diff --git a/.buildkite/Dockerfile b/.buildkite/Dockerfile index 5c4b64c2ab..f851f4369f 100644 --- a/.buildkite/Dockerfile +++ b/.buildkite/Dockerfile @@ -1,34 +1,17 @@ ARG RUBY_VERSION=${RUBY_VERSION:-3.1} -FROM ruby:$RUBY_VERSION - -# Default UID/GID to 1000 -# it can be overridden at build time -ARG BUILDER_UID=1000 -ARG BUILDER_GID=1000 -ENV BUILDER_USER elastic -ENV BUILDER_GROUP elastic +ARG RUBY_SOURCE=${RUBY_SOURCE:-ruby} +FROM $RUBY_SOURCE:$RUBY_VERSION ARG QUIET=${QUIET:-true} ARG CI=${CI:-false} ENV QUIET=$QUIET ENV CI=$CI +ARG TRANSPORT_VERSION=${TRANSPORT_VERSION:-8} # Install required tools -RUN apt-get -q update \ - && apt-get -y install zip curl - -# Create user -RUN groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP} \ - && useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GROUP} -d /var/lib/elastic -m elastic 1>/dev/null 2>/dev/null \ - && mkdir -p /usr/src/app && touch /Gemfile.lock \ - && chown -R ${BUILDER_USER}:${BUILDER_GROUP} /usr/src/app /Gemfile.lock - -COPY --chown=$BUILDER_USER:$BUILDER_GROUP . . - +RUN apt-get -q update && apt-get -y install zip curl git WORKDIR /usr/src/app - -USER ${BUILDER_USER}:${BUILDER_GROUP} - +COPY . . RUN bundle install \ && bundle exec rake bundle:clean \ && rake bundle:install diff --git a/.buildkite/create-serverless.sh b/.buildkite/create-serverless.sh new file mode 100755 index 0000000000..7b7d2c1dcf --- /dev/null +++ b/.buildkite/create-serverless.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if [[ -z $EC_PROJECT_PREFIX ]]; then + echo -e "\033[31;1mERROR:\033[0m Required environment variable [EC_PROJECT_PREFIX] not set\033[0m" + exit 1 +fi + +# Using BUILDKITE_JOB_ID for the name to make it unique: +export EC_PROJECT_NAME="$EC_PROJECT_PREFIX-$BUILDKITE_JOB_ID" +echo -e "--- :elasticsearch: Start serverless instance $EC_PROJECT_NAME" + +qaf elastic-cloud projects create --project-type elasticsearch +deployment=$(qaf elastic-cloud projects describe $EC_PROJECT_NAME --as-json --show-credentials) + +# Set ELASTICSEARCH_URL and API_KEY variables +export ES_API_SECRET_KEY=$(echo "$deployment" | jq -r '.credentials.api_key') +export ELASTICSEARCH_URL=$(echo "$deployment" | jq -r '.elasticsearch.url') +buildkite-agent meta-data set "ES_API_SECRET_KEY" $ES_API_SECRET_KEY +buildkite-agent meta-data set "ELASTICSEARCH_URL" $ELASTICSEARCH_URL +buildkite-agent meta-data set "EC_PROJECT_NAME" $EC_PROJECT_NAME + +echo -e "--- :computer: Environment variables" +echo -e "ELASTICSEARCH_URL $ELASTICSEARCH_URL" diff --git a/.buildkite/functions/wait-for-container.sh b/.buildkite/functions/wait-for-container.sh index 1a721b588f..89d65f4e7d 100755 --- a/.buildkite/functions/wait-for-container.sh +++ b/.buildkite/functions/wait-for-container.sh @@ -14,7 +14,7 @@ function wait_for_container { echo "" docker inspect -f "{{range .State.Health.Log}}{{.Output}}{{end}}" ${1} echo -e "\033[34;1mINFO:\033[0m waiting for node $1 to be up\033[0m" - sleep 2; + sleep 10; done; # Always show logs if the container is running, this is very useful both on CI as well as while developing diff --git a/.buildkite/log-results.sh b/.buildkite/log-results.sh index 7e3f9c922a..d3fb1c4e43 100755 --- a/.buildkite/log-results.sh +++ b/.buildkite/log-results.sh @@ -5,32 +5,20 @@ buildkite-agent annotate --style info "## :rspec: Tests summary :rspec: " buildkite-agent artifact download "elasticsearch-api/tmp/*" . -# Test result summary: -files="elasticsearch-api/tmp/*.html" +files="elasticsearch-api/tmp/*.log" for f in $files; do - TEST_SUITE=`echo $f | grep -o "\(free\|platinum\)"` - RUBY_VERSION=`echo $f | grep -Po "(\d+\.)+\d+"` - EXAMPLES=`cat $f | grep -o "[0-9]\+ examples\?" | tail -1` - FAILURES=`cat $f | grep -o "[0-9]\+ failures\?" | tail -1` - PENDING=`cat $f | grep -o "[0-9]\+ pending" | tail -1` + RUBY_VERSION=`echo $f | grep -Po "(j?ruby-|\d+\.)+\d+" | tail -1` + TRANSPORT_VERSION=`echo $f | grep -Po "transport-([\d.]+|main)"` buildkite-agent annotate --append " -:ruby: $RUBY_VERSION :test_tube: $TEST_SUITE :rspec: $EXAMPLES - :x: $FAILURES - :suspect: $PENDING +:ruby: $RUBY_VERSION :phone: $TRANSPORT_VERSION `tail --lines=2 $f | awk -F "-- :" '{print $2}'` + " -done -files="elasticsearch-api/tmp/*.log" -for f in $files; do - FAILED_TESTS=`awk 'BEGIN { FS = " | "}; /\| failed \|/{ print $1 }' $f | uniq` + FAILED_TESTS=`grep -A1 "E,.*" $f | sed 's/\#/-/g' | sed 's/^--/\n/g'` if [[ -n "$FAILED_TESTS" ]]; then - buildkite-agent annotate --append " -#### Failures in $f -" - FAILURES_ARRAY=($(echo $FAILED_TESTS | tr ' ' "\n")) - for f in "${FAILURES_ARRAY[@]}" - do - buildkite-agent annotate --append " -- $f -" - done + buildkite-agent annotate --append "
" + buildkite-agent annotate --append ":x: Failures in $f +$FAILED_TESTS +
" fi done diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index a6f11c5a41..1fdc76b1fd 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,36 +1,93 @@ steps: - - label: ":elasticsearch: :ruby: ES Ruby ({{ matrix.ruby }}) Test Suite: {{ matrix.suite }}" + - label: >- + :yaml: YAML test suite :ruby: {{ matrix.ruby_source}}:{{ matrix.ruby }} + :phone: Transport {{ matrix.transport }} agents: - provider: "gcp" - env: - RUBY_VERSION: "{{ matrix.ruby }}" - TEST_SUITE: "{{ matrix.suite }}" - STACK_VERSION: 8.10.0-SNAPSHOT + provider: gcp matrix: setup: - suite: - - "free" - - "platinum" ruby: - - "3.2" - - "3.1" - - "3.0" - # Only run platinum once for the latest Ruby. You can use lots of combinations, check the - # documentation on https://buildkite.com/docs/pipelines/build-matrix for more information. + - '3.4' + - '3.3' + - '3.2' + ruby_source: + - ruby + transport: + - '8.4' adjustments: - - with: - suite: "platinum" - ruby: "3.1" - skip: true - - with: - suite: "platinum" - ruby: "3.0" - skip: true - command: ./.buildkite/run-tests.sh - # I'm publishing test results to HTML and JUnit in this directory and this directive makes them - # available in the Artifacts tab of a build in Buildkite. - artifact_paths: "elasticsearch-api/tmp/*" + - with: # JRuby tests + ruby: '9.4' + ruby_source: jruby + transport: '8.4' + - with: # Test for main branch of transport + ruby: '3.4' + ruby_source: ruby + transport: main + env: + RUBY_VERSION: '{{ matrix.ruby }}' + STACK_VERSION: 9.1.0-SNAPSHOT + ES_YAML_TESTS_BRANCH: main + TRANSPORT_VERSION: '{{ matrix.transport }}' + RUBY_SOURCE: '{{ matrix.ruby_source }}' + TEST_SUITE: platinum + DEBUG: true + command: ./.buildkite/run-yaml-tests.sh + artifact_paths: elasticsearch-api/tmp/* + - group: 'Elasticsearch Serverless :elasticsearch:' + steps: + - label: 'Create :elasticsearch: Serverless projects' + key: create-serverless + agents: + image: 'docker.elastic.co/appex-qa/qaf:latest' + env: + EC_PROJECT_PREFIX: ruby + EC_REGISTER_BACKEND: buildkite + EC_REGION: aws-eu-west-1 + EC_ENV: qa + commands: + - mkdir ~/.elastic + - touch ~/.elastic/cloud.json + - >- + echo "{\"api_key\":{\"qa\":\"$(vault read -field=qa + secret/ci/elastic-elasticsearch-ruby/cloud-access)\"}}" > + ~/.elastic/cloud.json + - ./.buildkite/create-serverless.sh + - label: 'Run :elasticsearch: Serverless :rspec: Tests :ruby:' + key: run-serverless-tests + depends_on: + - step: create-serverless + agents: + provider: gcp + env: + RUBY_VERSION: '3.4' + RUBY_SOURCE: ruby + TEST_SUITE: serverless + ES_YAML_TESTS_BRANCH: main + QUIET: false + command: ./.buildkite/run-yaml-tests.sh + artifact_paths: elasticsearch-api/tmp/* + - label: 'Destroy :elasticsearch: Serverless projects' + depends_on: + - step: run-serverless-tests + allow_failure: true + agents: + image: 'docker.elastic.co/appex-qa/qaf:latest' + env: + EC_REGISTER_BACKEND: buildkite + EC_ENV: qa + EC_REGION: aws-eu-west-1 + commands: + - mkdir ~/.elastic + - touch ~/.elastic/cloud.json + - >- + export EC_PROJECT_NAME=`buildkite-agent meta-data get + "EC_PROJECT_NAME"` + - >- + echo "{\"api_key\":{\"qa\":\"$(vault read -field=qa + secret/ci/elastic-elasticsearch-ruby/cloud-access)\"}}" > + ~/.elastic/cloud.json + - qaf elastic-cloud projects delete - wait: ~ continue_on_failure: true - - label: "Log Results" + - label: Log Results command: ./.buildkite/log-results.sh diff --git a/.buildkite/run-client.sh b/.buildkite/run-client.sh deleted file mode 100755 index 4f7cefba63..0000000000 --- a/.buildkite/run-client.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# -# Once called Elasticsearch should be up and running -# -script_path=$(dirname $(realpath -s $0)) -set -euo pipefail -repo=`pwd` - -export RUBY_VERSION=${RUBY_VERSION:-3.1} - -echo "--- :ruby: Building Docker image" -docker build \ - --file $script_path/Dockerfile \ - --tag elastic/elasticsearch-ruby \ - --build-arg RUBY_VERSION=$RUBY_VERSION \ - . - -mkdir -p elasticsearch-api/tmp - -echo "--- :ruby: Running $TEST_SUITE tests" -docker run \ - -u "$(id -u)" \ - --network="${network_name}" \ - --env "TEST_ES_SERVER=${elasticsearch_url}" \ - --env "ELASTIC_PASSWORD=${elastic_password}" \ - --env "TEST_SUITE=${TEST_SUITE}" \ - --env "ELASTIC_USER=elastic" \ - --env "BUILDKITE=true" \ - --volume $repo:/usr/src/app \ - --name elasticsearch-ruby \ - --rm \ - elastic/elasticsearch-ruby \ - bundle exec rake elasticsearch:download_artifacts test:platinum:integration test:rest_api diff --git a/.buildkite/run-serverless-tests.sh b/.buildkite/run-serverless-tests.sh new file mode 100755 index 0000000000..d145d6e6d3 --- /dev/null +++ b/.buildkite/run-serverless-tests.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# Once called Elasticsearch should be up and running +# +script_path=$(dirname $(realpath -s $0)) +set -euo pipefail +repo=`pwd` + +export RUBY_VERSION=${RUBY_VERSION:-3.4} +export BUILDKITE=${BUILDKITE:-false} +export TRANSPORT_VERSION=${TRANSPORT_VERSION:-8} +ELASTICSEARCH_URL=`buildkite-agent meta-data get "ELASTICSEARCH_URL"` +ES_API_SECRET_KEY=`buildkite-agent meta-data get "ES_API_SECRET_KEY"` + +echo "--- :ruby: Building Docker image" +docker build \ + --file $script_path/Dockerfile \ + --tag elastic/elasticsearch-ruby \ + --build-arg RUBY_VERSION=$RUBY_VERSION \ + --build-arg TRANSPORT_VERSION=$TRANSPORT_VERSION \ + --build-arg RUBY_SOURCE=$RUBY_SOURCE \ + . + +mkdir -p elasticsearch-api/tmp + +echo "--- :ruby: Running $TEST_SUITE tests" +docker run \ + -u "$(id -u)" \ + -e "ELASTIC_USER=elastic" \ + -e "QUIET=${QUIET}" \ + -e "BUILDKITE=${BUILDKITE}" \ + -e "TRANSPORT_VERSION=${TRANSPORT_VERSION}" \ + -e "ELASTICSEARCH_URL=${ELASTICSEARCH_URL}" \ + -e "ES_API_KEY=${ES_API_SECRET_KEY}" \ + --volume $repo:/usr/src/app \ + --name elasticsearch-ruby \ + --rm \ + elastic/elasticsearch-ruby \ + bundle exec bundle exec rake test:yaml diff --git a/.buildkite/run-tests.sh b/.buildkite/run-tests.sh deleted file mode 100755 index 12a24c2912..0000000000 --- a/.buildkite/run-tests.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# -# Script to run Elasticsearch container and Elasticsearch client integration tests on Buildkite -# -# Version 0.1 -# -script_path=$(dirname $(realpath -s $0)) -source $script_path/functions/imports.sh -set -euo pipefail - -echo "--- :elasticsearch: Starting Elasticsearch" -DETACH=true bash $script_path/run-elasticsearch.sh - -echo "+++ :ruby: Run Client" -bash $script_path/run-client.sh diff --git a/.buildkite/run-yaml-tests.sh b/.buildkite/run-yaml-tests.sh new file mode 100755 index 0000000000..59faabb19c --- /dev/null +++ b/.buildkite/run-yaml-tests.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# +# Script to run YAML runner integration tests on Buildkite +# +# Version 0.1 +# +script_path=$(dirname $(realpath -s $0)) + +if [[ "$TEST_SUITE" == "serverless" ]]; then + # Get Elasticsearch Serverless credentials and endpoint + export TEST_ES_SERVER=`buildkite-agent meta-data get "ELASTICSEARCH_URL"` + export ES_API_SECRET_KEY=`buildkite-agent meta-data get "ES_API_SECRET_KEY"` +else + # Start Elasticsearch Stack on Docker + source $script_path/functions/imports.sh + echo "--- :elasticsearch: Starting Elasticsearch" + DETACH=true bash $script_path/run-elasticsearch.sh +fi + +set -euo pipefail +repo=`pwd` + +export RUBY_VERSION=${RUBY_VERSION:-3.1} +export BUILDKITE=${BUILDKITE:-false} +export TRANSPORT_VERSION=${TRANSPORT_VERSION:-8} +export QUIET=${QUIET:-false} +export DEBUG=${DEBUG:-false} +export TEST_SUITE=${TEST_SUITE:-platinum} + +echo "--- :ruby: Building Docker image" +docker build \ + --file $script_path/Dockerfile \ + --tag elastic/elasticsearch-ruby \ + --build-arg RUBY_VERSION=$RUBY_VERSION \ + --build-arg TRANSPORT_VERSION=$TRANSPORT_VERSION \ + --build-arg RUBY_SOURCE=$RUBY_SOURCE \ + . + +mkdir -p elasticsearch-api/tmp + +if [[ "$TEST_SUITE" == "serverless" ]]; then + echo "--- :ruby: Running :yaml: tests" + docker run \ + -u "$(id -u)" \ + --env "TEST_ES_SERVER=${TEST_ES_SERVER}" \ + --env "ES_API_KEY=${ES_API_SECRET_KEY}" \ + --env "BUILDKITE=${BUILDKITE}" \ + --env "TRANSPORT_VERSION=${TRANSPORT_VERSION}" \ + --env "ES_YAML_TESTS_BRANCH=${ES_YAML_TESTS_BRANCH}" \ + --env "TEST_SUITE=${TEST_SUITE}" \ + --env "DEBUG=${DEBUG}" \ + --env "QUIET=${QUIET}" \ + --volume $repo:/usr/src/app \ + --name elasticsearch-ruby \ + --rm \ + elastic/elasticsearch-ruby \ + bundle exec rake test:yaml +else + echo "--- :ruby: Running stack tests" + docker run \ + -u "$(id -u)" \ + --network="${network_name}" \ + --env "TEST_ES_SERVER=${elasticsearch_url}" \ + --env "ELASTIC_PASSWORD=${elastic_password}" \ + --env "ELASTIC_USER=elastic" \ + --env "STACK_VERSION=${STACK_VERSION}" \ + --env "BUILDKITE=${BUILDKITE}" \ + --env "TRANSPORT_VERSION=${TRANSPORT_VERSION}" \ + --env "ES_YAML_TESTS_BRANCH=${ES_YAML_TESTS_BRANCH}" \ + --env "TEST_SUITE=${TEST_SUITE}" \ + --env "DEBUG=${DEBUG}" \ + --env "QUIET=${QUIET}" \ + --volume $repo:/usr/src/app \ + --name elasticsearch-ruby \ + --rm \ + elastic/elasticsearch-ruby \ + bundle exec rake test:yaml +fi diff --git a/.github/create_jenkins_job.rb b/.github/create_jenkins_job.rb deleted file mode 100644 index 735d3b9dcf..0000000000 --- a/.github/create_jenkins_job.rb +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -source_branch = ARGV[0] -target_branch = ARGV[1] - -def usage - <<~USAGE - - This script creates a new Jenkins Job in .ci/jobs. It takes two parameters: - - source branch: branch name for the job to use as a source - - target branch: branch name for the new job - In the new file, it is going to replace the source branch value with the target branch value and - create a new yml file based on that. - - E.g.: - $ #{__FILE__} 7.x 7.99 - This is going to use .ci/jobs/elastic+elasticsearch-ruby+7.x.yml as a source and create - .ci/jobs/elastic+elasticsearch-ruby+7.99.yml and replace all the ocurrences of '7.x' with '7.99' - in the new file. - USAGE -end - -unless source_branch && target_branch - puts usage - exit -end - -job_file = File.expand_path("../.ci/jobs/elastic+elasticsearch-ruby+#{source_branch}.yml", __dir__) -raise ArgumentError, "cannot find file #{job_file}" unless File.exist? job_file - -target_branch_file = File.expand_path("../.ci/jobs/elastic+elasticsearch-ruby+#{target_branch}.yml", __dir__) -target_branch_content = File.read(job_file).gsub(source_branch, target_branch) - -begin - File.open(target_branch_file, 'w') { |file| file.puts target_branch_content } -rescue StandardError => e - raise e -end diff --git a/.ci/make.sh b/.github/make.sh similarity index 78% rename from .ci/make.sh rename to .github/make.sh index 9ec3e82f25..b36c4cea5b 100755 --- a/.ci/make.sh +++ b/.github/make.sh @@ -3,7 +3,7 @@ # # Build entry script for elasticsearch-ruby # -# Must be called: ./.ci/make.sh +# Must be called: ./.github/make.sh # # Version: 1.1.0 # @@ -34,34 +34,23 @@ STACK_VERSION=$VERSION set -euo pipefail product="elastic/elasticsearch-ruby" -output_folder=".ci/output" -codegen_folder=".ci/output" -OUTPUT_DIR="$repo/${output_folder}" -REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}" -RUBY_VERSION=${RUBY_VERSION-3.1} +RUBY_VERSION=${RUBY_VERSION-3.3} WORKFLOW=${WORKFLOW-staging} -mkdir -p "$OUTPUT_DIR" echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m" echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m" -echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m" echo -e "\033[34;1mINFO:\033[0m RUBY_VERSION ${RUBY_VERSION}\033[0m" case $CMD in clean) echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m" - rm -rf "$output_folder" + rm -rf "/build" echo -e "\033[32;1mdone.\033[0m" exit 0 ;; assemble) - if [ -v $VERSION ]; then - echo -e "\033[31;1mTARGET: assemble -> missing version parameter\033[0m" - exit 1 - fi - echo -e "\033[36;1mTARGET: assemble artefact $VERSION\033[0m" - TASK=assemble - TASK_ARGS=("$VERSION" "$output_folder") + echo -e "\033[36;1mTARGET: assemble\033[0m" + TASK=build_gems ;; codegen) TASK=codegen @@ -74,13 +63,10 @@ case $CMD in fi echo -e "\033[36;1mTARGET: generate docs for $VERSION\033[0m" TASK=codegen - # VERSION is BRANCH here for now - TASK_ARGS=("$VERSION" "$codegen_folder") ;; examplesgen) echo -e "\033[36;1mTARGET: generate docs examples\033[0m" TASK='docs:generate' - # VERSION is BRANCH here for now TASK_ARGS=() ;; bump) @@ -134,8 +120,6 @@ docker build --no-cache --build-arg BUILDER_UID="$(id -u)" --file .buildkite/Doc echo -e "\033[34;1mINFO: running $product container\033[0m" -mkdir -p "$OUTPUT_DIR" - # Convert ARGS to comma separated string for Rake: args_string="${TASK_ARGS[*]}" args_string="${args_string// /,}" @@ -144,26 +128,16 @@ docker run \ -u "$(id -u)" \ --env "RUBY_VERSION=${RUBY_VERSION}" \ --env "WORKFLOW=${WORKFLOW}" \ + --env "CLIENTS_GITHUB_TOKEN=${CLIENTS_GITHUB_TOKEN}" \ --name test-runner \ - --volume "${REPO_BINDING}" \ --volume "${repo}:/usr/src/app" \ --rm \ "${product}" \ - bundle exec rake unified_release:${TASK}["${args_string}"] + bundle exec rake automation:${TASK}["${args_string}"] # ------------------------------------------------------- # # Post Command tasks & checks # ------------------------------------------------------- # - -if [[ "$CMD" == "assemble" ]]; then - if compgen -G ".ci/output" > /dev/null; then - echo -e "\033[32;1mTARGET: successfully assembled client v$VERSION\033[0m" - else - echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m" - exit 1 - fi -fi - if [[ "$CMD" == "docsgen" ]]; then echo "TODO" fi diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml new file mode 100644 index 0000000000..bb466166d0 --- /dev/null +++ b/.github/workflows/docs-build.yml @@ -0,0 +1,19 @@ +name: docs-build + +on: + push: + branches: + - main + pull_request_target: ~ + merge_group: ~ + +jobs: + docs-preview: + uses: elastic/docs-builder/.github/workflows/preview-build.yml@main + with: + path-pattern: docs/** + permissions: + deployments: write + id-token: write + contents: read + pull-requests: read diff --git a/.github/workflows/docs-cleanup.yml b/.github/workflows/docs-cleanup.yml new file mode 100644 index 0000000000..f83e017b5f --- /dev/null +++ b/.github/workflows/docs-cleanup.yml @@ -0,0 +1,14 @@ +name: docs-cleanup + +on: + pull_request_target: + types: + - closed + +jobs: + docs-preview: + uses: elastic/docs-builder/.github/workflows/preview-cleanup.yml@main + permissions: + contents: none + id-token: write + deployments: write diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index d7357e56e7..e556b833ee 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -4,10 +4,10 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3 + ruby-version: '3.4' - name: Check license headers run: | ruby ./.github/check_license_headers.rb diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 428a03e7e9..b1d5d5a65f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,10 +14,10 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ '3.0', '3.1', '3.2', 'jruby-9.3', 'jruby-9.4' ] + ruby: ['head', '3.2', '3.3', '3.4', 'jruby-9.3', 'jruby-9.4', 'jruby-head'] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Increase system limits run: | sudo swapoff -a @@ -26,8 +26,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 8.10.0-SNAPSHOT - security-enabled: false + stack-version: 9.1.0-SNAPSHOT - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -40,4 +39,4 @@ jobs: - name: elasticsearch run: cd elasticsearch && bundle exec rake test:all - name: elasticsearch-api - run: cd elasticsearch-api && bundle exec rake test:spec test:platinum:unit + run: rake es:download_artifacts[9.1.0-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:all diff --git a/.github/workflows/otel.yml b/.github/workflows/otel.yml new file mode 100644 index 0000000000..b7bca6a485 --- /dev/null +++ b/.github/workflows/otel.yml @@ -0,0 +1,44 @@ +name: opentelemetry +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + test-otel: + name: 'Test Open Telemetry' + env: + TEST_ES_SERVER: http://localhost:9250 + PORT: 9250 + TEST_WITH_OTEL: true + strategy: + fail-fast: false + matrix: + ruby: ['3.4', 'jruby-9.4'] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 9.1.0-SNAPSHOT + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Build + run: | + sudo apt-get update + sudo apt-get install libcurl4-openssl-dev + rake bundle:clean + rake bundle:install + - name: elasticsearch + run: cd elasticsearch && bundle exec rake test:all + - name: elasticsearch-api + run: rake es:download_artifacts[9.1.0-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:all diff --git a/.github/workflows/unified-release.yml b/.github/workflows/unified-release.yml deleted file mode 100644 index 75de2ec33c..0000000000 --- a/.github/workflows/unified-release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Unified Release - -on: - pull_request: - paths-ignore: - - 'README.md' - push: - paths-ignore: - - 'README.md' - branches: - - main - - master - - '[0-9]+.[0-9]+' - - '[0-9]+.x' - -jobs: - assemble: - name: Assemble - runs-on: ubuntu-latest - env: - stack-version: 8.10.0-SNAPSHOT - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Assemble ${{ env.STACK_VERSION }} - run: "./.ci/make.sh assemble ${{ env.stack-version }}" diff --git a/.gitignore b/.gitignore index 8227873292..b6ec5bd32e 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,7 @@ Gemfile.lock profile/**/data/*.json .ci/output parsed_alternative_report.json -.byebug_history \ No newline at end of file +.byebug_history +build/ +*.gem +elastic-client-generator-ruby \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ffac783793..ac3416994b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,380 @@ -*To see release notes for the `7.x` branch and older releases, see [CHANGELOG on the 7.17 branch](https://github.com/elastic/elasticsearch-ruby/blob/7.17/CHANGELOG.md).* +*See the full release notes on the official documentation website: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/release_notes.html* + +## 8.17.0 Release notes + +### Client +* Tested versions of Ruby for 8.17.0: Ruby (MRI) 3.1, 3.2 and 3.3. JRuby 9.3 and JRuby 9.4. + +### API + +#### API changes +* `async_search.submit` - Removes `keep_alive` parameter. Adds: + * `ccs_minimize_roundtrips` (Boolean): When doing a cross-cluster search, setting it to true may improve overall search latency, particularly when searching clusters with a large number of shards. However, when set to true, the progress of searches on the remote clusters will not be received until the search finishes on all clusters. + * `rest_total_hits_as_int` (Boolean): Indicates whether hits.total should be rendered as an integer or an object in the rest search response. +* `open_point_in_time` - Adds `allow_partial_search_results` (Boolean) parameter: Specify whether to tolerate shards missing when creating the point-in-time, or otherwise throw an exception (default: false). + + +## 8.16.0 Release notes + +### Client +* Tested versions of Ruby for 8.16.0: Ruby (MRI) 3.1, 3.2 and 3.3. JRuby 9.3 and JRuby 9.4. + +### API + +#### API changes + +* `capabilities` - Adds `local_only` boolean parameter: True if only the node being called should be considered. +* `cluster.stats`- Removes `flat_settings` parameter, adds `include_remotes` boolean parameter: Include remote cluster data into the response (default: false) +* `indices.get_data_stream` - Adds `verbose` boolean parameter: Whether the maximum timestamp for each data stream should be calculated and returned (default: false). Adds `master_timeout` (see below). +* `query_rules.delete_ruleset` - Accepts `ignore: 404` common parameter. + +##### Timeout parameters: + +These parameters have been added to several APIs: + +* `master_timeout` timeout for processing on master node. +* `timeout` timeout for acknowledgement of update from all nodes in cluster parameters. + +Added in: + +* `indices.create_data_stream` - both. +* `indices.delete_data_stream` - `master_timeout`. +* `indices.get_data_lifecycle` - `master_timeout`. +* `indices.get_data_stream` - `master_timeout`. +* `indices.migrate_to_data_stream` - both. +* `indices.promote_data_stream` - `master_timeout`. +* `search_shards` - `master_timeout`. + +#### APIs Promoted from Experimental to Stable: + +* `indices.delete_data_lifecycle` +* `indices.explain_data_lifecycle` +* `indices.get_data_lifecycle` +* `indices.put_data_lifecycle` +* `security.create_cross_cluster_api_key` +* `security.update_cross_cluster_api_key` + +#### New APIs + +* `ingest.delete_ip_location_database` - Deletes an ip location database configuration. +* `ingest.get_ip_location_database` - Returns the specified ip location database configuration. +* `ingest.put_ip_location_database` - Puts the configuration for a ip location database to be downloaded. + + +#### New Experimental APIs + +* `inference.stream_inference` - Perform streaming inference. +* `query_rules.test` - Tests a query ruleset to identify the rules that would match input criteria. + + +## 8.15.0 Release notes + +### Client +* Tested versions of Ruby for 8.15.0: Ruby (MRI) 3.0, 3.1, 3.2 and 3.3. JRuby 9.3 and JRuby 9.4. + +#### API changes + +* `snapshot.delete` - Adds `wait_for_completion` Boolean parameter, should this request wait until the operation has completed before returning. +* `cluster.allocation_explain` - `body` is no longer a required parameter. +* `connector.put` - (experimental API) `body` and `connector_id` no longer required parameters. +* `machine_learning.update_trained_model_deployment` has been promoted to stable from Beta. Adds Integer parameter `number_of_allocations`, updates the model deployment to this number of allocations. + +##### `master_timeout` and `timeout` parameters + +These parameters have been added to several APIs: + +* `master_timeout` timeout for processing on master node. +* `timeout` timeout for acknowledgement of update from all nodes in cluster parameters. + +The APIs: + +* `autoscaling.delete_autoscaling_policy` - both. +* `autoscaling.get_autoscaling_capacity`- `master_timeout`. +* `get_autoscaling_policy` - `master_timeout`. +* `put_autoscaling_policy` - both. +* `enrich.delete_policy` - `master_timeout`. +* `enrich.execute_policy` - `master_timeout`. +* `enrich.get_policy` - `master_timeout`. +* `enrich.put_policy` - `master_timeout`. +* `enrich.stats` - `master_timeout`. +* `features.reset_features` - `master_timeout`. +* `license.delete` - both. +* `license.post` - both. +* `license.post_start_basic` - both. +* `license.post_start_trial` - both. +* `security.get_settings` - `master_timeout`. +* `security.update_settings` - both. +* `shutdown.get_node` - `master_timeout`. +* `snapshot_lifecycle_management.start` - both. +* `snapshot_lifecycle_management.stop` - both. +* `watcher.get_settings` - `master_timeout`. +* `watcher.start` - `master_timeout`. +* `watcher.stop` - `master_timeout`. +* `watcher.update_settings` - both. + +##### Inference APIs have been renamed: + +* `inference.delete_model` => `inference.delete`. Also adds two new parameters: + * `dry_run` (Boolean), if true the endpoint will not be deleted and a list of ingest processors which reference this endpoint will be returned. + * `force` (Boolean), if true the endpoint will be forcefully stopped (regardless of whether or not it is referenced by any ingest processors or semantic text fields). +* `inference.get_model` => `inference.get` +* `inference.put_model` => `inference.put` + +##### Query Rules parameters consolidated + +Changes in `query_ruleset` and `query_rules` APIs, these have been combined into the `query_rules` namespace: + +* `query_rules.delete_ruleset` - Renamed from `query_ruleset.delete`, promoted from experimental to stable. +* `query_rules.delete_rule` - Deletes an individual query rule within a ruleset. +* `query_rules.get_rule` - Returns the details about an individual query rule within a ruleset. +* `query_rules.get_ruleset` - Renamed from `query_ruleset.get`, promoted from experimental to stable. +* `query_rules.list_rulesets` - Renamed from `query_ruleset.list`, promoted from experimental to stable. +* `query_rules.put_rule` - Creates or updates a query rule within a ruleset. +* `query_rules.put_ruleset` - Renamed from `query_ruleset.put_ruleset`, promoted from experimental to stable. + +#### New APIs: + +* `ingest.delete_geoip_database` - Deletes a geoip database configuration. +* `ingest.get_geoip_database` - Returns geoip database configuration. +* `ingest.put_geoip_database` - Puts the configuration for a geoip database to be downloaded. +* `security.bulk_delete_role` - Bulk delete roles in the native realm. +* `security.bulk_put_role` - Bulk adds and updates roles in the native realm. +* `security.query_role` - Retrieves information for Roles using a subset of query DSL. +* `transform.get_node_stats` - Retrieves transform usage information for transform nodes. + +#### New Experimental APIs: + +* `connector.sync_job_claim` - Claims a connector sync job. +* `connector.update_features` - Updates the connector features in the connector document. + +### Development + +- Added a build using [es-test-runner-ruby](https://github.com/elastic/es-test-runner-ruby) and [Elasticsearch Clients Tests](https://github.com/elastic/elasticsearch-clients-tests) which will replace the Elasticsearch YAML test runner. + +## 8.14.0 Release notes + +### Client +* Tested versions of Ruby for 8.14.0: Ruby (MRI) 3.0, 3.1, 3.2 and 3.3. JRuby 9.3 and JRuby 9.4. + +### API + +API changes: + +- All Connector APIs have been migrated to one common namespace `connector`: + - `connector_secret.delete` -> `connector.secret_delete` + - `connector_secret.get` -> `connector.secret_get` + - `connector_secret.post` -> `connector.secret_post` + - `connector_secret.put` -> `connector.secret_put` + - `connector_sync_job.cancel` -> `connector.sync_job_cancel` + - `connector_sync_job.check_in` -> `connector.sync_job_check_in` + - `connector_sync_job.delete` -> `connector.sync_job_delete` + - `connector_sync_job.error` -> `connector.sync_job_error` + - `connector_sync_job.get` -> `connector.sync_job_get` + - `connector_sync_job.post` -> `connector.sync_job_post` + - `connector_sync_job.update_stats` -> `connector.sync_job_update_stats` + +- `connector.delete` - Adds Boolean parameter `:delete_sync_jobs`: Determines whether associated sync jobs are also deleted. +- `cross_cluster_replication.delete_auto_follow_pattern`, `cross_cluster_replication.follow`, `cross_cluster_replication.follow_info`, `cross_cluster_replication.get_auto_follow_pattern`, `cross_cluster_replication.pause_auto_follow_pattern`, `cross_cluster_replication.pause_follow`, `cross_cluster_replication.put_auto_follow_pattern`, `cross_cluster_replication.resume_auto_follow_pattern`, `cross_cluster_replication.resume_follow`, `cross_cluster_replication.stats`, `cross_cluster_replication.unfollow` - Add Time parameter `:master_timeout`: Explicit operation timeout for connection to master node. +- `cross_cluster_replication.follow_stats`, `cross_cluster_replication.forget_follower`, `cross_cluster_replication.stats` - Add Time parameter `:timeout`: Explicit operation timeout. +- `indices/rollover` - Adds Boolean parameter `:target_failure` If set to true, the rollover action will be applied on the failure store of the data stream. +- `inference.get_model` - Parameter `inference_id` no longer required. +- `search_application.search` - Adds Boolean parameter `:typed_keys`: Specify whether aggregation and suggester names should be prefixed by their respective types in the response. +- `security.get_api_key`, `security.query_api_keys` - Add Boolean parameter `:with_profile_uid`: flag to also retrieve the API Key's owner profile uid, if it exists. + +New APIs: + +- `profiling.topn_functions` - Extracts a list of topN functions from Universal Profiling. +- `text_structure.find_field_structure` - Finds the structure of a text field in an index. +- `text_structure/find_message_structure`- Finds the structure of a list of messages. The messages must contain data that is suitable to be ingested into Elasticsearch. + +APIs Migrated from experimental to stable: + +- `esql.async_query` +- `esql.query` + +New Experimental APIs: + +- `connector.update_active_filtering` - Activates the draft filtering rules if they are in a validated state. +- `connector.update_filtering_validation` - Updates the validation info of the draft filtering rules. + +## 8.13.0 Release notes + +### Client +* Tested versions of Ruby for 8.13.0: Ruby (MRI) 3.0, 3.1, 3.2 and 3.3. JRuby 9.3 and JRuby 9.4. + +### Experimental ES|QL Helper + +This version provides a new experimental Helper for the ES|QL `query` API. Please check out [the documentation](https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/Helpers.html#esql-helper) and [open an issue](https://github.com/elastic/elasticsearch-ruby/issues/new/choose) if you encounter any problems or have any feedback. + +### API + +API Changes: + +* `async_search.status` - adds Time `:keep_alive` parameter: Specify the time interval in which the results (partial or final) for this search will be available. +* `bulk` - adds boolean `:require_data_stream` parameter: When true, requires the destination to be a data stream (existing or to-be-created). Default is false. +* `connector.list` - Adds the following parameters: + * `:index_name` (List): A comma-separated list of connector index names to fetch connector documents for. + * `:connector_name` (List): A comma-separated list of connector names to fetch connector documents for. + * `:service_type` (List): A comma-separated list of connector service types to fetch connector documents for. + * `:query` (String): A search string for querying connectors, filtering results by matching against connector names, descriptions, and index names. +* `esql.query` - adds boolean `:drop_null_columns` parameter: Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. +* `field_caps` - Adds `:include_empty_fields` boolean parameter: Include empty fields in result. +* `index` - adds boolean `:require_data_stream` parameter: When true, requires the destination to be a data stream (existing or to-be-created). Default is false. +* `indices.rollover` - adds boolean `:lazy` parameter: If set to true, the rollover action will only mark a data stream to signal that it needs to be rolled over at the next write. Only allowed on data streams. +* connector_sync_job.list - adds List `:job_type` parameter: A comma-separated list of job types. +* `inference.delete_model`, `inference.get_model`, `inference.inference`, `inference.put_model`: renames `:model_id` parameter to `:inference_id`. +* `termvector` will show a warning since it's been deprecated. Please use the plural version, `termvectors`. + +New APIs: + +* `indices.resolve_cluster` - Resolves the specified index expressions to return information about each cluster, including the local cluster, if included. +* `profiling.flamegraph` - Extracts a UI-optimized structure to render flamegraphs from Universal Profiling. +* `profiling.stacktraces` - Extracts raw stacktrace information from Universal Profiling. +* `security.query_user` - Retrieves information for Users using a subset of query DSL +* `text_structure.test_grok_pattern` - Tests a Grok pattern on some text. + +APIs Migrated from experimental to stable: + +* `synonyms.delete_synonym` +* `synonyms.delete_synonym_rule` +* `synonyms.get_synonym` +* `synonyms.get_synonym_rule` +* `synonyms.get_synonyms_sets` +* `synonyms.put_synonym` +* `synonyms.put_synonym_rule` + +New Experimental APIs: + +* `connector.update_api_key_id` - Updates the API key id and/or API key secret id fields in the connector document. +* `connector.update_index_name` - Updates the index name of the connector. +* `connector.update_native` - Updates the is_native flag of the connector. +* `connector.update_service_type` - Updates the service type of the connector. +* `connector.update_status` - Updates the status of the connector. +* `esql.async_query` - Executes an ESQL request asynchronously +* `esql.async_query_get` - Retrieves the results of a previously submitted async query request given its ID. + +New Experimental namespace `connector_secret`: + +* `connector_secret.delete` - Deletes a connector secret. +* `connector_secret.get` - Retrieves a secret stored by Connectors. +* `connector_secret.post` - Creates a secret for a Connector. +* `connector_secret.put` - Creates or updates a secret for a Connector. + +### Development + +* Migrated from `byebug` to `debug`. +* Added extra testing for OpenTelemetry. + +## 8.12.0 Release notes + +### Client + +* Tested versions of Ruby for 8.12.0: Ruby (MRI) 3.0, 3.1, 3.2 and 3.3. JRuby 9.3 and JRuby 9.4. + +### API + +API Changes: + +* `bulk` - Adds boolean `:list_executed_pipelines` parameter: Sets `list_executed_pipelines` for all incoming documents. Defaults to unset (false). +* `indices.put_settings` - Adds boolean `:reopen` parameter: Whether to close and reopen the index to apply non-dynamic settings. If set to `true` the indices to which the settings are being applied will be closed temporarily and then reopened in order to apply the changes. The default is `false`. +* `open_point_in_time` - Adds Hash `:body` parameter: an index_filter specified with the Query DSL. +* `security.get_api_key` - Adds boolean `:active_only` parameter: flag to limit response to only active (not invalidated or expired) API keys. + +#### New APIs + +New API for [Universal profiling](https://www.elastic.co/guide/en/observability/8.12/universal-profiling.html): + +* `profiling.status` - Returns basic information about the status of Universal Profiling. + + +New experimental API: + +* `simulate.ingest` - Simulates running ingest with example documents. See: https://www.elastic.co/guide/en/elasticsearch/reference/8.12/simulate-ingest-api.html + +##### Connectors API + +Version 8.12 introduces the experimental [Connectors API](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/connector-apis.html). Use the following APIs to manage connectors: + +* `connector.post` - Creates a connector. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/create-connector-api.html) +* `connector.put` - Creates or updates a connector. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/create-connector-api.html) +* `connector.delete` - Deletes a connector. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/delete-connector-api.html) +* `connector.get` - Returns the details about a connector. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/get-connector-api.html) +* `connector.list` - Lists all connectors. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/list-connector-api.html) +* `connector.check_in` - Updates the last_seen timestamp in the connector document. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/check-in-connector-api.html) +* `connector.update_configuration` - Updates the connector configuration. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/update-connector-configuration-api.html) +* `connector.update_error` - Updates the error field in the connector document. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/update-connector-error-api.html) +* `connector.update_filtering` - Updates the filtering field in the connector document. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/update-connector-filtering-api.html) +* `connector.last_sync` - Updates the stats of last sync in the connector document. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/update-connector-last-sync-api.html) +* `connector.update_name` - Updates the name and/or description fields in the connector document. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/update-connector-name-description-api.html) +* `connector.update_pipeline` - Updates the pipeline field in the connector document. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/update-connector-pipeline-api.html) +* `connector.update_scheduling` - Updates the scheduling field in the connector document. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/update-connector-scheduling-api.html) + +Use the following APIs to manage sync jobs: + +* `connector_sync_job.cancel` - Cancels a connector sync job. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/cancel-connector-sync-job-api.html) +* `connector_sync_job.check_in` - Checks in a connector sync job (refreshes 'last_seen'). See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/check-in-connector-sync-job-api.html) +* `connector_sync_job.delete` - Deletes a connector sync job. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/delete-connector-sync-job-api.html) +* `connector_sync_job.error` - Sets an error for a connector sync job. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/set-connector-sync-job-error-api.html) +* `connector_sync_job.get` - Returns the details about a connector sync job. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/get-connector-sync-job-api.html) +* `connector_sync_job.list` - Lists all connector sync jobs. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/list-connector-sync-jobs-api.html) +* `connector_sync_job.post` - Creates a connector sync job. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/create-connector-sync-job-api.html) +* `connector_sync_job.update_stats` - Updates the stats fields in the connector sync job document. See [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/set-connector-sync-job-stats-api.html) + + + +## 8.11.0 Release notes + +### Client + +* Tested versions of Ruby for 8.11.0: Ruby (MRI) 3.0, 3.1 and 3.2. JRuby 9.3 and JRuby 9.4. +* Adds native support for *Open Telemetry*. See Open Telemetry for documentation. +* Improved documentation, now you can find more examples in Ruby in the [REST API reference](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/rest-apis.html). + +### API + +New Experimental APIs: +- `esql.query` - Executes an ESQL request. +- `inference.delete_model` - Delete model in the Inference API. +- `inference.get_model` - Get a model in the Inference API. +- `inference.inference` - Perform inference on a model. +- `inference.put_model` - Configure a model for use in the Inference API. + +## 8.10.0 Release notes + +### Client +* Tested versions of Ruby for 8.10.0: Ruby (MRI) 3.0, 3.1 and 3.2. JRuby 9.3 and JRuby 9.4. + +### API + +#### New Experimental APIs, for internal use: +- `fleet.delete_secret` +- `fleet.get_secret` +- `fleet.post_secret` + +#### New stable APIs: +- `security.get_settings` - Retrieve settings for the security system indices +- `security.update_settings` - Update settings for the security system indices + +#### New Experimental API: +- `query_ruleset.list` List query rulesets. + +#### API Changes: +- `indices.reload_search_analyzers` - Adds parameter `resource` changed resource to reload analyzers from if applicable + +Promoted from Experimental to Beta: +- `security.create_cross_cluster_api_key` +- `security.update_cross_cluster_api_key` + +#### Synonyms namespace update: + +All synonym related APIs have been moved to the `synonyms` namespace and some of the endpoints have been renamed, as well as their parameters: +- `synonyms.delete` => `synonyms.delete_synonym` - requires `id`, the id of the synonyms set to be deleted. +- `synonyms.get` => `synonyms.get_synonym` - requires `id`, the name of the synonyms set to be retrieved. +- `synonyms_set.get_synonyms_sets` => `synonyms.get_synonyms_sets` +- `synonyms.put` => `synonyms.put_synonym` - requires `id` of the synonyms set to be created or updated. +- `synonym_rule.put` => `synonyms.put_synonym_rule` - Parameters changed to `set_id` (the id of the synonym set to be updated with the synonym rule) and `rule_id` (the id of the synonym rule to be updated or created). +- New Experimental API `synonyms.delete_synonym_rule` - Deletes a synonym rule in a synonym set +- New Experimental API `synonyms.get_synonym_rule` - Retrieves a synonym rule from a synonym set ## 8.9.0 Release notes diff --git a/Gemfile b/Gemfile index f8150c9b0c..a2263210df 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,6 @@ gem 'cane' gem 'mocha' gem 'pry' gem 'rake' -gem 'rubocop' gem 'shoulda-context' gem 'simplecov' gem 'test-unit', '~> 2' @@ -37,6 +36,7 @@ unless defined?(JRUBY_VERSION) || defined?(Rubinius) end group :development, :test do - gem 'byebug' + gem 'debug' unless defined?(JRUBY_VERSION) gem 'rspec' + gem 'rubocop', '>= 1.51' unless defined?(JRUBY_VERSION) end diff --git a/README.md b/README.md index 3d0ed0755f..939ecf6e0a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Elasticsearch -[![7.17](https://github.com/elastic/elasticsearch-ruby/actions/workflows/7.17.yml/badge.svg?branch=7.17)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/7.17.yml) [![8.7](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.7.yml/badge.svg?branch=8.7)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.7.yml) [![8.8](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.8.yml/badge.svg?branch=8.8)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.8.yml) [![8.9](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.9.yml/badge.svg?branch=8.9)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.9.yml) [![main](https://github.com/elastic/elasticsearch-ruby/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/main.yml) [![Build status](https://badge.buildkite.com/e50e66eb71bf6566a6479c8a29b25458f6781ee8e52cee8d96.svg)](https://buildkite.com/elastic/elasticsearch-ruby) +[![8.17](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.17.yml/badge.svg?branch=8.17)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.17.yml) [![8.18](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.18.yml/badge.svg?branch=8.18)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/8.18.yml) [![9.0](https://github.com/elastic/elasticsearch-ruby/actions/workflows/9.0.yml/badge.svg?branch=9.0)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/9.0.yml) [![main](https://github.com/elastic/elasticsearch-ruby/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/elastic/elasticsearch-ruby/actions/workflows/main.yml) [![Build status](https://badge.buildkite.com/e50e66eb71bf6566a6479c8a29b25458f6781ee8e52cee8d96.svg)](https://buildkite.com/elastic/elasticsearch-ruby) + +**[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)** +or +**[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)** +**for a free trial of Elastic Cloud**. This repository contains the official [Elasticsearch](https://www.elastic.co/products/elasticsearch) Ruby client. The [`elasticsearch`](https://github.com/elasticsearch/elasticsearch-ruby/tree/main/elasticsearch) gem is a complete Elasticsearch client which uses two separate libraries: @@ -67,7 +72,28 @@ Please see their respective READMEs for information and documentation. We follow Ruby’s own maintenance policy and officially support all currently maintained versions per [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/). -Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made. +Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch without breaking. +It does not mean that the client automatically supports new features of newer Elasticsearch versions; it is only possible after a release of a new client version. +For example, a 8.12 client version won't automatically support the new features of the 8.13 version of Elasticsearch, the 8.13 client version is required for that. +Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made. + +| Gem Version | | Elasticsearch Version | Supported | +|-------------|---|------------------------|-----------| +| 8.x | → | 8.x | 8.x | +| 9.x | → | 9.x | 9.x | +| main | → | main | | + +## Try Elasticsearch and Kibana locally + +If you want to try Elasticsearch and Kibana locally, you can run the following command: + +```bash +curl -fsSL https://elastic.co/start-local | sh +``` + +This will run Elasticsearch at http://localhost:9200 and Kibana at http://localhost:5601 using Docker. + +More information is available [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/run-elasticsearch-locally.html). ## Development diff --git a/Rakefile b/Rakefile index a372b3c4d4..62a6205a2b 100644 --- a/Rakefile +++ b/Rakefile @@ -38,9 +38,9 @@ def admin_client } ) - url = "https://#{user}:#{password}@#{uri.host}:#{uri.port}" + url = "https://#{user}:#{password}@#{uri.host}:#{uri.port}" else - url = "http://#{user}:#{password}@#{uri.host}:#{uri.port}" + url = "http://#{user}:#{password}@#{uri.host}:#{uri.port}" end puts "Elasticsearch Client url: #{url}" Elasticsearch::Client.new(host: url, transport_options: transport_options) @@ -51,8 +51,6 @@ import 'rake_tasks/elasticsearch_tasks.rake' import 'rake_tasks/test_tasks.rake' import 'rake_tasks/doc_generator.rake' import 'rake_tasks/docker_tasks.rake' -import 'rake_tasks/update_version.rake' -import 'profile/benchmarking/benchmarking_tasks.rake' require 'pathname' CURRENT_PATH = Pathname(File.expand_path(__dir__)) @@ -70,7 +68,7 @@ RELEASE_TOGETHER = [ CERT_DIR = ENV['CERT_DIR'] || '.ci/certs' # Import build task after setting constants: -import 'rake_tasks/unified_release_tasks.rake' +import 'rake_tasks/automation.rake' # TODO: Figure out "bundle exec or not" # subprojects.each { |project| $LOAD_PATH.unshift CURRENT_PATH.join(project, "lib").to_s } @@ -131,3 +129,12 @@ task :release do puts '-' * 80 end end + +desc 'Server info' +task :info do + require 'elasticsearch' + + client = Elasticsearch::Client.new(url: ENV['TEST_ES_SERVER'], api_key: ENV['ES_API_KEY']) + info = client.info + puts "Connected to Elasticsearch cluster #{info['cluster_name']}" +end diff --git a/benchmarks/Dockerfile b/benchmarks/Dockerfile deleted file mode 100644 index fb148f89d2..0000000000 --- a/benchmarks/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# $ docker build --file benchmarks/Dockerfile --tag elastic/elasticsearch-ruby . - -ARG RUBY_VERSION=2.7 -FROM ruby:${RUBY_VERSION} - -ENV TERM xterm-256color -ENV GEM_HOME="/usr/local/bundle" -ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH - -VOLUME ["/data"] - -WORKDIR /elasticsearch-ruby - -# TODO(karmi): Copy dependencies first to make use of Docker layer caching -COPY . . - -RUN bundle install --retry=5 -RUN cd benchmarks && bundle install - -CMD ["/bin/bash"] diff --git a/benchmarks/Gemfile b/benchmarks/Gemfile deleted file mode 100644 index 45b087784b..0000000000 --- a/benchmarks/Gemfile +++ /dev/null @@ -1,32 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# frozen_string_literal: true - -source "https://rubygems.org" - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -gem 'elasticsearch', path: File.expand_path('../../elasticsearch', __FILE__), require: false -gem 'elasticsearch-api', path: File.expand_path('../../elasticsearch-api', __FILE__), require: false -gem 'elasticsearch-transport', path: File.expand_path('../../elasticsearch-transport', __FILE__), require: false - -gem 'ansi' -gem 'patron' -gem 'oj' - -gem 'pry', group: :development diff --git a/benchmarks/actions/001_ping.rb b/benchmarks/actions/001_ping.rb deleted file mode 100644 index d7ea49a855..0000000000 --- a/benchmarks/actions/001_ping.rb +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../lib/benchmarks' - -Benchmarks.register \ - action: 'ping', - category: 'core', - warmups: Benchmarks::DEFAULT_WARMUPS, - repetitions: 10_000, - measure: Proc.new { |n, runner| - runner.runner_client.ping - } diff --git a/benchmarks/actions/002_info.rb b/benchmarks/actions/002_info.rb deleted file mode 100644 index 1b095ab02e..0000000000 --- a/benchmarks/actions/002_info.rb +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../lib/benchmarks' - -Benchmarks.register \ - action: 'info', - category: 'core', - warmups: Benchmarks::DEFAULT_WARMUPS, - repetitions: 10_000, - measure: Proc.new { |n, runner| - runner.runner_client.info - } diff --git a/benchmarks/actions/003_get.rb b/benchmarks/actions/003_get.rb deleted file mode 100644 index dd612e77ed..0000000000 --- a/benchmarks/actions/003_get.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../lib/benchmarks' - -Benchmarks.register \ - action: 'get', - category: 'core', - warmups: 100, - repetitions: 10_000, - setup: Proc.new { |runner| - runner.runner_client.indices.delete(index: 'test-bench-get', ignore: 404) - runner.runner_client.index index: 'test-bench-get', id: '1', body: { title: 'Test' } - runner.runner_client.cluster.health(wait_for_status: 'yellow') - runner.runner_client.indices.refresh index: 'test-bench-get' - }, - measure: Proc.new { |n, runner| - response = runner.runner_client.get index: 'test-bench-get', id: '1' - raise RuntimeError.new("Incorrect data: #{response}") unless response["_source"]["title"] == "Test" - } diff --git a/benchmarks/actions/004_index.rb b/benchmarks/actions/004_index.rb deleted file mode 100644 index 5428228787..0000000000 --- a/benchmarks/actions/004_index.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../lib/benchmarks' - -Benchmarks.register \ - action: 'index', - category: 'core', - warmups: 100, - repetitions: 10_000, - setup: Proc.new { |runner| - runner.runner_client.indices.delete(index: 'test-bench-index', ignore: 404) - runner.runner_client.indices.create(index: 'test-bench-index') - runner.runner_client.cluster.health(wait_for_status: 'yellow') - }, - measure: Proc.new { |n, runner| - doc_path = Benchmarks.data_path.join('small/document.json') - raise RuntimeError.new("Document at #{doc_path} not found") unless doc_path.exist? - response = runner.runner_client.index index: 'test-bench-index', id: "%04d-%04d" % [n, rand(1..1000)], body: doc_path.open.read - raise RuntimeError.new("Incorrect response: #{response}") unless response["result"] == "created" - } diff --git a/benchmarks/actions/005_bulk.rb b/benchmarks/actions/005_bulk.rb deleted file mode 100644 index 03213e7a1a..0000000000 --- a/benchmarks/actions/005_bulk.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../lib/benchmarks' - -Benchmarks.register \ - action: 'bulk', - category: 'core', - warmups: 10, - repetitions: 1_000, - operations: 10_000, - setup: Proc.new { |runner| - runner.runner_client.indices.delete(index: 'test-bench-bulk', ignore: 404) - runner.runner_client.indices.create(index: 'test-bench-bulk', body: '{"settings": { "number_of_shards": 3, "refresh_interval":"5s"}}') - runner.runner_client.cluster.health(wait_for_status: 'yellow') - }, - measure: Proc.new { |n, runner| - doc_path = Benchmarks.data_path.join('small/document.json') - raise RuntimeError.new("Document at #{doc_path} not found") unless doc_path.exist? - doc_body = doc_path.open.read.tr("\n", "").gsub(/\s{2,}/, "") + "\n" - - op_meta = %Q|{"index":{}}\n|.freeze - op_body = '' - - 1.upto(runner.operations).each do |i| - op_body << op_meta - op_body << doc_body - end - - response = runner.runner_client.bulk index: 'test-bench-bulk', body: op_body - raise RuntimeError.new("Incorrect response: #{response}") if response["errors"] - } diff --git a/benchmarks/bin/run.rb b/benchmarks/bin/run.rb deleted file mode 100755 index 52866fb139..0000000000 --- a/benchmarks/bin/run.rb +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env ruby -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'ansi/core' -require 'logger' -require 'patron' -require 'pathname' -require 'oj' - -require_relative '../lib/benchmarks' - -puts "Running benchmarks for elasticsearch-ruby@#{Elasticsearch::VERSION}".ansi(:bold,:underline) - -config = { - "ELASTICSEARCH_TARGET_URL" => "", - "ELASTICSEARCH_REPORT_URL" => "", - "DATA_SOURCE" => "", - "BUILD_ID" => "", - "TARGET_SERVICE_TYPE" => "", - "TARGET_SERVICE_NAME" => "", - "TARGET_SERVICE_VERSION" => "", - "TARGET_SERVICE_OS_FAMILY" => "", - "CLIENT_BRANCH" => "", - "CLIENT_COMMIT" => "", - "CLIENT_BENCHMARK_ENVIRONMENT" => "" -} - -missing_keys = [] - -config.keys.each do |key| - if ENV[key] && !ENV[key].to_s.empty? - config[key] = ENV[key] - else - missing_keys << key - end -end - -unless missing_keys.empty? -puts "ERROR: Required environment variables [#{missing_keys.join(',')}] missing".ansi(:bold, :red) - exit(1) -end - -start = Time.now.utc - -runner_client = Elasticsearch::Client.new(url: config["ELASTICSEARCH_TARGET_URL"]) -report_client = Elasticsearch::Client.new( - url: config["ELASTICSEARCH_REPORT_URL"], - request_timeout: 5*60, - retry_on_failure: 10 -) -if ENV['DEBUG'] - logger = Logger.new(STDOUT) - logger.level = Logger::INFO - logger.formatter = proc { |s, d, p, m| "#{m}\n".ansi(:faint) } - - runner_client.transport.logger = logger - report_client.transport.logger = logger -end - -runner = Benchmarks::Runner::Runner.new \ - build_id: config['BUILD_ID'], - environment: config['CLIENT_BENCHMARK_ENVIRONMENT'], - category: ENV['CLIENT_BENCHMARK_CATEGORY'].to_s, - runner_client: runner_client, - report_client: report_client, - target: { - service: { - type: config['TARGET_SERVICE_TYPE'], - name: config['TARGET_SERVICE_NAME'], - version: config['TARGET_SERVICE_VERSION'], - git: { - branch: ENV['TARGET_SERVICE_GIT_BRANCH'], - commit: ENV['TARGET_SERVICE_GIT_COMMIT'] - } - }, - os: { - family: config['TARGET_SERVICE_OS_FAMILY'] - } - }, - runner: { - service: { - git: { - branch: config['CLIENT_BRANCH'], - commit: config['CLIENT_COMMIT'] - } - } - } - -# ----- Run benchmarks -------------------------------------------------------- - -Benchmarks.data_path = Pathname(config["DATA_SOURCE"]) -unless Benchmarks.data_path.exist? - puts "ERROR: Data source at [#{Benchmarks.data_path}] not found".ansi(:bold, :red) - exit(1) -end - -Dir[File.expand_path("../../actions/*.rb", __FILE__)].each { |file| require file } - -Benchmarks.actions.each do |b| - next unless ENV['FILTER'].nil? or ENV['FILTER'].include? b.action - - runner.setup(&b.setup) if b.setup - - result = runner.measure( - action: b.action, - category: b.category, - warmups: b.warmups, - repetitions: b.repetitions, - operations: b.operations, - &b.measure).run! - - puts " " + - "[#{b.action}] ".ljust(16) + - "#{b.repetitions}x ".ljust(10) + - "mean=".ansi(:faint) + - "#{coll = runner.stats.map(&:duration); ((coll.sum / coll.size.to_f)/1e+6).round}ms " + - "runner=".ansi(:faint)+ - "#{runner.stats.any? { |s| s.outcome == 'failure' } ? 'failure' : 'success' } ".ansi( runner.stats.none? { |s| s.outcome == 'failure' } ? :green : :red ) + - "report=".ansi(:faint)+ - "#{result ? 'success' : 'failure' }".ansi( result ? :green : :red ) -end - -# ----------------------------------------------------------------------------- - -puts "Finished in #{(Time.mktime(0)+(Time.now.utc-start)).strftime("%H:%M:%S")}".ansi(:underline) diff --git a/benchmarks/lib/benchmarks.rb b/benchmarks/lib/benchmarks.rb deleted file mode 100644 index 09a621e471..0000000000 --- a/benchmarks/lib/benchmarks.rb +++ /dev/null @@ -1,339 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 "ostruct" -require "time" -require "rbconfig" - -require "ansi/core" -require "elasticsearch" - -## -# Module Benchmarks contains components for end-to-end benchmarking of the Ruby client for Elasticsearch. -# -module Benchmarks - DEFAULT_WARMUPS = 0 - DEFAULT_REPETITIONS = 1_000 - DEFAULT_OPERATIONS = 1 - - ## - # Represents the benchmarking action. - # - class Action - attr_reader :action, :category, :warmups, :repetitions, :operations, :setup, :measure - - # @param action [String] The name of the measured action - # @param category [String] The category of the measured action - # @param warmups [Number] The number of warmup runs - # @param repetitions [Number] The number of repetitions - # @param operations [Number] The number of operations in a single repetition - # @param setup [Block] The operation setup - # @param measure [Block] The measured operation - def initialize(action:, category:, warmups:, repetitions:, operations:, setup:, measure:) - raise ArgumentError.new("Required parameter [action] empty") if action.empty? - raise ArgumentError.new("Required parameter [category] empty") if category.empty? - - @action = action - @category = category - @warmups = warmups || DEFAULT_WARMUPS - @repetitions = repetitions || DEFAULT_REPETITIONS - @operations = operations || DEFAULT_OPERATIONS - @setup = setup - @measure = measure - end - end - - ## - # Registers an action for benchmarking. - # - # @option arguments [String] :action The name of the measured action - # @option arguments [String] :category The category of the measured action - # @option arguments [Number] :warmups The number of warmup runs - # @option arguments [Number] :repetitions The number of repetitions - # @option arguments [Number] :operations The number of operations in a single repetition - # @option arguments [Block] :setup The operation setup - # @option arguments [Block] :measure The measured operation - # - def self.register(arguments = {}) - self.actions << Action.new( - action: arguments[:action], - category: arguments[:category], - warmups: arguments[:warmups], - repetitions: arguments[:repetitions], - operations: arguments[:operations], - setup: arguments[:setup], - measure: arguments[:measure] - ) - end - - ## - # Set data path for benchmarks. - # - # @param path [Pathname,String] - # - def self.data_path=(path) - @data_path = Pathname(path) - end - - ## - # Return data path for benchmarks. - # - # @return [Pathname] - # - def self.data_path - @data_path - end - - ## - # Returns the registered actions. - # - # @return [Array] - # - def self.actions - @actions ||= [] - end - - ## - # Module Runner contains components for running the benchmarks. - # - module Runner - ## - # Stats represents the measured statistics. - # - class Stats < OpenStruct; end - - ## - # Errors contain error class for runner operations. - # - module Errors - ## - # ReportError represents an exception ocurring during reporting the results. - # - class ReportError < StandardError; end - - ## - # SetupError represents an exception occuring during operation setup. - # - class SetupError < StandardError; end - - ## - # WarmupError represents an exception occuring during operation warmup. - # - class WarmupError < StandardError; end - end - - ## - # The bulk size for reporting results. - # - BULK_BATCH_SIZE = 1000 - - ## - # The index name for reporting results. - # - INDEX_NAME="metrics-intake-#{Time.now.strftime("%Y-%m")}" - - ## - # Runner represents a benchmarking runner. - # - # It is initialized with two Elasticsearch clients, one for running the benchmarks, - # another one for reporting the results. - # - # Use the {#measure} method for adding a block which is executed and measured. - # - class Runner - attr_reader :stats, :runner_client, :report_client, :warmups, :repetitions, :operations - - ## - # @param runner_client [Elasticsearch::Client] The client for executing the measured operations. - # @param report_client [Elasticsearch::Client] The client for storing the results. - # - def initialize(build_id:, category:, environment:, runner_client:, report_client:, target:, runner:) - raise ArgumentError.new("Required parameter [build_id] empty") if build_id.empty? - raise ArgumentError.new("Required parameter [environment] empty") if environment.empty? - - @action = '' - @stats = [] - @warmups = 0 - @repetitions = 0 - @operations = 0 - - @build_id = build_id - @category = category - @environment = environment - @runner_client = runner_client - @report_client = report_client - @target_config = target - @runner_config = runner - end - - ## - # Executes the measured block, capturing statistics, and reports the results. - # - # @return [Boolean] - # @raise [Errors::ReportError] - # - def run! - @stats = [] - - # Run setup code - begin - @setup.arity < 1 ? self.instance_eval(&@setup) : @setup.call(self) if @setup - rescue StandardError => e - raise Errors::SetupError.new(e.inspect) - end - - # Run warmups - begin - @warmups.times do |n| - @measure.arity < 1 ? self.instance_eval(&@measure) : @measure.call(n, self) if @measure - end - rescue StandardError => e - raise Errors::WarmupError.new(e.inspect) - end - - # Run measured repetitions - # - # Cf. https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/ - @repetitions.times do |n| - stat = Stats.new(start: Time.now.utc) - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) - begin - result = @measure.arity < 1 ? result = self.instance_eval(&@measure) : result = @measure.call(n, self) if @measure - if result == false - stat.outcome = "failure" - else - stat.outcome = "success" - end - rescue StandardError => e - stat.outcome = "failure" - ensure - stat.duration = ((Process.clock_gettime(Process::CLOCK_MONOTONIC)-start) * 1e+9 ).to_i - @stats << stat - end - end - - # Report results - begin - __report - rescue StandardError => e - puts "ERROR: #{e.inspect}" - return false - end - - return true - end - - ## - # Configure a setup for the measure operation. - # - # @return [self] - # - def setup &block - @setup = block - return self - end - - ## - # Configure the measure operation. - # - # @param action [String] A human-readable name of the operation. - # @param category [String] The operation category. - # @param warmups [Number] The number of warmups. - # @param repetitions [Number] The number of repetitions. - # @param operations [Number] The number of operations in a single repetition. - # - # @return [self] - # - def measure(action:, category:, warmups:, repetitions:, operations:, &block) - raise ArgumentError.new("Required parameter [action] empty") if action.empty? - raise ArgumentError.new("Required parameter [category] empty") if category.empty? - raise ArgumentError.new("Required parameter [repetitions] not a number") unless repetitions.is_a? Numeric - raise ArgumentError.new("Required parameter [operations] not a number") unless operations.is_a? Numeric - - @action = action - @category = category - @warmups = warmups - @repetitions = repetitions - @operations = operations - @measure = block - return self - end - - ## - # Stores the result in the reporting cluster. - # - # @api private - # - def __report - @stats.each_slice(BULK_BATCH_SIZE) do |slice| - payload = slice.map do |s| - { index: { - data: { - :'@timestamp' => s.start.iso8601, - labels: { - build_id: @build_id, - client: 'elasticsearch-ruby', - environment: @environment.to_s - }, - tags: ['bench', 'elasticsearch-ruby'], - event: { - action: @action, - duration: s.duration, - outcome: s.outcome - }, - benchmark: { - build_id: @build_id, - environment: @environment.to_s, - category: @category.to_s, - repetitions: @repetitions, - operations: @operations, - runner: { - service: @runner_config[:service].merge({ - type: 'client', - name: 'elasticsearch-ruby', - version: Elasticsearch::VERSION - }), - runtime: { - name: 'ruby', version: RbConfig::CONFIG['ruby_version'] - }, - os: { - family: RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase - } - }, - target: @target_config - } - } - } - } - end - - begin - - rescue Elasticsearch::Transport::Transport::Error => e - puts "ERROR: #{e.inspect}" - raise e - end - - response = @report_client.bulk index: INDEX_NAME, body: payload - if response['errors'] || response['items'].any? { |i| i.values.first['status'] > 201 } - raise Errors::ReportError.new("Error saving benchmark results to report cluster") - end - end - end - end - end -end diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 0000000000..25413dfabf --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,19 @@ +apiVersion: backstage.io/v1alpha1 +kind: Resource +metadata: + name: buildkite-pipeline-elasticsearch-ruby +spec: + implementation: + apiVersion: buildkite.elastic.dev/v1 + kind: Pipeline + metadata: + description: Elasticsearch Ruby Client + name: elasticsearch-ruby + spec: + repository: elastic/elasticsearch-ruby + teams: + devtools-team: {} + everyone: + access_level: READ_ONLY + owner: group:devtools-team + type: buildkite-pipeline diff --git a/docs/advanced-config.asciidoc b/docs/advanced-config.asciidoc deleted file mode 100644 index cb0a54e77c..0000000000 --- a/docs/advanced-config.asciidoc +++ /dev/null @@ -1,359 +0,0 @@ -[[advanced-config]] -=== Advanced configuration - -The client supports many configurations options for setting up and managing -connections, configuring logging, customizing the transport library, and so on. - -[discrete] -[[setting-hosts]] -==== Setting hosts - -To connect to a specific {es} host: - -```ruby -Elasticsearch::Client.new(host: 'search.myserver.com') -``` - -To connect to a host with specific port: - -```ruby -Elasticsearch::Client.new(host: 'myhost:8080') -``` - -To connect to multiple hosts: - -```ruby -Elasticsearch::Client.new(hosts: ['myhost1', 'myhost2']) -``` - -Instead of strings, you can pass host information as an array of Hashes: - -```ruby -Elasticsearch::Client.new(hosts: [ { host: 'myhost1', port: 8080 }, { host: 'myhost2', port: 8080 } ]) -``` - -NOTE: When specifying multiple hosts, you might want to enable the -`retry_on_failure` or `retry_on_status` options to perform a failed request on -another node (refer to <>). - -Common URL parts – scheme, HTTP authentication credentials, URL prefixes, and so -on – are handled automatically: - -```ruby -Elasticsearch::Client.new(url: 'https://username:password@api.server.org:4430/search') -``` - -You can pass multiple URLs separated by a comma: - -```ruby -Elasticsearch::Client.new(urls: 'http://localhost:9200,http://localhost:9201') -``` - -Another way to configure URLs is to export the `ELASTICSEARCH_URL` variable. - -The client is automatically going to use a round-robin algorithm across the -hosts (unless you select or implement a different <>). - - -[discrete] -[[default-port]] -==== Default port - -The default port is `9200`. Specify a port for your host(s) if they differ from -this default. - -If you are using Elastic Cloud, the default port is port `9243`. You must supply -your username and password separately, and optionally a port. Refer to -<>. - - -[discrete] -[[logging]] -==== Logging - -To log requests and responses to standard output with the default logger (an -instance of Ruby's `::Logger` class), set the log argument to true: - -```ruby -Elasticsearch::Client.new(log: true) -``` - -You can also use https://github.com/elastic/ecs-logging-ruby[`ecs-logging`] -which is a set of libraries that enables you to transform your application logs -to structured logs that comply with the -https://www.elastic.co/guide/en/ecs/current/ecs-reference.html[Elastic Common Schema]. See <>. - -To trace requests and responses in the Curl format, set the `trace` argument: - -```ruby -Elasticsearch::Client.new(trace: true) -``` - -You can customize the default logger or tracer: - -[source,ruby] ------------------------------------- -client.transport.logger.formatter = proc { |s, d, p, m| "#{s}: #{m}\n" } -client.transport.logger.level = Logger::INFO ------------------------------------- - -Or, you can use a custom `::Logger` instance: - -```ruby -Elasticsearch::Client.new(logger: Logger.new(STDERR)) -``` - -You can pass the client any conforming logger implementation: - -[source,ruby] ------------------------------------- -require 'logging' # https://github.com/TwP/logging/ - -log = Logging.logger['elasticsearch'] -log.add_appenders Logging.appenders.stdout -log.level = :info - -client = Elasticsearch::Client.new(logger: log) ------------------------------------- - - -[discrete] -[[apm-integration]] -==== APM integration - -This client integrates seamlessly with Elastic APM via the Elastic APM Agent. It -automatically captures client requests if you are using the agent on your code. -If you're using `elastic-apm` v3.8.0 or up, you can set -`capture_elasticsearch_queries` to `true` in `config/elastic_apm.yml` to also -capture the body from requests in {es}. Refer to -https://github.com/elastic/elasticsearch-ruby/tree/main/docs/examples/apm[this example]. - - -[discrete] -[[custom-http-headers]] -==== Custom HTTP Headers - -You can set a custom HTTP header on the client's initializer: - -[source,ruby] ------------------------------------- -client = Elasticsearch::Client.new( - transport_options: { - headers: - {user_agent: "My App"} - } -) ------------------------------------- - -You can also pass in `headers` as a parameter to any of the API Endpoints to set -custom headers for the request: - -```ruby -client.search(index: 'myindex', q: 'title:test', headers: {user_agent: "My App"}) -``` - - -[discrete] -[[x-opaque-id]] -==== Identifying running tasks with X-Opaque-Id - -The X-Opaque-Id header allows to track certain calls, or associate certain tasks -with the client that started them (refer to -https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html#_identifying_running_tasks[the documentation]). -To use this feature, you need to set an id for `opaque_id` on the client on each -request. Example: - -[source,ruby] ------------------------------------- -client = Elasticsearch::Client.new -client.search(index: 'myindex', q: 'title:test', opaque_id: '123456') ------------------------------------- - -The search request includes the following HTTP Header: - -```ruby -X-Opaque-Id: 123456 -``` - -You can also set a prefix for X-Opaque-Id when initializing the client. This is -prepended to the id you set before each request if you're using X-Opaque-Id. -Example: - -[source,ruby] ------------------------------------- -client = Elasticsearch::Client.new(opaque_id_prefix: 'eu-west1_') -client.search(index: 'myindex', q: 'title:test', opaque_id: '123456') ------------------------------------- - -The request includes the following HTTP Header: - -```ruby -X-Opaque-Id: eu-west1_123456 -``` - - -[discrete] -[[setting-timeouts]] -==== Setting Timeouts - -For many operations in {es}, the default timeouts of HTTP libraries are too low. -To increase the timeout, you can use the `request_timeout` parameter: - -```ruby -Elasticsearch::Client.new(request_timeout: 5*60) -``` - -You can also use the `transport_options` argument documented below. - - -[discrete] -[[randomizing-hosts]] -==== Randomizing Hosts - -If you pass multiple hosts to the client, it rotates across them in a -round-robin fashion by default. When the same client would be running in -multiple processes (for example, in a Ruby web server such as Thin), it might -keep connecting to the same nodes "at once". To prevent this, you can randomize -the hosts collection on initialization and reloading: - -```ruby -Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], randomize_hosts: true) -``` - - -[discrete] -[[retry-failures]] -==== Retrying on Failures - -When the client is initialized with multiple hosts, it makes sense to retry a -failed request on a different host: - -```ruby -Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: true) -``` - -By default, the client retries the request 3 times. You can specify how many -times to retry before it raises an exception by passing a number to -`retry_on_failure`: - -```ruby - Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: 5) -``` - -You can also use `retry_on_status` to retry when specific status codes are -returned: - -```ruby -Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_status: [502, 503]) -``` - -These two parameters can also be used together: - -```ruby -Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_status: [502, 503], retry_on_failure: 10) -``` - -You can also set a `delay_on_retry` value in milliseconds. This will add a delay to wait between retries: - -```ruby - Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: 5, delay_on_retry: 1000) -``` - -[discrete] -[[reload-hosts]] -==== Reloading Hosts - -{es} dynamically discovers new nodes in the cluster by default. You can leverage -this in the client, and periodically check for new nodes to spread the load. - -To retrieve and use the information from the -https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html[Nodes Info API] -on every 10,000th request: - -```ruby -Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], reload_connections: true) -``` - -You can pass a specific number of requests after which reloading should be -performed: - -```ruby -Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], reload_connections: 1_000) -``` - -To reload connections on failures, use: - -```ruby -Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], reload_on_failure: true) -``` - -The reloading timeouts if not finished under 1 second by default. To change the -setting: - -```ruby -Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], sniffer_timeout: 3) -``` - -NOTE: When using reloading hosts ("sniffing") together with authentication, pass -the scheme, user and password with the host info – or, for more clarity, in the -`http` options: - -[source,ruby] ------------------------------------- -Elasticsearch::Client.new( - host: 'localhost:9200', - http: { scheme: 'https', user: 'U', password: 'P' }, - reload_connections: true, - reload_on_failure: true -) ------------------------------------- - - -[discrete] -[[connection-selector]] -==== Connection Selector - -By default, the client rotates the connections in a round-robin fashion, using the `Elastic::Transport::Transport::Connections::Selector::RoundRobin` strategy. - -You can implement your own strategy to customize the behaviour. For example, let's have a "rack aware" strategy, which prefers the nodes with a specific attribute. The strategy uses the other nodes, only when these are unavailable: - -[source,ruby] ------------------------------------- -class RackIdSelector - include Elastic::Transport::Transport::Connections::Selector::Base - - def select(options={}) - connections.select do |c| - # Try selecting the nodes with a `rack_id:x1` attribute first - c.host[:attributes] && c.host[:attributes][:rack_id] == 'x1' - end.sample || connections.to_a.sample - end -end - -Elasticsearch::Client.new hosts: ['x1.search.org', 'x2.search.org'], selector_class: RackIdSelector ------------------------------------- - - -[discrete] -[[serializer-implementations]] -==== Serializer Implementations - -By default, the https://rubygems.org/gems/multi_json[MultiJSON] library is used as the serializer implementation, and it picks up the "right" adapter based on gems available. - -The serialization component is pluggable, though, so you can write your own by including the `Elastic::Transport::Transport::Serializer::Base` module, implementing the required contract, and passing it to the client as the `serializer_class` or `serializer` parameter. - - -[discrete] -[[exception-handling]] -==== Exception Handling - -The library defines a -https://github.com/elastic/elastic-transport-ruby/blob/main/lib/elastic/transport/transport/errors.rb[number of exception classes] for various client and server errors, as well as unsuccessful HTTP responses, making it possible to rescue specific exceptions with desired granularity. - -The highest-level exception is `Elastic::Transport::Transport::Error` and is raised for any generic client or server errors. - -`Elastic::Transport::Transport::ServerError` is raised for server errors only. - -As an example for response-specific errors, a 404 response status raises an `Elastic::Transport::Transport::Errors::NotFound` exception. - -Finally, `Elastic::Transport::Transport::SnifferTimeoutError` is raised when connection reloading ("sniffing") times out. diff --git a/docs/api.asciidoc b/docs/api.asciidoc deleted file mode 100644 index 85386c8122..0000000000 --- a/docs/api.asciidoc +++ /dev/null @@ -1,220 +0,0 @@ -[[api]] -=== Elasticsearch API - -The `elasticsearch-api` library provides a Ruby implementation of the https://www.elastic.co/elastic-stack/[Elasticsearch] REST API. - -[discrete] -[[api-install]] -==== Installation - -Install the package from https://rubygems.org[Rubygems]: - -[source,bash] ----------------------------- -gem install elasticsearch-api ----------------------------- - -To use an unreleased version, either add it to your `Gemfile` for https://bundler.io/[Bundler]: - -[source,bash] ----------------------------- -gem 'elasticsearch-api', git: 'git://github.com/elasticsearch/elasticsearch-ruby.git' ----------------------------- - -or install it from a source code checkout: - -[source,bash] ----------------------------- -git clone https://github.com/elasticsearch/elasticsearch-ruby.git -cd elasticsearch-ruby/elasticsearch-api -bundle install -rake install ----------------------------- - -[discrete] -[[api-example-usage]] -==== Example usage - -The library is designed as a group of standalone Ruby modules, which can be mixed into a class -providing connection to Elasticsearch -- an Elasticsearch client. - -[discrete] -===== Usage with the `elasticsearch` gem - -**When you use the client from the https://github.com/elasticsearch/elasticsearch-ruby[`elasticsearch-ruby`] client, the library modules have been already included**, so you just call the API methods. - -The response will be an `Elasticsearch::API::Response` object which wraps an `Elasticsearch::Transport::Transport::Response` object. It provides `body`, `status` and `headers` methods, but you can treat is as a hash and access the keys directly. - -[source,rb] ----------------------------- -require 'elasticsearch' - -client = Elasticsearch::Client.new - ->response = client.index(index: 'myindex', id: 1, body: { title: 'Test' }) -=> #"myindex", - "_id"=>"1", - "_version"=>2, - "result"=>"updated", - "_shards"=>{"total"=>1, "successful"=>1, "failed"=>0}, - "_seq_no"=>1, - "_primary_term"=>1}, - @headers= - {"x-elastic-product"=>"Elasticsearch", - "content-type"=>"application/json", - "content-encoding"=>"gzip", - "content-length"=>"130"}, - @status=200>> - -> response['result'] -=> "updated" - -client.search(index: 'myindex', body: { query: { match: { title: 'test' } } }) -# => => #223, - "timed_out"=>false, - "_shards"=>{"total"=>2, "successful"=>2, "skipped"=>0, "failed"=>0}, - "hits"=> - {"total"=>{"value"=>1, "relation"=>"eq"}, - "max_score"=>0.2876821, - "hits"=>[{"_index"=>"myindex", "_id"=>"1", "_score"=>0.2876821, "_source"=>{"title"=>"Test"}}]}}, - @headers= - {"x-elastic-product"=>"Elasticsearch", - "content-type"=>"application/json", - "content-encoding"=>"gzip", - "content-length"=>"188"}, - @status=200>> ----------------------------- - -Full documentation and examples are included as RDoc annotations in the source code and available online at . - -[discrete] -===== Usage with a custom client - -When you want to mix the library with your own client, it must conform to the following _contract_: - -* It responds to a `perform_request(method, path, params, body, headers)` method, -* the method returns an object with `status`, `body` and `headers` methods. - -A simple client could look like this (_with a dependency on `active_support` to parse the query params_): - -[source,rb] ----------------------------- -require 'multi_json' -require 'faraday' -require 'elasticsearch/api' - -class MySimpleClient - include Elasticsearch::API - - CONNECTION = ::Faraday::Connection.new(url: 'http://localhost:9200') - - def perform_request(method, path, params, body, headers = nil) - puts "--> #{method.upcase} #{path} #{params} #{body} #{headers}" - - CONNECTION.run_request \ - method.downcase.to_sym, - path_with_params(path, params), - ( body ? MultiJson.dump(body): nil ), - {'Content-Type' => 'application/json'} - end - - private - - def path_with_params(path, params) - return path if params.blank? - - case params - when String - "#{path}?#{params}" - when Hash - "#{path}?#{URI.encode_www_form(params)}" - else - raise ArgumentError, "Cannot parse params: '#{params}'" - end - end -end - -client = MySimpleClient.new - -p client.cluster.health -# --> GET _cluster/health {} -# => "{"cluster_name":"elasticsearch" ... }" - -p client.index(index: 'myindex', id: 'custom', body: { title: "Indexing from my client" }) -# --> PUT myindex/mytype/custom {} {:title=>"Indexing from my client"} -# => "{"ok":true, ... }" ----------------------------- - -[discrete] -===== Using JSON Builders - -Instead of passing the `:body` argument as a Ruby _Hash_, you can pass it as a _String_, potentially -taking advantage of JSON builders such as https://github.com/rails/jbuilder[JBuilder] or -https://github.com/bsiggelkow/jsonify[Jsonify]: - -[source,rb] ----------------------------- -require 'jbuilder' - -query = Jbuilder.encode do |json| - json.query do - json.match do - json.title do - json.query 'test 1' - json.operator 'and' - end - end - end -end - -client.search(index: 'myindex', body: query) - -# 2013-06-25 09:56:05 +0200: GET http://localhost:9200/myindex/_search [status:200, request:0.015s, query:0.011s] -# 2013-06-25 09:56:05 +0200: > {"query":{"match":{"title":{"query":"test 1","operator":"and"}}}} -# ... -# => {"took"=>21, ..., "hits"=>{"total"=>1, "hits"=>[{ "_source"=>{"title"=>"Test 1", ...}}]}} ----------------------------- - -[discrete] -===== Using Hash Wrappers - -For a more comfortable access to response properties, you may wrap it in one of the _Hash_ "object access" -wrappers, such as https://github.com/intridea/hashie[`Hashie::Mash`]: - -[source,rb] ----------------------------- -require 'hashie' - -response = client.search( - index: 'myindex', - body: { - query: { match: { title: 'test' } }, - aggregations: { tags: { terms: { field: 'tags' } } } - } -) - -mash = Hashie::Mash.new(response) - -mash.hits.hits.first._source.title -# => 'Test' ----------------------------- - -[discrete] -===== Using a Custom JSON Serializer - -The library uses the https://rubygems.org/gems/multi_json/[MultiJson] gem by default but allows you to set a custom JSON library, provided it uses the standard `load/dump` interface: - -[source,rb] ----------------------------- -Elasticsearch::API.settings[:serializer] = JrJackson::Json -Elasticsearch::API.serializer.dump({foo: 'bar'}) -# => {"foo":"bar"} ----------------------------- diff --git a/docs/basic-config.asciidoc b/docs/basic-config.asciidoc deleted file mode 100644 index d23d517166..0000000000 --- a/docs/basic-config.asciidoc +++ /dev/null @@ -1,36 +0,0 @@ -[[basic-config]] -=== Basic configuration - -The table below contains the most important initialization parameters that you -can use. - - -[cols="<,<,<"] -|=== - -| **Parameter** | **Data type** | **Description** -| `adapter` | Symbol | A specific adapter for Faraday (for example, `:patron`). -| `api_key` | String, Hash | For API key Authentication. Either the base64 encoding of `id` and `api_key` joined by a colon as a string, or a hash with the `id` and `api_key` values. -| `compression` | Boolean | Whether to compress requests. Gzip compression is used. Defaults to `false`. Responses are automatically inflated if they are compressed. If a custom transport object is used, it must handle the request compression and response inflation. -| `enable_meta_header` | Boolean | Whether to enable sending the meta data header to Cloud. Defaults to `true`. -| `hosts` | String, Array | Single host passed as a string or hash, or multiple hosts passed as an array; `host` or `url` keys are also valid. -| `log` | Boolean | Whether to use the default logger. Disabled by default. -| `logger` | Object | An instance of a Logger-compatible object. -| `opaque_id_prefix` | String | Sets a prefix for X-Opaque-Id when initializing the client. This is prepended to the id you set before each request if you're using X-Opaque-Id. -| `randomize_hosts` | Boolean | Whether to shuffle connections on initialization and reload. Defaults to `false`. -| `reload_connections` | Boolean, Number | Whether to reload connections after X requests. Defaults to `false`. -| `reload_on_failure` | Boolean | Whether to reload connections after failure. Defaults to `false`. -| `request_timeout` | Integer | The request timeout to be passed to transport in options. -| `resurrect_after` | Integer | Specifies after how many seconds a dead connection should be tried again. -| `retry_on_failure` | Boolean, Number | Whether to retry X times when request fails before raising and exception. Defaults to `false`. -| `retry_on_status` | Array, Number | Specifies which status code needs to be returned to retry. -| `selector` | Constant | An instance of selector strategy implemented with {Elastic::Transport::Transport::Connections::Selector::Base}. -| `send_get_body_as` | String | Specifies the HTTP method to use for GET requests with a body. Defaults to `GET`. -| `serializer_class` | Constant | Specifies a serializer class to use. It is initialized by the transport and passed the transport instance. -| `sniffer_timeout` | Integer | Specifieds the timeout for reloading connections in seconds. Defaults to `1`. -| `trace` | Boolean | Whether to use the default tracer. Disabled by default. -| `tracer` | Object | Specifies an instance of a Logger-compatible object. -| `transport` | Object | Specifies a transport instance. -| `transport_class` | Constant | Specifies a transport class to use. It is initialized by the client and passed hosts and all arguments. -| `transport_options` | Hash | Specifies the options to be passed to the `Faraday::Connection` constructor. -|=== diff --git a/docs/config.asciidoc b/docs/config.asciidoc deleted file mode 100644 index c9897f8313..0000000000 --- a/docs/config.asciidoc +++ /dev/null @@ -1,9 +0,0 @@ -[[ruby-config]] -== Configuration - -This page contains information about how to configure the Ruby client tailored -to your needs. Almost every aspect of the client is configurable. However, in -most cases you only need to set a couple of parameters. - -* <> -* <> \ No newline at end of file diff --git a/docs/connecting.asciidoc b/docs/connecting.asciidoc deleted file mode 100644 index 3f988cfe67..0000000000 --- a/docs/connecting.asciidoc +++ /dev/null @@ -1,352 +0,0 @@ -[[connecting]] -== Connecting - -This page contains the information you need to connect and use the Client with -{es}. - -**On this page** - -* <> -* <> -* <> -* <> - -[discrete] -[[client-auth]] -=== Authentication - -This document contains code snippets to show you how to connect to various {es} providers. - -[discrete] -[[auth-ec]] -==== Elastic Cloud - -If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers an easy way to connect to it. You need the Cloud ID that you can find in the cloud console, then your username and password. - -image::docs/images/cloud_id.png["Cloud ID"] - -Once you have collected the Cloud ID you can use the client to connect to your Elastic Cloud instance, as follows: - -[source,ruby] ------------------------------------- -require 'elasticsearch' - -client = Elasticsearch::Client.new( - cloud_id: '' - user: '', - password: '', -) ------------------------------------- - -You can also connect to the Cloud by using API Key authentication. You can generate an `API key` in the `Management` page under the section `Security`. - -image::docs/images/cloud_api_key.png["API key"] - -When you click on `Create API key` you can choose a name and set the other options (eg. restrict privileges, expire after time, etc). - -image::docs/images/api_key_name.png["Choose an API name"] - -After this step you will get the `API key` in the API keys page. - -image::docs/images/cloud_api_key.png["API key"] - -**IMPORTANT**: you need to copy and store the `API key` in a secure place, since you will not be able to view it again in Elastic Cloud. - -Once you have collected the `Cloud ID` and the `API key` you can use the client -to connect to your Elastic Cloud instance, as follows: - -[source,ruby] ------------------------------------- -client = Elasticsearch::Client.new( - cloud_id: '', - api_key: '' -) ------------------------------------- - -If you create the API Key through the dev console or the REST API, you may get instead a pair of `id` and `APIKey` values. The client also accepts a Hash for the `api_key` parameter, so you can pass in these values and it will encode the API Key internally: - -[source,ruby] ------------------------------------- -client = Elasticsearch::Client.new( - cloud_id: '', - api_key: {id: '', api_key: ''} -) ------------------------------------- - -[discrete] -[[connect-self-managed]] -=== Connecting to a self-managed cluster - -{es} 8.0 offers security by default, that means authentication and TLS are enabled. - -To connect to the {es} cluster you’ll need to configure the Ruby {es} client to use HTTPS with the generated CA certificate in order to make requests successfully. - -If you’re just getting started with {es} we recommend reading the documentation on configuring and starting {es} to ensure your cluster is running as expected. - -When you start {es} for the first time you’ll see a distinct block like the one below in the output from {es} (you may have to scroll up if it’s been a while): - - -```sh ----------------------------------------------------------------- --> Elasticsearch security features have been automatically configured! --> Authentication is enabled and cluster connections are encrypted. - --> Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`): - lhQpLELkjkrawaBoaz0Q - --> HTTP CA certificate SHA-256 fingerprint: - a52dd93511e8c6045e21f16654b77c9ee0f34aea26d9f40320b531c474676228 -... ----------------------------------------------------------------- -``` - -Note down the `elastic` user password and HTTP CA fingerprint for the next sections. In the examples below they will be stored in the variables `ELASTIC_PASSWORD` and `CERT_FINGERPRINT` respectively. - -Depending on the circumstances there are two options for verifying the HTTPS connection, either verifying with the CA certificate itself or via the HTTP CA certificate fingerprint. - - -[discrete] -[[ca-certificates]] -==== Verifying HTTPS with CA certificates - -The generated root CA certificate can be found in the `certs` directory in your {es} config location (`$ES_CONF_PATH/certs/http_ca.crt`). If you're running {es} in Docker there is https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html[additional documentation for retrieving the CA certificate]. - -Once you have the `http_ca.crt` file somewhere accessible pass the path to the client via `ca_certs`: - -[source,ruby] ------------------------------------- -client = Elasticsearch::Client.new( - host: "https://elastic:#{ELASTIC_PASSWORD}@localhost:9200", - transport_options: { ssl: { ca_path: CERT_DIR } } -) ------------------------------------- - -[discrete] -[[ca-fingerprint]] -==== Verifying HTTPS with certificate fingerprints - - -This method of verifying the HTTPS connection takes advantage of the certificate fingerprint value noted down earlier. Take this SHA256 fingerprint value and pass it to the Ruby {es} client via `ca_fingerprint`: - -[source,ruby] ------------------------------------- -# Colons and uppercase/lowercase don't matter when using -# the 'ca_fingerprint' parameter -CERT_FINGERPRINT = '64F2593F...' - -# Password for the 'elastic' user generated by Elasticsearch -ELASTIC_PASSWORD = "" - -client = Elasticsearch::Client.new( - host: "https://elastic:#{ELASTIC_PASSWORD}@localhost:9200", - transport_options: { ssl: { verify: false } }, - ca_fingerprint: CERT_FINGERPRINT -) ------------------------------------- - -The verification will be run once per connection. - - -The certificate fingerprint can be calculated using `openssl x509` with the certificate file: - -[source,sh] ----- -openssl x509 -fingerprint -sha256 -noout -in /path/to/http_ca.crt ----- - -If you don't have access to the generated CA file from {es} you can use the following script to output the root CA fingerprint of the {es} instance with `openssl s_client`: - -[source,sh] ----- -# Replace the values of 'localhost' and '9200' to the -# corresponding host and port values for the cluster. -openssl s_client -connect localhost:9200 -servername localhost -showcerts /dev/null \ - | openssl x509 -fingerprint -sha256 -noout -in /dev/stdin ----- - -The output of `openssl x509` will look something like this: - -[source,sh] ----- -SHA256 Fingerprint=A5:2D:D9:35:11:E8:C6:04:5E:21:F1:66:54:B7:7C:9E:E0:F3:4A:EA:26:D9:F4:03:20:B5:31:C4:74:67:62:28 ----- - - - - -[discrete] -[[auth-api-key]] -==== API Key authentication - -You can also use https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html[ApiKey] authentication. - -NOTE: If you provide both basic authentication credentials and the ApiKey configuration, the ApiKey takes precedence. - -[source,ruby] ------------------------------------- -Elasticsearch::Client.new( - host: host, - transport_options: transport_options, - api_key: credentials -) ------------------------------------- - -Where credentials is either the base64 encoding of `id` and `api_key` joined by -a colon or a hash with the `id` and `api_key`: - -[source,ruby] ------------------------------------- -Elasticsearch::Client.new( - host: host, - transport_options: transport_options, - api_key: {id: 'my_id', api_key: 'my_api_key'} -) ------------------------------------- - - -[discrete] -[[auth-basic]] -==== Basic authentication - -You can pass the authentication credentials, scheme and port in the host -configuration hash: - -[source,ruby] ------------------------------------- -client = Elasticsearch::Client.new( - hosts: - [ - { - host: 'my-protected-host', - port: '443', - user: 'USERNAME', - password: 'PASSWORD', - scheme: 'https' - } - ] -) ------------------------------------- - -Or use the common URL format: - -[source,ruby] ------------------------------------- -client = Elasticsearch::Client.new(url: 'https://username:password@localhost:9200') ------------------------------------- - -To pass a custom certificate for SSL peer verification to Faraday-based clients, -use the `transport_options` option: - -[source,ruby] ------------------------------------- -Elasticsearch::Client.new( - url: 'https://username:password@localhost:9200', - transport_options: { - ssl: { ca_file: '/path/to/cacert.pem' } - } -) ------------------------------------- - -[discrete] -[[client-usage]] -=== Usage - -The following snippet shows an example of using the Ruby client: - -[source,ruby] ------------------------------------- -require 'elasticsearch' - -client = Elasticsearch::Client.new log: true - -client.cluster.health - -client.index(index: 'my-index', id: 1, body: { title: 'Test' }) - -client.indices.refresh(index: 'my-index') - -client.search(index: 'my-index', body: { query: { match: { title: 'test' } } }) ------------------------------------- - - -[discrete] -[[client-faas]] -=== Using the Client in a Function-as-a-Service Environment - -This section illustrates the best practices for leveraging the {es} client in a Function-as-a-Service (FaaS) environment. The most influential optimization is to initialize the client outside of the function, the global scope. This practice does not only improve performance but also enables background functionality as – for example – sniffing. The following examples provide a skeleton for the best practices. - -[discrete] -==== GCP Cloud Functions - -[source,ruby] ------------------------------------- -require 'functions_framework' -require 'elasticsearch' - -client = Elasticsearch::Client.new( - cloud_id: "elasic-cloud-id", - user: "elastic", - password: "password", - log: true -) - -FunctionsFramework.http "hello_world" do |request| - client.search( - index: 'stack-overflow', - body: { - query: { - match: { - title: { - query: 'phone application' - } - } - } - } - ) -end ------------------------------------- - -[discrete] -==== AWS Lambda - -[source,ruby] ------------------------------------- -require 'elasticsearch' - -def client - @client ||= Elasticsearch::Client.new( - cloud_id: "elastic-cloud-id", - user: "elastic", - password: "password", - log: true - ) -end - -def lambda_handler(event:, context:) - client.search( - index: 'stack-overflow', - body: { - query: { - match: { - title: { - query: 'phone application' - } - } - } - } - ) -end ------------------------------------- - -Resources used to assess these recommendations: - -* https://cloud.google.com/functions/docs/bestpractices/tips#use_global_variables_to_reuse_objects_in_future_invocations[GCP Cloud Functions: Tips & Tricks] -* https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html[Best practices for working with AWS Lambda functions] - -[discrete] -[[client-comp]] -=== Enabling the Compatibility Mode - -The Elasticsearch server version 8.0 is introducing a new compatibility mode that allows you a smoother upgrade experience from 7 to 8. In a nutshell, you can use the latest 7.x Elasticsearch client with an 8.x Elasticsearch server, giving more room to coordinate the upgrade of your codebase to the next major version. - -If you want to leverage this functionality, please make sure that you are using the latest 7.x client and set the environment variable `ELASTIC_CLIENT_APIVERSIONING` to `true`. The client is handling the rest internally. For every 8.0 and beyond client, you're all set! The compatibility mode is enabled by default. diff --git a/docs/docset.yml b/docs/docset.yml new file mode 100644 index 0000000000..d1f01be642 --- /dev/null +++ b/docs/docset.yml @@ -0,0 +1,12 @@ +project: 'Ruby client' +exclude: + - examples/** +cross_links: + - docs-content + - ecs + - ecs-logging-ruby +toc: + - toc: reference + - toc: release-notes +subs: + es: "Elasticsearch" diff --git a/docs/dsl.asciidoc b/docs/dsl.asciidoc deleted file mode 100644 index 922624a4fa..0000000000 --- a/docs/dsl.asciidoc +++ /dev/null @@ -1,6 +0,0 @@ -[[dsl]] -=== Elasticsearch DSL - -The https://github.com/elastic/elasticsearch-dsl-ruby[elasticsearch-dsl] gem provides a Ruby API for the https://www.elasticsearch.com/guide/en/elasticsearch/reference/current/query-dsl.html[Elasticsearch Query DSL]. The library allows to programmatically build complex search definitions for {es} in Ruby, which are translated to Hashes, and ultimately, JSON, the language of {es}. - -See https://github.com/elastic/elasticsearch-dsl-ruby#elasticsearchdsl[the README] for more information. diff --git a/docs/ecs.asciidoc b/docs/ecs.asciidoc deleted file mode 100644 index 218708038b..0000000000 --- a/docs/ecs.asciidoc +++ /dev/null @@ -1,34 +0,0 @@ -[[ecs]] -=== Elastic Common Schema (ECS) - -The https://www.elastic.co/guide/en/ecs/current/ecs-reference.html[Elastic Common Schema (ECS)] is an open source format that defines a common set of fields to be used when storing event data like logs in Elasticsearch. - -You can use the library https://github.com/elastic/ecs-logging-ruby[ecs-logging] which is a set of libraries that enables you to transform your application logs to structured logs that comply with the ECS format. - -Add this line to your application's Gemfile: - -[source,ruby] ------------------------------------- -gem 'ecs-logging' ------------------------------------- - -Then execute `bundle install`. Or install from the command line yourself: - -[source,ruby] ------------------------------------- -$ gem install ecs-logging ------------------------------------- - -Then configure the client to use the logger: -[source,ruby] ------------------------------------- -require 'ecs_logging/logger' -require 'elasticsearch' - -logger = EcsLogging::Logger.new($stdout) -client = Elasticsearch::Client.new(logger: logger) -> client.info -{"@timestamp":"2022-07-12T05:31:18.590Z","log.level":"INFO","message":"GET http://localhost:9200/ [status:200, request:0.009s, query:n/a]","ecs.version":"1.4.0"}... ------------------------------------- - -See https://www.elastic.co/guide/en/ecs-logging/ruby/current/index.html[ECS Logging Ruby Reference] for more information on how to configure the logger. diff --git a/docs/examples.asciidoc b/docs/examples.asciidoc deleted file mode 100644 index 49afcaf3a5..0000000000 --- a/docs/examples.asciidoc +++ /dev/null @@ -1,226 +0,0 @@ -[[examples]] -== Examples - -Below you can find examples of how to use the most frequently called APIs with -the Ruby client. - -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> - - -[discrete] -[[ex-index]] -=== Indexing a document - -Let's index a document with the following fields: `name`, `author`, -`release_date`, and `page_count`: - -```ruby -body = { - name: "The Hitchhiker's Guide to the Galaxy", - author: "Douglas Adams", - release_date: "1979-10-12", - page_count: 180 -} - -client.index(index: 'books', body: body) -``` - - -[discrete] -[[ex-get]] -=== Getting a document - -You can get a document by ID: - -```ruby -id = 'l7LRjXgB2_ry9btNEv_V' -client.get(index: 'books', id: id) -``` - - -[discrete] -[[ex-update]] -=== Updating a document - -Assume you have the following document: - -```ruby -book = {"name": "Foundation", "author": "Isaac Asimov", "release_date": "1951-06-01", "page_count": 224} -``` - -You can update the document by using the following script: - -```ruby -response = client.index(index: 'books', body: book) -id = response['_id'] -client.update(index: 'books', id: id, body: { doc: { page_count: 225 } }) -``` - - -[discrete] -[[ex-delete]] -=== Deleting a document - -You can delete a document by ID: - -```ruby -id = 'l7LRjXgB2_ry9btNEv_V' -client.delete(index: 'books', id: id) -``` - - -[discrete] -[[ex-bulk]] -=== Bulk requests - -The `bulk` operation of the client supports various different formats of the -payload: array of strings, header/data pairs, or the combined format where data -is passed along with the header in a single item in a custom `:data` key. - -Index several documents in one request: - -```ruby -body = [ - { index: { _index: 'books', _id: '42' } }, - { name: "The Hitchhiker's Guide to the Galaxy", author: 'Douglas Adams', release_date: '1979-10-12', page_count: 180}, - { index: { _index: 'books', _id: '43' } }, - { name: 'Snow Crash', author: 'Neal Stephenson', release_date: '1992-06-01', page_count: 470 }, - { index: { _index: 'books', _id: '44' } }, - { name: 'Starship Troopers', author: 'Robert A. Heinlein', release_date: '1959-12-01', page_count: 335} -] -client.bulk(body: body) -``` - -Delete several documents: - -```ruby -body = [ - { delete: { _index: 'books', _id: '42' } }, - { delete: { _index: 'books', _id: '43' } }, -] -client.bulk(body: body) -``` - -As mentioned, you can perform several operations in a single request with the -combined format passing data in the `:data` option: - -```ruby -body = [ - { index: { _index: 'books', _id: 45, data: { name: '1984', author: 'George Orwell', release_date: '1985-06-01', page_count: 328 } } }, - { update: { _index: 'books', _id: 43, data: { doc: { page_count: 471 } } } }, - { delete: { _index: 'books', _id: 44 } } -] -client.bulk(body: body) -``` - - -[discrete] -[[ex-search]] -=== Searching for a document - -This example uses the same data that is used in the -https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html#find-structure-example-nld-json[Find structure API documentation]. - -First, bulk index it: - -[source,ruby] ----- -body = [ - { index: { _index: 'books', data: {name: "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561} } }, - { index: { _index: 'books', data: {name: "Hyperion", "author": "Dan Simmons", "release_date": "1989-05-26", "page_count": 482} } }, - { index: { _index: 'books', data: {name: "Dune", "author": "Frank Herbert", "release_date": "1965-06-01", "page_count": 604} } }, - { index: { _index: 'books', data: {name: "Dune Messiah", "author": "Frank Herbert", "release_date": "1969-10-15", "page_count": 331} } }, - { index: { _index: 'books', data: {name: "Children of Dune", "author": "Frank Herbert", "release_date": "1976-04-21", "page_count": 408} } }, - { index: { _index: 'books', data: {name: "God Emperor of Dune", "author": "Frank Herbert", "release_date": "1981-05-28", "page_count": 454} } }, - { index: { _index: 'books', data: {name: "Consider Phlebas", "author": "Iain M. Banks", "release_date": "1987-04-23", "page_count": 471} } }, - { index: { _index: 'books', data: {name: "Pandora's Star", "author": "Peter F. Hamilton", "release_date": "2004-03-02", "page_count": 768} } }, - { index: { _index: 'books', data: {name: "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585} } }, - { index: { _index: 'books', data: {name: "A Fire Upon the Deep", "author": "Vernor Vinge", "release_date": "1992-06-01", "page_count": 613} } }, - { index: { _index: 'books', data: {name: "Ender's Game", "author": "Orson Scott Card", "release_date": "1985-06-01", "page_count": 324} } }, - { index: { _index: 'books', data: {name: "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328} } }, - { index: { _index: 'books', data: {name: "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227} } }, - { index: { _index: 'books', data: {name: "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268} } }, - { index: { _index: 'books', data: {name: "Foundation", "author": "Isaac Asimov", "release_date": "1951-06-01", "page_count": 224} } }, - { index: { _index: 'books', data: {name: "The Giver", "author": "Lois Lowry", "release_date": "1993-04-26", "page_count": 208} } }, - { index: { _index: 'books', data: {name: "Slaughterhouse-Five", "author": "Kurt Vonnegut", "release_date": "1969-06-01", "page_count": 275} } }, - { index: { _index: 'books', data: {name: "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "release_date": "1979-10-12", "page_count": 180} } }, - { index: { _index: 'books', data: {name: "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470} } }, - { index: { _index: 'books', data: {name: "Neuromancer", "author": "William Gibson", "release_date": "1984-07-01", "page_count": 271} } }, - { index: { _index: 'books', data: {name: "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311} } }, - { index: { _index: 'books', data: {name: "Starship Troopers", "author": "Robert A. Heinlein", "release_date": "1959-12-01", "page_count": 335} } }, - { index: { _index: 'books', data: {name: "The Left Hand of Darkness", "author": "Ursula K. Le Guin", "release_date": "1969-06-01", "page_count": 304} } }, - { index: { _index: 'books', data: {name: "The Moon is a Harsh Mistress", "author": "Robert A. Heinlein", "release_date": "1966-04-01", "page_count": 288 } } } -] -client.bulk(body: body) ----- - -The `field` parameter is a common parameter, so it can be passed in directly in -the following way: - -```ruby -client.search(index: 'books', q: 'dune') -``` - -You can do the same by using body request parameters: - -```ruby -client.search(index: 'books', q: 'dune', body: { fields: [{ field: 'name' }] }) -response = client.search(index: 'books', body: { size: 15 }) -response['hits']['hits'].count # => 15 -``` - - -[discrete] -[[ex-multisearch]] -=== Multi search -The following example shows how to perform a multisearch API call on `books` index: -```ruby -body = [ - {}, - {query: {range: {page_count: {gte: 100}}}}, - {}, - {query: {range: {page_count: {lte: 100}}}} -] -client.msearch(index:'books', body: body) -``` - -[discrete] -[[ex-scroll]] -=== Scrolling - -Submit a search API request that includes an argument for the scroll query -parameter, save the search ID, then print out the book names you found: - -```ruby -# Search request with a scroll argument: -response = client.search(index: 'books', scroll: '10m') - -# Save the scroll id: -scroll_id = response['_scroll_id'] - -# Print out the names of all the books we find: -while response['hits']['hits'].size.positive? - response = client.scroll(scroll: '5m', body: { scroll_id: scroll_id }) - puts(response['hits']['hits'].map { |r| r['_source']['name'] }) -end -``` - - -[discrete] -[[ex-reindex]] -=== Reindexing - -The following example shows how to reindex the `books` index into a new index -called `books-reindexed`: - -```ruby -client.reindex(body: {source: { index: 'books'}, dest: {index: 'books-reindexed' } }) -``` diff --git a/docs/examples/apm/screenshot.jpg b/docs/examples/apm/screenshot.jpg deleted file mode 100644 index 6ba778dfb5..0000000000 Binary files a/docs/examples/apm/screenshot.jpg and /dev/null differ diff --git a/docs/examples/guide/0091fc75271b1fbbd4269622a4881e8b.asciidoc b/docs/examples/guide/0091fc75271b1fbbd4269622a4881e8b.asciidoc index ece3af94cb..5a97c4fcb7 100644 --- a/docs/examples/guide/0091fc75271b1fbbd4269622a4881e8b.asciidoc +++ b/docs/examples/guide/0091fc75271b1fbbd4269622a4881e8b.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "http.clientip": '40.135.0.0' + 'http.clientip' => '40.135.0.0' } }, fields: [ diff --git a/docs/examples/guide/01c0e302f4fd5118faf5e34f4a010ebf.asciidoc b/docs/examples/guide/01c0e302f4fd5118faf5e34f4a010ebf.asciidoc deleted file mode 100644 index d021935d69..0000000000 --- a/docs/examples/guide/01c0e302f4fd5118faf5e34f4a010ebf.asciidoc +++ /dev/null @@ -1,12 +0,0 @@ -[source, ruby] ----- -response = client.indices.put_settings( - index: 'my_source_index', - body: { - settings: { - "index.blocks.write": true - } - } -) -puts response ----- diff --git a/docs/examples/guide/02b6aa3e5652839f03de3a655854b897.asciidoc b/docs/examples/guide/02b6aa3e5652839f03de3a655854b897.asciidoc new file mode 100644 index 0000000000..262aa3d102 --- /dev/null +++ b/docs/examples/guide/02b6aa3e5652839f03de3a655854b897.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.search( + index: 'my-data-stream' +) +puts response +---- diff --git a/docs/examples/guide/033838729cfb5d1a28d04f69ee78d924.asciidoc b/docs/examples/guide/033838729cfb5d1a28d04f69ee78d924.asciidoc new file mode 100644 index 0000000000..9afab92f19 --- /dev/null +++ b/docs/examples/guide/033838729cfb5d1a28d04f69ee78d924.asciidoc @@ -0,0 +1,41 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'Polygon', + orientation: 'LEFT', + coordinates: [ + [ + [ + -177, + 10 + ], + [ + 176, + 15 + ], + [ + 172, + 0 + ], + [ + 176, + -15 + ], + [ + -177, + -10 + ], + [ + -177, + 10 + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/0350410d11579f4e876c798ce1eaef5b.asciidoc b/docs/examples/guide/0350410d11579f4e876c798ce1eaef5b.asciidoc new file mode 100644 index 0000000000..4382f16605 --- /dev/null +++ b/docs/examples/guide/0350410d11579f4e876c798ce1eaef5b.asciidoc @@ -0,0 +1,33 @@ +[source, ruby] +---- +response = client.index( + index: 'my-index-000001', + id: 5, + refresh: true, + body: { + query: { + bool: { + should: [ + { + match: { + message: { + query: 'Japanese art', + _name: 'query1' + } + } + }, + { + match: { + message: { + query: 'Holand culture', + _name: 'query2' + } + } + } + ] + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/04412d11783dac25b5fd2ec5407078a3.asciidoc b/docs/examples/guide/04412d11783dac25b5fd2ec5407078a3.asciidoc new file mode 100644 index 0000000000..70b13f8c28 --- /dev/null +++ b/docs/examples/guide/04412d11783dac25b5fd2ec5407078a3.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.connector.update_api_key_id( + connector_id: 'my-connector', + body: { + api_key_id: 'my-api-key-id', + api_key_secret_id: 'my-connector-secret-id' + } +) +puts response +---- diff --git a/docs/examples/guide/0502284d4685c478eb68761f979f4303.asciidoc b/docs/examples/guide/0502284d4685c478eb68761f979f4303.asciidoc index 9e21512aee..3a918f0cf8 100644 --- a/docs/examples/guide/0502284d4685c478eb68761f979f4303.asciidoc +++ b/docs/examples/guide/0502284d4685c478eb68761f979f4303.asciidoc @@ -8,7 +8,7 @@ response = client.ml.evaluate_data_frame( filter: [ { term: { - "ml.is_training": false + 'ml.is_training' => false } } ] diff --git a/docs/examples/guide/0514111513bb21f69a40c6258573264f.asciidoc b/docs/examples/guide/0514111513bb21f69a40c6258573264f.asciidoc deleted file mode 100644 index 0eb49a4320..0000000000 --- a/docs/examples/guide/0514111513bb21f69a40c6258573264f.asciidoc +++ /dev/null @@ -1,19 +0,0 @@ -[source, ruby] ----- -response = client.cluster.put_settings( - body: { - persistent: { - cluster: { - remote: { - cluster_one: { - seeds: [ - '127.0.0.1:9300' - ] - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/05500e77aef581d92f6c605f7a48f7df.asciidoc b/docs/examples/guide/05500e77aef581d92f6c605f7a48f7df.asciidoc new file mode 100644 index 0000000000..08bd3515c9 --- /dev/null +++ b/docs/examples/guide/05500e77aef581d92f6c605f7a48f7df.asciidoc @@ -0,0 +1,36 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'polygon', + coordinates: [ + [ + [ + 1000, + -1001 + ], + [ + 1001, + -1001 + ], + [ + 1001, + -1000 + ], + [ + 1000, + -1000 + ], + [ + 1000, + -1001 + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/05a09078fe1016e900e445ad4039cf97.asciidoc b/docs/examples/guide/05a09078fe1016e900e445ad4039cf97.asciidoc new file mode 100644 index 0000000000..3456e7448c --- /dev/null +++ b/docs/examples/guide/05a09078fe1016e900e445ad4039cf97.asciidoc @@ -0,0 +1,81 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'clientips', + body: { + mappings: { + properties: { + client_ip: { + type: 'keyword' + }, + env: { + type: 'keyword' + } + } + } + } +) +puts response + +response = client.bulk( + index: 'clientips', + body: [ + { + index: {} + }, + { + client_ip: '172.21.0.5', + env: 'Development' + }, + { + index: {} + }, + { + client_ip: '172.21.2.113', + env: 'QA' + }, + { + index: {} + }, + { + client_ip: '172.21.2.162', + env: 'QA' + }, + { + index: {} + }, + { + client_ip: '172.21.3.15', + env: 'Production' + }, + { + index: {} + }, + { + client_ip: '172.21.3.16', + env: 'Production' + } + ] +) +puts response + +response = client.enrich.put_policy( + name: 'clientip_policy', + body: { + match: { + indices: 'clientips', + match_field: 'client_ip', + enrich_fields: [ + 'env' + ] + } + } +) +puts response + +response = client.enrich.execute_policy( + name: 'clientip_policy', + wait_for_completion: false +) +puts response +---- diff --git a/docs/examples/guide/06d65e3505dcb306977185e8545cf4a8.asciidoc b/docs/examples/guide/06d65e3505dcb306977185e8545cf4a8.asciidoc index e6935f0668..8ea30df5e7 100644 --- a/docs/examples/guide/06d65e3505dcb306977185e8545cf4a8.asciidoc +++ b/docs/examples/guide/06d65e3505dcb306977185e8545cf4a8.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.total_shards_per_node": 400 + 'cluster.routing.allocation.total_shards_per_node' => 400 } } ) diff --git a/docs/examples/guide/070cf72783cfe534a04f2f64e4016052.asciidoc b/docs/examples/guide/070cf72783cfe534a04f2f64e4016052.asciidoc index d5d2d06587..c9cd446c1f 100644 --- a/docs/examples/guide/070cf72783cfe534a04f2f64e4016052.asciidoc +++ b/docs/examples/guide/070cf72783cfe534a04f2f64e4016052.asciidoc @@ -15,8 +15,8 @@ response = client.index( id: 'metric_1', body: { time: '100ms', - "time.min": '10ms', - "time.max": '900ms' + 'time.min' => '10ms', + 'time.max' => '900ms' } ) puts response diff --git a/docs/examples/guide/083e514297c09e91211f0d168aef1b0b.asciidoc b/docs/examples/guide/083e514297c09e91211f0d168aef1b0b.asciidoc index c2a75d4461..12732cfa40 100644 --- a/docs/examples/guide/083e514297c09e91211f0d168aef1b0b.asciidoc +++ b/docs/examples/guide/083e514297c09e91211f0d168aef1b0b.asciidoc @@ -5,7 +5,7 @@ response = client.update_by_query( body: { query: { match: { - "event.sequence": '97' + 'event.sequence' => '97' } }, script: { diff --git a/docs/examples/guide/086ec4c5d86bbf80fb80162e94037689.asciidoc b/docs/examples/guide/086ec4c5d86bbf80fb80162e94037689.asciidoc new file mode 100644 index 0000000000..66813eba78 --- /dev/null +++ b/docs/examples/guide/086ec4c5d86bbf80fb80162e94037689.asciidoc @@ -0,0 +1,48 @@ +[source, ruby] +---- +response = client.search( + body: { + query: { + weighted_tokens: { + query_expansion_field: { + tokens: { + "2161": 0.4679, + "2621": 0.307, + "2782": 0.1299, + "2851": 0.1056, + "3088": 0.3041, + "3376": 0.1038, + "3467": 0.4873, + "3684": 0.8958, + "4380": 0.334, + "4542": 0.4636, + "4633": 2.2805, + "4785": 1.2628, + "4860": 1.0655, + "5133": 1.0709, + "7139": 1.0016, + "7224": 0.2486, + "7387": 0.0985, + "7394": 0.0542, + "8915": 0.369, + "9156": 2.8947, + "10505": 0.2771, + "11464": 0.3996, + "13525": 0.0088, + "14178": 0.8161, + "16893": 0.1376, + "17851": 1.5348, + "19939": 0.6012 + }, + pruning_config: { + tokens_freq_ratio_threshold: 5, + tokens_weight_threshold: 0.4, + only_score_pruned_tokens: false + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/08f20902821a4f7a73ce7b959c5bdbdc.asciidoc b/docs/examples/guide/08f20902821a4f7a73ce7b959c5bdbdc.asciidoc new file mode 100644 index 0000000000..b09f73849c --- /dev/null +++ b/docs/examples/guide/08f20902821a4f7a73ce7b959c5bdbdc.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.search( + body: { + query: { + regexp: { + 'user.id' => { + value: 'k.*y', + flags: 'ALL', + case_insensitive: true, + max_determinized_states: 10_000, + rewrite: 'constant_score_blended' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/091200b658023db31dffc2f08a85a9cc.asciidoc b/docs/examples/guide/091200b658023db31dffc2f08a85a9cc.asciidoc index ab4f18e035..2978aa101a 100644 --- a/docs/examples/guide/091200b658023db31dffc2f08a85a9cc.asciidoc +++ b/docs/examples/guide/091200b658023db31dffc2f08a85a9cc.asciidoc @@ -4,7 +4,7 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { index: { - "routing.allocation.total_shards_per_node": -1 + 'routing.allocation.total_shards_per_node' => -1 } } ) diff --git a/docs/examples/guide/0957bbd535f58c97b12ffba90813d64c.asciidoc b/docs/examples/guide/0957bbd535f58c97b12ffba90813d64c.asciidoc index 0378daa07e..f5c1386805 100644 --- a/docs/examples/guide/0957bbd535f58c97b12ffba90813d64c.asciidoc +++ b/docs/examples/guide/0957bbd535f58c97b12ffba90813d64c.asciidoc @@ -4,7 +4,7 @@ response = client.indices.create( index: 'analyze_sample', body: { settings: { - "index.analyze.max_token_count": 20_000 + 'index.analyze.max_token_count' => 20_000 } } ) diff --git a/docs/examples/guide/09a478fe32a7b7d814083ffa5297bcdf.asciidoc b/docs/examples/guide/09a478fe32a7b7d814083ffa5297bcdf.asciidoc index 6829a3b96c..9b1e738eab 100644 --- a/docs/examples/guide/09a478fe32a7b7d814083ffa5297bcdf.asciidoc +++ b/docs/examples/guide/09a478fe32a7b7d814083ffa5297bcdf.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { fuzzy: { - "user.id": { + 'user.id' => { value: 'ki' } } diff --git a/docs/examples/guide/09bdf9a7e22733d668476724042a406c.asciidoc b/docs/examples/guide/09bdf9a7e22733d668476724042a406c.asciidoc index 062b985eee..b4cb5b0eba 100644 --- a/docs/examples/guide/09bdf9a7e22733d668476724042a406c.asciidoc +++ b/docs/examples/guide/09bdf9a7e22733d668476724042a406c.asciidoc @@ -11,7 +11,7 @@ response = client.indices.put_index_template( settings: { number_of_shards: 1, number_of_replicas: 1, - "index.lifecycle.name": 'timeseries_policy' + 'index.lifecycle.name' => 'timeseries_policy' } } } diff --git a/docs/examples/guide/0a3003fa5af850e415634b50b1029859.asciidoc b/docs/examples/guide/0a3003fa5af850e415634b50b1029859.asciidoc index 014354e582..90fe82158f 100644 --- a/docs/examples/guide/0a3003fa5af850e415634b50b1029859.asciidoc +++ b/docs/examples/guide/0a3003fa5af850e415634b50b1029859.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { query: { match: { - "event.sequence": '97' + 'event.sequence' => '97' } } } diff --git a/docs/examples/guide/0a84c5b7c0793be745b13eaf13e94422.asciidoc b/docs/examples/guide/0a84c5b7c0793be745b13eaf13e94422.asciidoc index 4a2f27239d..ebbfac8bd3 100644 --- a/docs/examples/guide/0a84c5b7c0793be745b13eaf13e94422.asciidoc +++ b/docs/examples/guide/0a84c5b7c0793be745b13eaf13e94422.asciidoc @@ -4,7 +4,7 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { index: { - "routing.allocation.total_shards_per_node": '2' + 'routing.allocation.total_shards_per_node' => '2' } } ) diff --git a/docs/examples/guide/0ac5ec27c129b9541a6ddad6aeea1276.asciidoc b/docs/examples/guide/0ac5ec27c129b9541a6ddad6aeea1276.asciidoc deleted file mode 100644 index bf807e3171..0000000000 --- a/docs/examples/guide/0ac5ec27c129b9541a6ddad6aeea1276.asciidoc +++ /dev/null @@ -1,20 +0,0 @@ -[source, ruby] ----- -response = client.search( - body: { - query: { - fuzzy: { - "user.id": { - value: 'ki', - fuzziness: 'AUTO', - max_expansions: 50, - prefix_length: 0, - transpositions: true, - rewrite: 'constant_score' - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/0ac9e7dd7e4acba51888256326ed5ffe.asciidoc b/docs/examples/guide/0ac9e7dd7e4acba51888256326ed5ffe.asciidoc index 5cc10e6545..06e9740778 100644 --- a/docs/examples/guide/0ac9e7dd7e4acba51888256326ed5ffe.asciidoc +++ b/docs/examples/guide/0ac9e7dd7e4acba51888256326ed5ffe.asciidoc @@ -6,7 +6,7 @@ response = client.search( track_total_hits: true, query: { match: { - "user.id": 'elkbee' + 'user.id' => 'elkbee' } } } diff --git a/docs/examples/guide/0b913fb9e010d877c0be015519cfddc6.asciidoc b/docs/examples/guide/0b913fb9e010d877c0be015519cfddc6.asciidoc new file mode 100644 index 0000000000..89567134c6 --- /dev/null +++ b/docs/examples/guide/0b913fb9e010d877c0be015519cfddc6.asciidoc @@ -0,0 +1,39 @@ +[source, ruby] +---- +response = client.index( + index: 'my-index-000001', + body: { + "@timestamp": '2019-05-18T15:57:27.541Z', + ip: '225.44.217.191', + extension: 'jpg', + response: '200', + geo: { + coordinates: { + lat: 38.53146222, + lon: -121.7864906 + } + }, + url: 'https://media-for-the-masses.theacademyofperformingartsandscience.org/uploads/charles-fullerton.jpg' + } +) +puts response + +response = client.index( + index: 'my-index-000002', + body: { + "@timestamp": '2019-05-20T03:44:20.844Z', + ip: '198.247.165.49', + extension: 'php', + response: '200', + geo: { + coordinates: { + lat: 37.13189556, + lon: -76.4929875 + } + }, + memory: 241_720, + url: 'https://theacademyofperformingartsandscience.org/people/type:astronauts/name:laurel-b-clark/profile' + } +) +puts response +---- diff --git a/docs/examples/guide/0ba5acede9d43af424e85428e7d35420.asciidoc b/docs/examples/guide/0ba5acede9d43af424e85428e7d35420.asciidoc new file mode 100644 index 0000000000..87819a64c9 --- /dev/null +++ b/docs/examples/guide/0ba5acede9d43af424e85428e7d35420.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.ingest.put_pipeline( + id: 'azure_openai_embeddings', + body: { + processors: [ + { + inference: { + model_id: 'azure_openai_embeddings', + input_output: { + input_field: 'content', + output_field: 'content_embedding' + } + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/0c7c40cd17985c3dd32aeaadbafc4fce.asciidoc b/docs/examples/guide/0c7c40cd17985c3dd32aeaadbafc4fce.asciidoc new file mode 100644 index 0000000000..272df3e322 --- /dev/null +++ b/docs/examples/guide/0c7c40cd17985c3dd32aeaadbafc4fce.asciidoc @@ -0,0 +1,18 @@ +[source, ruby] +---- +response = client.render_search_template( + body: { + source: { + query: { + match: { + message: '{{^name_exists}}Hello World{{/name_exists}}' + } + } + }, + params: { + name_exists: false + } + } +) +puts response +---- diff --git a/docs/examples/guide/0cee58617e75f493c5049d77be1c49f3.asciidoc b/docs/examples/guide/0cee58617e75f493c5049d77be1c49f3.asciidoc new file mode 100644 index 0000000000..3a25f0bc33 --- /dev/null +++ b/docs/examples/guide/0cee58617e75f493c5049d77be1c49f3.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.search( + body: { + query: { + fuzzy: { + 'user.id' => { + value: 'ki', + fuzziness: 'AUTO', + max_expansions: 50, + prefix_length: 0, + transpositions: true, + rewrite: 'constant_score_blended' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/0cf29da4b9f0503bd1a79bdc883aadbc.asciidoc b/docs/examples/guide/0cf29da4b9f0503bd1a79bdc883aadbc.asciidoc index f962665195..642fe40df3 100644 --- a/docs/examples/guide/0cf29da4b9f0503bd1a79bdc883aadbc.asciidoc +++ b/docs/examples/guide/0cf29da4b9f0503bd1a79bdc883aadbc.asciidoc @@ -5,7 +5,7 @@ response = client.search( size: 0, body: { runtime_mappings: { - "grade.corrected": { + 'grade.corrected' => { type: 'double', script: { source: "emit(Math.min(100, doc['grade'].value * params.correction))", diff --git a/docs/examples/guide/0e83f140237d75469a428ff403564bb5.asciidoc b/docs/examples/guide/0e83f140237d75469a428ff403564bb5.asciidoc index de32e24924..e81db18aed 100644 --- a/docs/examples/guide/0e83f140237d75469a428ff403564bb5.asciidoc +++ b/docs/examples/guide/0e83f140237d75469a428ff403564bb5.asciidoc @@ -3,10 +3,10 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.disk.watermark.low": '100gb', - "cluster.routing.allocation.disk.watermark.high": '50gb', - "cluster.routing.allocation.disk.watermark.flood_stage": '10gb', - "cluster.info.update.interval": '1m' + 'cluster.routing.allocation.disk.watermark.low' => '100gb', + 'cluster.routing.allocation.disk.watermark.high' => '50gb', + 'cluster.routing.allocation.disk.watermark.flood_stage' => '10gb', + 'cluster.info.update.interval' => '1m' } } ) diff --git a/docs/examples/guide/0eae571e9e1c40a40cb4b1c9530a8987.asciidoc b/docs/examples/guide/0eae571e9e1c40a40cb4b1c9530a8987.asciidoc new file mode 100644 index 0000000000..de7c0517f8 --- /dev/null +++ b/docs/examples/guide/0eae571e9e1c40a40cb4b1c9530a8987.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.ilm.migrate_to_data_tiers( + body: { + legacy_template_to_delete: 'global-template', + node_attribute: 'custom_attribute_name' + } +) +puts response +---- diff --git a/docs/examples/guide/0eccea755bd4f6dd47579a9022690546.asciidoc b/docs/examples/guide/0eccea755bd4f6dd47579a9022690546.asciidoc new file mode 100644 index 0000000000..2a75495820 --- /dev/null +++ b/docs/examples/guide/0eccea755bd4f6dd47579a9022690546.asciidoc @@ -0,0 +1,18 @@ +[source, ruby] +---- +response = client.cluster.put_settings( + body: { + persistent: { + cluster: { + remote: { + my_remote: { + mode: 'proxy', + proxy_address: 'my.remote.cluster.com:9443' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/0f2e5e006b663a88ee99b130ab1b4844.asciidoc b/docs/examples/guide/0f2e5e006b663a88ee99b130ab1b4844.asciidoc index 2145ec81bf..f2fe2c785b 100644 --- a/docs/examples/guide/0f2e5e006b663a88ee99b130ab1b4844.asciidoc +++ b/docs/examples/guide/0f2e5e006b663a88ee99b130ab1b4844.asciidoc @@ -5,7 +5,7 @@ response = client.search( sort: [ { _geo_distance: { - "pin.location": [ + 'pin.location' => [ [ -70, 40 diff --git a/docs/examples/guide/0f3a78296825d507dda6771f7ceb9d61.asciidoc b/docs/examples/guide/0f3a78296825d507dda6771f7ceb9d61.asciidoc index f60ab0aad9..421f3f3b1f 100644 --- a/docs/examples/guide/0f3a78296825d507dda6771f7ceb9d61.asciidoc +++ b/docs/examples/guide/0f3a78296825d507dda6771f7ceb9d61.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.exclude._ip": '10.0.0.1' + 'cluster.routing.allocation.exclude._ip' => '10.0.0.1' } } ) diff --git a/docs/examples/guide/1070e59ba144cdf309fd9b2591612b95.asciidoc b/docs/examples/guide/1070e59ba144cdf309fd9b2591612b95.asciidoc new file mode 100644 index 0000000000..d2d1d286e0 --- /dev/null +++ b/docs/examples/guide/1070e59ba144cdf309fd9b2591612b95.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.index( + index: 'test', + id: 3, + body: { + test: 'test' + } +) +puts response + +response = client.index( + index: 'test', + id: 4, + refresh: false, + body: { + test: 'test' + } +) +puts response +---- diff --git a/docs/examples/guide/10f0c8fed98455c460c374b50ffbb204.asciidoc b/docs/examples/guide/10f0c8fed98455c460c374b50ffbb204.asciidoc new file mode 100644 index 0000000000..dc9a483dd8 --- /dev/null +++ b/docs/examples/guide/10f0c8fed98455c460c374b50ffbb204.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.indices.rollover( + alias: 'dsl-data-stream' +) +puts response +---- diff --git a/docs/examples/guide/1147a02afa087278e51fa365fb9e06b7.asciidoc b/docs/examples/guide/1147a02afa087278e51fa365fb9e06b7.asciidoc new file mode 100644 index 0000000000..d72c72314b --- /dev/null +++ b/docs/examples/guide/1147a02afa087278e51fa365fb9e06b7.asciidoc @@ -0,0 +1,9 @@ +[source, ruby] +---- +response = client.search( + body: { + size: '1000' + } +) +puts response +---- diff --git a/docs/examples/guide/11e8d6e14686efabb8634b6522c05cb5.asciidoc b/docs/examples/guide/11e8d6e14686efabb8634b6522c05cb5.asciidoc index 55e6e14846..e7a9a68f0d 100644 --- a/docs/examples/guide/11e8d6e14686efabb8634b6522c05cb5.asciidoc +++ b/docs/examples/guide/11e8d6e14686efabb8634b6522c05cb5.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { diff --git a/docs/examples/guide/1206539c3243681232cb134f4f89bed6.asciidoc b/docs/examples/guide/1206539c3243681232cb134f4f89bed6.asciidoc deleted file mode 100644 index b936cf7090..0000000000 --- a/docs/examples/guide/1206539c3243681232cb134f4f89bed6.asciidoc +++ /dev/null @@ -1,42 +0,0 @@ -[source, ruby] ----- -response = client.search( - index: 'sample-01*', - body: { - size: 0, - aggregations: { - tsid: { - terms: { - field: '_tsid' - }, - aggregations: { - over_time: { - date_histogram: { - field: '@timestamp', - fixed_interval: '1d' - }, - aggregations: { - min: { - min: { - field: 'kubernetes.container.memory.usage.bytes' - } - }, - max: { - max: { - field: 'kubernetes.container.memory.usage.bytes' - } - }, - avg: { - avg: { - field: 'kubernetes.container.memory.usage.bytes' - } - } - } - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/1295f51b9e5d4ba9987b02478146b50b.asciidoc b/docs/examples/guide/1295f51b9e5d4ba9987b02478146b50b.asciidoc index 4fdef9f756..b544c7f2f3 100644 --- a/docs/examples/guide/1295f51b9e5d4ba9987b02478146b50b.asciidoc +++ b/docs/examples/guide/1295f51b9e5d4ba9987b02478146b50b.asciidoc @@ -2,7 +2,7 @@ ---- response = client.indices.put_settings( body: { - "index.max_result_window": 5000 + 'index.max_result_window' => 5000 } ) puts response @@ -10,8 +10,8 @@ puts response response = client.cluster.put_settings( body: { persistent: { - "search.max_buckets": 20_000, - "search.allow_expensive_queries": false + 'search.max_buckets' => 20_000, + 'search.allow_expensive_queries' => false } } ) diff --git a/docs/examples/guide/12cb1a87cdd0326cbe5affabdbf2ffe2.asciidoc b/docs/examples/guide/12cb1a87cdd0326cbe5affabdbf2ffe2.asciidoc deleted file mode 100644 index f2bea9e76d..0000000000 --- a/docs/examples/guide/12cb1a87cdd0326cbe5affabdbf2ffe2.asciidoc +++ /dev/null @@ -1,7 +0,0 @@ -[source, ruby] ----- -response = client.ilm.explain_lifecycle( - index: 'my-index-000001' -) -puts response ----- diff --git a/docs/examples/guide/1302e24b0476e0e9af7a2c890edf9f62.asciidoc b/docs/examples/guide/1302e24b0476e0e9af7a2c890edf9f62.asciidoc index 996cd4e105..367c24ff6c 100644 --- a/docs/examples/guide/1302e24b0476e0e9af7a2c890edf9f62.asciidoc +++ b/docs/examples/guide/1302e24b0476e0e9af7a2c890edf9f62.asciidoc @@ -6,7 +6,7 @@ response = client.search( track_total_hits: false, query: { match: { - "user.id": 'elkbee' + 'user.id' => 'elkbee' } } } diff --git a/docs/examples/guide/134384b8c63cfbd8d762fb01757bb3f9.asciidoc b/docs/examples/guide/134384b8c63cfbd8d762fb01757bb3f9.asciidoc new file mode 100644 index 0000000000..d5811e51c1 --- /dev/null +++ b/docs/examples/guide/134384b8c63cfbd8d762fb01757bb3f9.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.index( + index: 'logs-debug', + body: { + date: '2019-12-12', + message: 'Starting up Elasticsearch', + level: 'debug' + } +) +puts response + +response = client.index( + index: 'logs-debug', + body: { + date: '2019-12-12', + message: 'Starting up Elasticsearch' + } +) +puts response +---- diff --git a/docs/examples/guide/13917f7cfb6a382c293275ff71134ec4.asciidoc b/docs/examples/guide/13917f7cfb6a382c293275ff71134ec4.asciidoc new file mode 100644 index 0000000000..cac3d1e470 --- /dev/null +++ b/docs/examples/guide/13917f7cfb6a382c293275ff71134ec4.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.render_search_template( + body: { + source: { + query: { + match: { + message: 'Hello {{#name_exists}}{{query_string}}{{/name_exists}}{{^name_exists}}World{{/name_exists}}' + } + } + }, + params: { + query_string: 'Kimchy', + name_exists: true + } + } +) +puts response +---- diff --git a/docs/examples/guide/13cc51ca3a783cdbb1f1d353eaedbf23.asciidoc b/docs/examples/guide/13cc51ca3a783cdbb1f1d353eaedbf23.asciidoc index 44f54dc09e..4c2688cead 100644 --- a/docs/examples/guide/13cc51ca3a783cdbb1f1d353eaedbf23.asciidoc +++ b/docs/examples/guide/13cc51ca3a783cdbb1f1d353eaedbf23.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "logger.org.elasticsearch.xpack.security.authc": 'debug' + 'logger.org.elasticsearch.xpack.security.authc' => 'debug' } } ) diff --git a/docs/examples/guide/13d90ba227131aefbf4fcfd5992e662a.asciidoc b/docs/examples/guide/13d90ba227131aefbf4fcfd5992e662a.asciidoc index fa36a229f4..5f5919e2a7 100644 --- a/docs/examples/guide/13d90ba227131aefbf4fcfd5992e662a.asciidoc +++ b/docs/examples/guide/13d90ba227131aefbf4fcfd5992e662a.asciidoc @@ -7,7 +7,7 @@ response = client.search( should: [ { match: { - "name.first": { + 'name.first' => { query: 'shay', _name: 'first' } @@ -15,7 +15,7 @@ response = client.search( }, { match: { - "name.last": { + 'name.last' => { query: 'banon', _name: 'last' } @@ -24,7 +24,7 @@ response = client.search( ], filter: { terms: { - "name.last": [ + 'name.last' => [ 'banon', 'kimchy' ], diff --git a/docs/examples/guide/13ecdf99114098c76b050397d9c3d4e6.asciidoc b/docs/examples/guide/13ecdf99114098c76b050397d9c3d4e6.asciidoc new file mode 100644 index 0000000000..5972158dfe --- /dev/null +++ b/docs/examples/guide/13ecdf99114098c76b050397d9c3d4e6.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.inference.inference( + task_type: 'sparse_embedding', + inference_id: 'my-elser-model', + body: { + input: 'The sky above the port was the color of television tuned to a dead channel.' + } +) +puts response +---- diff --git a/docs/examples/guide/14a1db30e13eb1d03cfd9710ca847ebb.asciidoc b/docs/examples/guide/14a1db30e13eb1d03cfd9710ca847ebb.asciidoc new file mode 100644 index 0000000000..0e7714c213 --- /dev/null +++ b/docs/examples/guide/14a1db30e13eb1d03cfd9710ca847ebb.asciidoc @@ -0,0 +1,23 @@ +[source, ruby] +---- +response = client.bulk( + index: 'my-data-stream', + body: [ + { + create: {} + }, + { + "@timestamp": '2099-05-06T16:21:15.000Z', + message: '192.0.2.42 - - [06/May/2099:16:21:15 +0000] "GET /images/bg.jpg HTTP/1.0" 200 24736' + }, + { + create: {} + }, + { + "@timestamp": '2099-05-06T16:25:42.000Z', + message: '192.0.2.255 - - [06/May/2099:16:25:42 +0000] "GET /favicon.ico HTTP/1.0" 200 3638' + } + ] +) +puts response +---- diff --git a/docs/examples/guide/14afe65afee3d43f27aaaa5b37f26a31.asciidoc b/docs/examples/guide/14afe65afee3d43f27aaaa5b37f26a31.asciidoc new file mode 100644 index 0000000000..5f446cbf10 --- /dev/null +++ b/docs/examples/guide/14afe65afee3d43f27aaaa5b37f26a31.asciidoc @@ -0,0 +1,16 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'Point', + coordinates: [ + -77.03653, + 38.897676 + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/154d703732daf5c5fcd0122e6a50213f.asciidoc b/docs/examples/guide/154d703732daf5c5fcd0122e6a50213f.asciidoc index 7f90b03bb1..c148862c88 100644 --- a/docs/examples/guide/154d703732daf5c5fcd0122e6a50213f.asciidoc +++ b/docs/examples/guide/154d703732daf5c5fcd0122e6a50213f.asciidoc @@ -4,10 +4,10 @@ response = client.indices.put_mapping( index: 'my-index-000001', body: { runtime: { - "measures.start": { + 'measures.start' => { type: 'long' }, - "measures.end": { + 'measures.end' => { type: 'long' } } diff --git a/docs/examples/guide/156bc64c94f9f3334fbce25165d2286a.asciidoc b/docs/examples/guide/156bc64c94f9f3334fbce25165d2286a.asciidoc index a56a0baf72..cb0e371518 100644 --- a/docs/examples/guide/156bc64c94f9f3334fbce25165d2286a.asciidoc +++ b/docs/examples/guide/156bc64c94f9f3334fbce25165d2286a.asciidoc @@ -5,8 +5,8 @@ response = client.indices.create( body: { settings: { index: { - "sort.field": 'date', - "sort.order": 'desc' + 'sort.field' => 'date', + 'sort.order' => 'desc' } }, mappings: { diff --git a/docs/examples/guide/165bebb9ce8b6babb72672db5b8b5976.asciidoc b/docs/examples/guide/165bebb9ce8b6babb72672db5b8b5976.asciidoc deleted file mode 100644 index 7043cf07f8..0000000000 --- a/docs/examples/guide/165bebb9ce8b6babb72672db5b8b5976.asciidoc +++ /dev/null @@ -1,24 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'test_index', - body: { - settings: { - index: { - analysis: { - filter: { - synonym: { - type: 'synonym', - synonyms: [ - 'i-pod, i pod => ipod', - 'universe, cosmos' - ] - } - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/16fc93f0e9a395d0668483d29e3df9d8.asciidoc b/docs/examples/guide/16fc93f0e9a395d0668483d29e3df9d8.asciidoc new file mode 100644 index 0000000000..5a5410cf7f --- /dev/null +++ b/docs/examples/guide/16fc93f0e9a395d0668483d29e3df9d8.asciidoc @@ -0,0 +1,35 @@ +[source, ruby] +---- +response = client.bulk( + index: 'mv', + refresh: true, + body: [ + { + index: {} + }, + { + a: 1, + b: [ + 2, + 1 + ] + }, + { + index: {} + }, + { + a: 2, + b: 3 + } + ] +) +puts response + +response = client.esql.query( + body: { + query: 'FROM mv | LIMIT 2', + version: '2024.04.01' + } +) +puts response +---- diff --git a/docs/examples/guide/1736545c8b5674f6d311f3277eb387f1.asciidoc b/docs/examples/guide/1736545c8b5674f6d311f3277eb387f1.asciidoc new file mode 100644 index 0000000000..2c07d094b6 --- /dev/null +++ b/docs/examples/guide/1736545c8b5674f6d311f3277eb387f1.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.indices.put_data_lifecycle( + name: 'my-data-stream', + body: { + data_retention: '30d' + } +) +puts response +---- diff --git a/docs/examples/guide/17e6f3fac556f08a78f7a876e71acb89.asciidoc b/docs/examples/guide/17e6f3fac556f08a78f7a876e71acb89.asciidoc index 419b4f0d93..914ab1e5ae 100644 --- a/docs/examples/guide/17e6f3fac556f08a78f7a876e71acb89.asciidoc +++ b/docs/examples/guide/17e6f3fac556f08a78f7a876e71acb89.asciidoc @@ -4,7 +4,7 @@ response = client.indices.put_settings( index: '_all', body: { settings: { - "index.unassigned.node_left.delayed_timeout": '5m' + 'index.unassigned.node_left.delayed_timeout' => '5m' } } ) diff --git a/docs/examples/guide/17fb298fb1e47f7d946a772d68f4e2df.asciidoc b/docs/examples/guide/17fb298fb1e47f7d946a772d68f4e2df.asciidoc index c068872aba..b036ff9e74 100644 --- a/docs/examples/guide/17fb298fb1e47f7d946a772d68f4e2df.asciidoc +++ b/docs/examples/guide/17fb298fb1e47f7d946a772d68f4e2df.asciidoc @@ -5,7 +5,7 @@ response = client.delete_by_query( body: { query: { match: { - "user.id": 'vlb44hny' + 'user.id' => 'vlb44hny' } } } diff --git a/docs/examples/guide/186a7143d50e8c3ee01094e1a9ff0c0c.asciidoc b/docs/examples/guide/186a7143d50e8c3ee01094e1a9ff0c0c.asciidoc new file mode 100644 index 0000000000..05ba3af0e9 --- /dev/null +++ b/docs/examples/guide/186a7143d50e8c3ee01094e1a9ff0c0c.asciidoc @@ -0,0 +1,35 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'passage_vectors', + body: { + mappings: { + properties: { + full_text: { + type: 'text' + }, + creation_time: { + type: 'date' + }, + paragraph: { + type: 'nested', + properties: { + vector: { + type: 'dense_vector', + dims: 2, + index_options: { + type: 'hnsw' + } + }, + text: { + type: 'text', + index: false + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/197dc41c8df9629e145b3064c63b2ccc.asciidoc b/docs/examples/guide/197dc41c8df9629e145b3064c63b2ccc.asciidoc deleted file mode 100644 index fbbb020028..0000000000 --- a/docs/examples/guide/197dc41c8df9629e145b3064c63b2ccc.asciidoc +++ /dev/null @@ -1,37 +0,0 @@ -[source, ruby] ----- -response = client.bulk( - index: 'customer', - body: [ - { - create: {} - }, - { - firstname: 'Monica', - lastname: 'Rambeau' - }, - { - create: {} - }, - { - firstname: 'Carol', - lastname: 'Danvers' - }, - { - create: {} - }, - { - firstname: 'Wanda', - lastname: 'Maximoff' - }, - { - create: {} - }, - { - firstname: 'Jennifer', - lastname: 'Takeda' - } - ] -) -puts response ----- diff --git a/docs/examples/guide/19c00c6b29bc7dbc5e92b3668da2da93.asciidoc b/docs/examples/guide/19c00c6b29bc7dbc5e92b3668da2da93.asciidoc new file mode 100644 index 0000000000..d7ed691180 --- /dev/null +++ b/docs/examples/guide/19c00c6b29bc7dbc5e92b3668da2da93.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.simulate.ingest( + body: { + docs: [ + { + _index: 'my-index', + _id: '123', + _source: { + foo: 'bar' + } + }, + { + _index: 'my-index', + _id: '456', + _source: { + foo: 'rab' + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/1aa96eeaf63fc967e166d1a2fcdccccc.asciidoc b/docs/examples/guide/1aa96eeaf63fc967e166d1a2fcdccccc.asciidoc new file mode 100644 index 0000000000..75b7f4fdaf --- /dev/null +++ b/docs/examples/guide/1aa96eeaf63fc967e166d1a2fcdccccc.asciidoc @@ -0,0 +1,34 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index-000002', + body: { + mappings: { + properties: { + metrics: { + subobjects: false, + properties: { + time: { + type: 'object', + properties: { + min: { + type: 'long' + }, + max: { + type: 'long' + } + } + } + } + } + } + } + } +) +puts response + +response = client.indices.get_mapping( + index: 'my-index-000002' +) +puts response +---- diff --git a/docs/examples/guide/1b5c8d6e61930a308008b5b1ace2aa07.asciidoc b/docs/examples/guide/1b5c8d6e61930a308008b5b1ace2aa07.asciidoc index 6b69e350c7..6630104c85 100644 --- a/docs/examples/guide/1b5c8d6e61930a308008b5b1ace2aa07.asciidoc +++ b/docs/examples/guide/1b5c8d6e61930a308008b5b1ace2aa07.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "manager.name": 'Alice White' + 'manager.name' => 'Alice White' } }, aggregations: { diff --git a/docs/examples/guide/1c1f2a6a193d9e64c37242b2824b3031.asciidoc b/docs/examples/guide/1c1f2a6a193d9e64c37242b2824b3031.asciidoc new file mode 100644 index 0000000000..f133387e99 --- /dev/null +++ b/docs/examples/guide/1c1f2a6a193d9e64c37242b2824b3031.asciidoc @@ -0,0 +1,56 @@ +[source, ruby] +---- +response = client.cluster.put_component_template( + name: 'source_template', + body: { + template: { + settings: { + index: { + number_of_replicas: 2, + number_of_shards: 2, + mode: 'time_series', + routing_path: [ + 'metricset' + ] + } + }, + mappings: { + properties: { + "@timestamp": { + type: 'date' + }, + metricset: { + type: 'keyword', + time_series_dimension: true + }, + "k8s": { + properties: { + tx: { + type: 'long' + }, + rx: { + type: 'long' + } + } + } + } + } + } + } +) +puts response + +response = client.indices.put_index_template( + name: 1, + body: { + index_patterns: [ + 'k8s*' + ], + composed_of: [ + 'source_template' + ], + data_stream: {} + } +) +puts response +---- diff --git a/docs/examples/guide/1c5a5a8c0bdc3c577f560157bd4e2313.asciidoc b/docs/examples/guide/1c5a5a8c0bdc3c577f560157bd4e2313.asciidoc deleted file mode 100644 index d021935d69..0000000000 --- a/docs/examples/guide/1c5a5a8c0bdc3c577f560157bd4e2313.asciidoc +++ /dev/null @@ -1,12 +0,0 @@ -[source, ruby] ----- -response = client.indices.put_settings( - index: 'my_source_index', - body: { - settings: { - "index.blocks.write": true - } - } -) -puts response ----- diff --git a/docs/examples/guide/1cadbcf2cfeb312f73b7f098291356ac.asciidoc b/docs/examples/guide/1cadbcf2cfeb312f73b7f098291356ac.asciidoc new file mode 100644 index 0000000000..034775dae3 --- /dev/null +++ b/docs/examples/guide/1cadbcf2cfeb312f73b7f098291356ac.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'MULTIPOINT (102.0 2.0, 103.0 2.0)' + } +) +puts response +---- diff --git a/docs/examples/guide/1cb3b45335ab1b9697c358104d44ea39.asciidoc b/docs/examples/guide/1cb3b45335ab1b9697c358104d44ea39.asciidoc index fba8ebd60d..431f740523 100644 --- a/docs/examples/guide/1cb3b45335ab1b9697c358104d44ea39.asciidoc +++ b/docs/examples/guide/1cb3b45335ab1b9697c358104d44ea39.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "xpack.security.transport.filter.enabled": false + 'xpack.security.transport.filter.enabled' => false } } ) diff --git a/docs/examples/guide/1cd3b9d65576a9212eef898eb3105758.asciidoc b/docs/examples/guide/1cd3b9d65576a9212eef898eb3105758.asciidoc index 56c6f0b69e..76116fcedb 100644 --- a/docs/examples/guide/1cd3b9d65576a9212eef898eb3105758.asciidoc +++ b/docs/examples/guide/1cd3b9d65576a9212eef898eb3105758.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.enable": 'primaries' + 'cluster.routing.allocation.enable' => 'primaries' } } ) diff --git a/docs/examples/guide/1ce2cbfe1430c8837c19304a6b648af3.asciidoc b/docs/examples/guide/1ce2cbfe1430c8837c19304a6b648af3.asciidoc new file mode 100644 index 0000000000..ab0394bf90 --- /dev/null +++ b/docs/examples/guide/1ce2cbfe1430c8837c19304a6b648af3.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.esql.query( + body: { + query: 'FROM mv | EVAL b + 2, a + b | LIMIT 4', + version: '2024.04.01' + } +) +puts response +---- diff --git a/docs/examples/guide/1cfa04e9654c1484e3d4c75bf439400a.asciidoc b/docs/examples/guide/1cfa04e9654c1484e3d4c75bf439400a.asciidoc new file mode 100644 index 0000000000..b12afda61e --- /dev/null +++ b/docs/examples/guide/1cfa04e9654c1484e3d4c75bf439400a.asciidoc @@ -0,0 +1,58 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'polygon', + coordinates: [ + [ + [ + 1000, + -1001 + ], + [ + 1001, + -1001 + ], + [ + 1001, + -1000 + ], + [ + 1000, + -1000 + ], + [ + 1000, + -1001 + ] + ], + [ + [ + 1000.2, + -1001.2 + ], + [ + 1000.8, + -1001.2 + ], + [ + 1000.8, + -1001.8 + ], + [ + 1000.2, + -1001.8 + ], + [ + 1000.2, + -1001.2 + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/1d746272a7511bf91302a15b5c58ca0e.asciidoc b/docs/examples/guide/1d746272a7511bf91302a15b5c58ca0e.asciidoc new file mode 100644 index 0000000000..91ad0a31e5 --- /dev/null +++ b/docs/examples/guide/1d746272a7511bf91302a15b5c58ca0e.asciidoc @@ -0,0 +1,23 @@ +[source, ruby] +---- +response = client.search( + index: 'passage_vectors', + body: { + fields: [ + 'full_text', + 'creation_time' + ], + _source: false, + knn: { + query_vector: [ + 0.45, + 45 + ], + field: 'paragraph.vector', + k: 2, + num_candidates: 2 + } + } +) +puts response +---- diff --git a/docs/examples/guide/1d918e206ad8dab916e59183da24d9ec.asciidoc b/docs/examples/guide/1d918e206ad8dab916e59183da24d9ec.asciidoc index 0adff674d0..aa554fcd02 100644 --- a/docs/examples/guide/1d918e206ad8dab916e59183da24d9ec.asciidoc +++ b/docs/examples/guide/1d918e206ad8dab916e59183da24d9ec.asciidoc @@ -3,7 +3,7 @@ response = client.indices.put_settings( index: '.watches', body: { - "index.routing.allocation.include.role": 'watcher' + 'index.routing.allocation.include.role' => 'watcher' } ) puts response diff --git a/docs/examples/guide/1d9b695a17cffd910c496c9b03c75d6f.asciidoc b/docs/examples/guide/1d9b695a17cffd910c496c9b03c75d6f.asciidoc new file mode 100644 index 0000000000..0bfbbe2d71 --- /dev/null +++ b/docs/examples/guide/1d9b695a17cffd910c496c9b03c75d6f.asciidoc @@ -0,0 +1,26 @@ +[source, ruby] +---- +response = client.ilm.put_lifecycle( + policy: 'pre-dsl-ilm-policy', + body: { + policy: { + phases: { + hot: { + actions: { + rollover: { + max_primary_shard_size: '50gb' + } + } + }, + delete: { + min_age: '7d', + actions: { + delete: {} + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/1e94a2bb95bc245bcfb87ac7d611cf49.asciidoc b/docs/examples/guide/1e94a2bb95bc245bcfb87ac7d611cf49.asciidoc new file mode 100644 index 0000000000..95b97b0d29 --- /dev/null +++ b/docs/examples/guide/1e94a2bb95bc245bcfb87ac7d611cf49.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.search( + index: 'latency', + body: { + size: 0, + aggregations: { + load_time_outlier: { + percentiles: { + field: 'load_time', + tdigest: { + execution_hint: 'high_accuracy' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/1eb9c6ecb827ca69f7b17f7d2a26eae9.asciidoc b/docs/examples/guide/1eb9c6ecb827ca69f7b17f7d2a26eae9.asciidoc index c4ccf60c50..a40eec98d0 100644 --- a/docs/examples/guide/1eb9c6ecb827ca69f7b17f7d2a26eae9.asciidoc +++ b/docs/examples/guide/1eb9c6ecb827ca69f7b17f7d2a26eae9.asciidoc @@ -5,7 +5,7 @@ response = client.render_search_template( source: { query: { term: { - "url.full": '{{#url}}{{host}}/{{page}}{{/url}}' + 'url.full' => '{{#url}}{{host}}/{{page}}{{/url}}' } } }, diff --git a/docs/examples/guide/1ed77bf308fa4ab328b36060e412f500.asciidoc b/docs/examples/guide/1ed77bf308fa4ab328b36060e412f500.asciidoc new file mode 100644 index 0000000000..fb386b3b81 --- /dev/null +++ b/docs/examples/guide/1ed77bf308fa4ab328b36060e412f500.asciidoc @@ -0,0 +1,91 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'metrics_index', + body: { + mappings: { + properties: { + network: { + properties: { + name: { + type: 'keyword' + } + } + }, + latency_histo: { + type: 'histogram' + } + } + } + } +) +puts response + +response = client.index( + index: 'metrics_index', + id: 1, + refresh: true, + body: { + 'network.name' => 'net-1', + latency_histo: { + values: [ + 1, + 3, + 8, + 12, + 15 + ], + counts: [ + 3, + 7, + 23, + 12, + 6 + ] + } + } +) +puts response + +response = client.index( + index: 'metrics_index', + id: 2, + refresh: true, + body: { + 'network.name' => 'net-2', + latency_histo: { + values: [ + 1, + 6, + 8, + 12, + 14 + ], + counts: [ + 8, + 17, + 8, + 7, + 6 + ] + } + } +) +puts response + +response = client.search( + index: 'metrics_index', + size: 0, + body: { + aggregations: { + latency_buckets: { + histogram: { + field: 'latency_histo', + interval: 5 + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/1f507659757e2844cefced25848540a0.asciidoc b/docs/examples/guide/1f507659757e2844cefced25848540a0.asciidoc index 360c711dde..4681d24d98 100644 --- a/docs/examples/guide/1f507659757e2844cefced25848540a0.asciidoc +++ b/docs/examples/guide/1f507659757e2844cefced25848540a0.asciidoc @@ -11,7 +11,7 @@ response = client.search( filter: { geo_distance: { distance: '12km', - "pin.location": [ + 'pin.location' => [ -70, 40 ] diff --git a/docs/examples/guide/1f6a190fa1aade1fb66680388f184ef9.asciidoc b/docs/examples/guide/1f6a190fa1aade1fb66680388f184ef9.asciidoc index e7ba65255b..4ab0f74b92 100644 --- a/docs/examples/guide/1f6a190fa1aade1fb66680388f184ef9.asciidoc +++ b/docs/examples/guide/1f6a190fa1aade1fb66680388f184ef9.asciidoc @@ -7,7 +7,7 @@ response = client.indices.validate_query( body: { query: { match: { - "user.id": { + 'user.id' => { query: 'kimchy', fuzziness: 'auto' } diff --git a/docs/examples/guide/1fcc4a3280be399753dcfd5c489ff682.asciidoc b/docs/examples/guide/1fcc4a3280be399753dcfd5c489ff682.asciidoc new file mode 100644 index 0000000000..ba41c64e82 --- /dev/null +++ b/docs/examples/guide/1fcc4a3280be399753dcfd5c489ff682.asciidoc @@ -0,0 +1,34 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'idx', + body: { + mappings: { + _source: { + mode: 'synthetic' + }, + properties: { + my_range: { + type: 'ip_range' + } + } + } + } +) +puts response + +response = client.index( + index: 'idx', + id: 1, + body: { + my_range: [ + '10.0.0.0/24', + { + gte: '10.0.0.0', + lte: '10.0.0.255' + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/2009f2d1ba0780a799a0fdce889c9739.asciidoc b/docs/examples/guide/2009f2d1ba0780a799a0fdce889c9739.asciidoc new file mode 100644 index 0000000000..c206fffad9 --- /dev/null +++ b/docs/examples/guide/2009f2d1ba0780a799a0fdce889c9739.asciidoc @@ -0,0 +1,64 @@ +[source, ruby] +---- +response = client.bulk( + index: 'passage_vectors', + refresh: true, + body: [ + { + index: { + _id: '1' + } + }, + { + full_text: 'first paragraph another paragraph', + creation_time: '2019-05-04', + paragraph: [ + { + vector: [ + 0.45, + 45 + ], + text: 'first paragraph', + paragraph_id: '1' + }, + { + vector: [ + 0.8, + 0.6 + ], + text: 'another paragraph', + paragraph_id: '2' + } + ] + }, + { + index: { + _id: '2' + } + }, + { + full_text: 'number one paragraph number two paragraph', + creation_time: '2020-05-04', + paragraph: [ + { + vector: [ + 1.2, + 4.5 + ], + text: 'number one paragraph', + paragraph_id: '1' + }, + { + vector: [ + -1, + 42 + ], + text: 'number two paragraph', + paragraph_id: '2' + } + ] + } + ] +) +puts response +---- diff --git a/docs/examples/guide/20407c847adb8393ce41dc656384afc4.asciidoc b/docs/examples/guide/20407c847adb8393ce41dc656384afc4.asciidoc new file mode 100644 index 0000000000..9d11ea16f9 --- /dev/null +++ b/docs/examples/guide/20407c847adb8393ce41dc656384afc4.asciidoc @@ -0,0 +1,37 @@ +[source, ruby] +---- +response = client.search( + index: 'passage_vectors', + body: { + fields: [ + 'creation_time', + 'full_text' + ], + _source: false, + knn: { + query_vector: [ + 0.45, + 45 + ], + field: 'paragraph.vector', + k: 2, + num_candidates: 2, + filter: { + bool: { + filter: [ + { + range: { + creation_time: { + gte: '2019-05-01', + lte: '2019-05-05' + } + } + } + ] + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/2051ffe025550ab6645bfd525eaed3c4.asciidoc b/docs/examples/guide/2051ffe025550ab6645bfd525eaed3c4.asciidoc index ca39b7d159..237e9d305f 100644 --- a/docs/examples/guide/2051ffe025550ab6645bfd525eaed3c4.asciidoc +++ b/docs/examples/guide/2051ffe025550ab6645bfd525eaed3c4.asciidoc @@ -10,7 +10,7 @@ response = client.search( }, filter: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { top_left: 'POINT (-74.1 40.73)', bottom_right: 'POINT (-71.12 40.01)' } diff --git a/docs/examples/guide/2081739da0c69de8af6f5bf9e94433e6.asciidoc b/docs/examples/guide/2081739da0c69de8af6f5bf9e94433e6.asciidoc new file mode 100644 index 0000000000..ca8445843c --- /dev/null +++ b/docs/examples/guide/2081739da0c69de8af6f5bf9e94433e6.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'MULTILINESTRING ((102.0 2.0, 103.0 2.0, 103.0 3.0, 102.0 3.0), (100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8))' + } +) +puts response +---- diff --git a/docs/examples/guide/20e31b7ff08794bdf3c8f8ca3b796b1c.asciidoc b/docs/examples/guide/20e31b7ff08794bdf3c8f8ca3b796b1c.asciidoc deleted file mode 100644 index 8b485f60f5..0000000000 --- a/docs/examples/guide/20e31b7ff08794bdf3c8f8ca3b796b1c.asciidoc +++ /dev/null @@ -1,11 +0,0 @@ -[source, ruby] ----- -response = client.indices.downsample( - index: 'sample-01', - target_index: 'sample-01-downsample', - body: { - fixed_interval: '1h' - } -) -puts response ----- diff --git a/docs/examples/guide/2155c920d7d860f3ee7542f2211b4fec.asciidoc b/docs/examples/guide/2155c920d7d860f3ee7542f2211b4fec.asciidoc new file mode 100644 index 0000000000..f6c627b4bc --- /dev/null +++ b/docs/examples/guide/2155c920d7d860f3ee7542f2211b4fec.asciidoc @@ -0,0 +1,16 @@ +[source, ruby] +---- +response = client.search( + body: { + query: { + text_expansion: { + "": { + model_id: 'the model to produce the token weights', + model_text: 'the query string' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/21d0ab6e420bfe7a1639db6af5b2e9c0.asciidoc b/docs/examples/guide/21d0ab6e420bfe7a1639db6af5b2e9c0.asciidoc index a54d1256d5..649fd51ca7 100644 --- a/docs/examples/guide/21d0ab6e420bfe7a1639db6af5b2e9c0.asciidoc +++ b/docs/examples/guide/21d0ab6e420bfe7a1639db6af5b2e9c0.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "rating.out_of_ten": { + 'rating.out_of_ten' => { type: 'long', script: { source: "emit(doc['rating'].value * params.scaleFactor)", diff --git a/docs/examples/guide/2224143c45dfc83a2d10b98cd4f94bb5.asciidoc b/docs/examples/guide/2224143c45dfc83a2d10b98cd4f94bb5.asciidoc index 0a349c4918..6b26b2063b 100644 --- a/docs/examples/guide/2224143c45dfc83a2d10b98cd4f94bb5.asciidoc +++ b/docs/examples/guide/2224143c45dfc83a2d10b98cd4f94bb5.asciidoc @@ -11,7 +11,7 @@ response = client.search( path: 'comments', query: { term: { - "comments.author": 'nik9000' + 'comments.author' => 'nik9000' } } } diff --git a/docs/examples/guide/2238ac4170275f6cfc2af49c3f014cbc.asciidoc b/docs/examples/guide/2238ac4170275f6cfc2af49c3f014cbc.asciidoc index 23fd8144ab..b56b0daa0e 100644 --- a/docs/examples/guide/2238ac4170275f6cfc2af49c3f014cbc.asciidoc +++ b/docs/examples/guide/2238ac4170275f6cfc2af49c3f014cbc.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "grade.corrected": { + 'grade.corrected' => { type: 'double', script: { source: "emit(Math.min(100, doc['grade'].value * params.correction))", diff --git a/docs/examples/guide/22cb99d4e6ba3101a2d9f59764a90877.asciidoc b/docs/examples/guide/22cb99d4e6ba3101a2d9f59764a90877.asciidoc new file mode 100644 index 0000000000..0408e0fdf8 --- /dev/null +++ b/docs/examples/guide/22cb99d4e6ba3101a2d9f59764a90877.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'POINT (-77.03653 38.897676)' + } +) +puts response +---- diff --git a/docs/examples/guide/22dd833336fa22c8a8f67bb754ffba9a.asciidoc b/docs/examples/guide/22dd833336fa22c8a8f67bb754ffba9a.asciidoc new file mode 100644 index 0000000000..fdce36bfd6 --- /dev/null +++ b/docs/examples/guide/22dd833336fa22c8a8f67bb754ffba9a.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.search( + index: 'azure-openai-embeddings', + body: { + knn: { + field: 'content_embedding', + query_vector_builder: { + text_embedding: { + model_id: 'azure_openai_embeddings', + model_text: 'Calculate fuel cost' + } + }, + k: 10, + num_candidates: 100 + }, + _source: [ + 'id', + 'content' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/2310d84ebf113f2a3ed14cc53172ae4a.asciidoc b/docs/examples/guide/2310d84ebf113f2a3ed14cc53172ae4a.asciidoc new file mode 100644 index 0000000000..937d675bcd --- /dev/null +++ b/docs/examples/guide/2310d84ebf113f2a3ed14cc53172ae4a.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + query: { + text_expansion: { + 'ml.tokens' => { + model_id: '.elser_model_2', + model_text: 'How is the weather in Jamaica?' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/23af230e824f48b9cd56a4cf973d788c.asciidoc b/docs/examples/guide/23af230e824f48b9cd56a4cf973d788c.asciidoc index affb5c4321..58424f15be 100644 --- a/docs/examples/guide/23af230e824f48b9cd56a4cf973d788c.asciidoc +++ b/docs/examples/guide/23af230e824f48b9cd56a4cf973d788c.asciidoc @@ -3,14 +3,14 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { - "index.search.slowlog.threshold.query.warn": '10s', - "index.search.slowlog.threshold.query.info": '5s', - "index.search.slowlog.threshold.query.debug": '2s', - "index.search.slowlog.threshold.query.trace": '500ms', - "index.search.slowlog.threshold.fetch.warn": '1s', - "index.search.slowlog.threshold.fetch.info": '800ms', - "index.search.slowlog.threshold.fetch.debug": '500ms', - "index.search.slowlog.threshold.fetch.trace": '200ms' + 'index.search.slowlog.threshold.query.warn' => '10s', + 'index.search.slowlog.threshold.query.info' => '5s', + 'index.search.slowlog.threshold.query.debug' => '2s', + 'index.search.slowlog.threshold.query.trace' => '500ms', + 'index.search.slowlog.threshold.fetch.warn' => '1s', + 'index.search.slowlog.threshold.fetch.info' => '800ms', + 'index.search.slowlog.threshold.fetch.debug' => '500ms', + 'index.search.slowlog.threshold.fetch.trace' => '200ms' } ) puts response diff --git a/docs/examples/guide/24ad3c234f69f55a3fbe2d488e70178a.asciidoc b/docs/examples/guide/24ad3c234f69f55a3fbe2d488e70178a.asciidoc index 2a69b8cb1a..938c15b190 100644 --- a/docs/examples/guide/24ad3c234f69f55a3fbe2d488e70178a.asciidoc +++ b/docs/examples/guide/24ad3c234f69f55a3fbe2d488e70178a.asciidoc @@ -5,7 +5,7 @@ response = client.ml.evaluate_data_frame( index: 'student_performance_mathematics_reg', query: { term: { - "ml.is_training": { + 'ml.is_training' => { value: true } } diff --git a/docs/examples/guide/24d66b2ebdf662d8b03e17214e65c825.asciidoc b/docs/examples/guide/24d66b2ebdf662d8b03e17214e65c825.asciidoc new file mode 100644 index 0000000000..e9e2c858ea --- /dev/null +++ b/docs/examples/guide/24d66b2ebdf662d8b03e17214e65c825.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.cluster.put_settings( + body: { + persistent: { + 'xpack.profiling.templates.enabled' => false + } + } +) +puts response +---- diff --git a/docs/examples/guide/256eba7a77c8890a43afeda8ce8a3225.asciidoc b/docs/examples/guide/256eba7a77c8890a43afeda8ce8a3225.asciidoc new file mode 100644 index 0000000000..f32c912892 --- /dev/null +++ b/docs/examples/guide/256eba7a77c8890a43afeda8ce8a3225.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.ingest.put_pipeline( + id: 'my-text-embeddings-pipeline', + body: { + description: 'Text embedding pipeline', + processors: [ + { + inference: { + model_id: 'sentence-transformers__msmarco-minilm-l-12-v3', + target_field: 'my_embeddings', + field_map: { + my_text_field: 'text_field' + } + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/25981b7b3d55b87e1484586d57b695b1.asciidoc b/docs/examples/guide/25981b7b3d55b87e1484586d57b695b1.asciidoc new file mode 100644 index 0000000000..bb761bab2d --- /dev/null +++ b/docs/examples/guide/25981b7b3d55b87e1484586d57b695b1.asciidoc @@ -0,0 +1,12 @@ +[source, ruby] +---- +response = client.index( + index: 'products', + id: 1567, + body: { + product: 'r2d2', + details: 'A resourceful astromech droid' + } +) +puts response +---- diff --git a/docs/examples/guide/25d40d3049e57e2bb70c2c5b88bd7b87.asciidoc b/docs/examples/guide/25d40d3049e57e2bb70c2c5b88bd7b87.asciidoc index bd388c74e1..0f12f3a9aa 100644 --- a/docs/examples/guide/25d40d3049e57e2bb70c2c5b88bd7b87.asciidoc +++ b/docs/examples/guide/25d40d3049e57e2bb70c2c5b88bd7b87.asciidoc @@ -4,7 +4,7 @@ response = client.indices.put_settings( index: '_all', body: { settings: { - "index.unassigned.node_left.delayed_timeout": '0' + 'index.unassigned.node_left.delayed_timeout' => '0' } } ) diff --git a/docs/examples/guide/2646710ece0c4c843aebeacd370d0396.asciidoc b/docs/examples/guide/2646710ece0c4c843aebeacd370d0396.asciidoc new file mode 100644 index 0000000000..d8d4796cc6 --- /dev/null +++ b/docs/examples/guide/2646710ece0c4c843aebeacd370d0396.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-byte-quantized-index', + body: { + mappings: { + properties: { + my_vector: { + type: 'dense_vector', + dims: 3, + index: true, + index_options: { + type: 'int8_hnsw' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/27384266370152add76471dd0332a2f1.asciidoc b/docs/examples/guide/27384266370152add76471dd0332a2f1.asciidoc index 81861484c5..ea187447aa 100644 --- a/docs/examples/guide/27384266370152add76471dd0332a2f1.asciidoc +++ b/docs/examples/guide/27384266370152add76471dd0332a2f1.asciidoc @@ -7,7 +7,7 @@ response = client.transform.update_transform( index: 'kibana_sample_data_ecommerce', query: { term: { - "geoip.continent_name": { + 'geoip.continent_name' => { value: 'Asia' } } diff --git a/docs/examples/guide/274feaaa727e0ddf61b3c0f093182839.asciidoc b/docs/examples/guide/274feaaa727e0ddf61b3c0f093182839.asciidoc new file mode 100644 index 0000000000..7108c73033 --- /dev/null +++ b/docs/examples/guide/274feaaa727e0ddf61b3c0f093182839.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index-000001', + body: { + runtime_mappings: { + duration: { + type: 'long', + script: { + source: "\n emit(doc['measures.end'].value - doc['measures.start'].value);\n " + } + } + }, + aggregations: { + duration_stats: { + stats: { + field: 'duration' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/279e2b29261971999923fdc658bba8ff.asciidoc b/docs/examples/guide/279e2b29261971999923fdc658bba8ff.asciidoc index 71610c2706..81c0dc4380 100644 --- a/docs/examples/guide/279e2b29261971999923fdc658bba8ff.asciidoc +++ b/docs/examples/guide/279e2b29261971999923fdc658bba8ff.asciidoc @@ -13,7 +13,7 @@ response = client.search( }, query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/27c22a152470e6a4c06e832731d9b77d.asciidoc b/docs/examples/guide/27c22a152470e6a4c06e832731d9b77d.asciidoc deleted file mode 100644 index f7b0543284..0000000000 --- a/docs/examples/guide/27c22a152470e6a4c06e832731d9b77d.asciidoc +++ /dev/null @@ -1,8 +0,0 @@ -[source, ruby] ----- -response = client.indices.add_block( - index: 'sample-01', - block: 'write' -) -puts response ----- diff --git a/docs/examples/guide/28543836b62b5622a402e6f7731d68f0.asciidoc b/docs/examples/guide/28543836b62b5622a402e6f7731d68f0.asciidoc new file mode 100644 index 0000000000..f2c56f82c0 --- /dev/null +++ b/docs/examples/guide/28543836b62b5622a402e6f7731d68f0.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.indices.downsample( + index: '.ds-my-data-stream-2023.07.26-000001', + target_index: '.ds-my-data-stream-2023.07.26-000001-downsample', + body: { + fixed_interval: '1h' + } +) +puts response +---- diff --git a/docs/examples/guide/2897ccc2a3bf3d0cd89328ee4413fae5.asciidoc b/docs/examples/guide/2897ccc2a3bf3d0cd89328ee4413fae5.asciidoc new file mode 100644 index 0000000000..f1c4802004 --- /dev/null +++ b/docs/examples/guide/2897ccc2a3bf3d0cd89328ee4413fae5.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.async_search.get( + id: 'FklQYndoTDJ2VEFlMEVBTzFJMGhJVFEaLVlKYndBWWZSMUdicUc4WVlEaFl4ZzoxNTU=' +) +puts response +---- diff --git a/docs/examples/guide/28ac880057135e46b3b00c7f3976538c.asciidoc b/docs/examples/guide/28ac880057135e46b3b00c7f3976538c.asciidoc index 13d5773085..4f5df5b79b 100644 --- a/docs/examples/guide/28ac880057135e46b3b00c7f3976538c.asciidoc +++ b/docs/examples/guide/28ac880057135e46b3b00c7f3976538c.asciidoc @@ -3,7 +3,7 @@ response = client.indices.put_settings( index: 'test', body: { - "index.routing.allocation.include._ip": '192.168.2.*' + 'index.routing.allocation.include._ip' => '192.168.2.*' } ) puts response diff --git a/docs/examples/guide/28d3bb1dbed615c6e719d50d48ab6fb4.asciidoc b/docs/examples/guide/28d3bb1dbed615c6e719d50d48ab6fb4.asciidoc deleted file mode 100644 index f72bfd4ab7..0000000000 --- a/docs/examples/guide/28d3bb1dbed615c6e719d50d48ab6fb4.asciidoc +++ /dev/null @@ -1,19 +0,0 @@ -[source, ruby] ----- -response = client.search( - body: { - query: { - regexp: { - "user.id": { - value: 'k.*y', - flags: 'ALL', - case_insensitive: true, - max_determinized_states: 10_000, - rewrite: 'constant_score' - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/2988a112b590ae2320940887125fe36a.asciidoc b/docs/examples/guide/2988a112b590ae2320940887125fe36a.asciidoc new file mode 100644 index 0000000000..b7074ac60d --- /dev/null +++ b/docs/examples/guide/2988a112b590ae2320940887125fe36a.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.esql.query( + body: { + query: 'FROM mv | EVAL b=MV_MIN(b) | EVAL b + 2, a + b | LIMIT 4', + version: '2024.04.01' + } +) +puts response +---- diff --git a/docs/examples/guide/29953082744b7a36e437b392a6391c81.asciidoc b/docs/examples/guide/29953082744b7a36e437b392a6391c81.asciidoc new file mode 100644 index 0000000000..d8b66a0146 --- /dev/null +++ b/docs/examples/guide/29953082744b7a36e437b392a6391c81.asciidoc @@ -0,0 +1,13 @@ +[source, ruby] +---- +response = client.render_search_template( + body: { + id: 'my-search-template', + params: { + from: 20, + size: 10 + } + } +) +puts response +---- diff --git a/docs/examples/guide/2a71e2d7f7179dd76183d30789046808.asciidoc b/docs/examples/guide/2a71e2d7f7179dd76183d30789046808.asciidoc new file mode 100644 index 0000000000..0abe51fb52 --- /dev/null +++ b/docs/examples/guide/2a71e2d7f7179dd76183d30789046808.asciidoc @@ -0,0 +1,27 @@ +[source, ruby] +---- +response = client.bulk( + index: 'mv', + refresh: true, + body: [ + { + index: {} + }, + { + a: 1, + b: [ + 2, + 1 + ] + }, + { + index: {} + }, + { + a: 2, + b: 3 + } + ] +) +puts response +---- diff --git a/docs/examples/guide/2a91e1fb8ad93a188fa9d77ec01bc431.asciidoc b/docs/examples/guide/2a91e1fb8ad93a188fa9d77ec01bc431.asciidoc index f8943ea937..a7b1406e87 100644 --- a/docs/examples/guide/2a91e1fb8ad93a188fa9d77ec01bc431.asciidoc +++ b/docs/examples/guide/2a91e1fb8ad93a188fa9d77ec01bc431.asciidoc @@ -42,7 +42,7 @@ response = client.search( path: 'comments', query: { match: { - "comments.number": 2 + 'comments.number' => 2 } }, inner_hits: {} diff --git a/docs/examples/guide/2afdf0d83724953aa2875b5fb37d60cc.asciidoc b/docs/examples/guide/2afdf0d83724953aa2875b5fb37d60cc.asciidoc new file mode 100644 index 0000000000..f146aeb501 --- /dev/null +++ b/docs/examples/guide/2afdf0d83724953aa2875b5fb37d60cc.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.esql.async_query_get( + id: 'FmNJRUZ1YWZCU3dHY1BIOUhaenVSRkEaaXFlZ3h4c1RTWFNocDdnY2FSaERnUTozNDE=', + wait_for_completion_timeout: '30s' +) +puts response +---- diff --git a/docs/examples/guide/2b1c560f00d9bcf5caaf56c03f6b5962.asciidoc b/docs/examples/guide/2b1c560f00d9bcf5caaf56c03f6b5962.asciidoc new file mode 100644 index 0000000000..d9089312cf --- /dev/null +++ b/docs/examples/guide/2b1c560f00d9bcf5caaf56c03f6b5962.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.sync_job_list( + job_type: 'full,incremental' +) +puts response +---- diff --git a/docs/examples/guide/2b23a0e5fc29fa57da48c50b41909951.asciidoc b/docs/examples/guide/2b23a0e5fc29fa57da48c50b41909951.asciidoc deleted file mode 100644 index f61445c101..0000000000 --- a/docs/examples/guide/2b23a0e5fc29fa57da48c50b41909951.asciidoc +++ /dev/null @@ -1,31 +0,0 @@ -[source, ruby] ----- -response = client.search( - body: { - query: { - span_near: { - clauses: [ - { - span_term: { - text: 'quick brown' - } - }, - { - span_field_masking: { - query: { - span_term: { - "text.stems": 'fox' - } - }, - field: 'text' - } - } - ], - slop: 5, - in_order: false - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/2b7687e3d7c06824950e00618c297864.asciidoc b/docs/examples/guide/2b7687e3d7c06824950e00618c297864.asciidoc new file mode 100644 index 0000000000..ae52726b49 --- /dev/null +++ b/docs/examples/guide/2b7687e3d7c06824950e00618c297864.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.indices.resolve_cluster( + name: 'my-index*,clust*:my-index*' +) +puts response +---- diff --git a/docs/examples/guide/2bb41b0b4876ce98cd0cd8fb6d337f18.asciidoc b/docs/examples/guide/2bb41b0b4876ce98cd0cd8fb6d337f18.asciidoc index da108df215..54e4427c94 100644 --- a/docs/examples/guide/2bb41b0b4876ce98cd0cd8fb6d337f18.asciidoc +++ b/docs/examples/guide/2bb41b0b4876ce98cd0cd8fb6d337f18.asciidoc @@ -3,8 +3,8 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.indices.close.enable": false, - "indices.recovery.max_bytes_per_sec": '50mb' + 'cluster.indices.close.enable' => false, + 'indices.recovery.max_bytes_per_sec' => '50mb' }, transient: { "*": nil diff --git a/docs/examples/guide/2bc1d52efec2076dc9fc2a3a2d90e8ab.asciidoc b/docs/examples/guide/2bc1d52efec2076dc9fc2a3a2d90e8ab.asciidoc new file mode 100644 index 0000000000..854c43d58b --- /dev/null +++ b/docs/examples/guide/2bc1d52efec2076dc9fc2a3a2d90e8ab.asciidoc @@ -0,0 +1,18 @@ +[source, ruby] +---- +response = client.search( + index: 'latency', + body: { + size: 0, + aggregations: { + load_time_boxplot: { + boxplot: { + field: 'load_time', + execution_hint: 'high_accuracy' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/2c1e16e9ac24cfea979af2a69900d3c2.asciidoc b/docs/examples/guide/2c1e16e9ac24cfea979af2a69900d3c2.asciidoc new file mode 100644 index 0000000000..574ab9bc24 --- /dev/null +++ b/docs/examples/guide/2c1e16e9ac24cfea979af2a69900d3c2.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.synonyms.put_synonym_rule( + set_id: 'my-synonyms-set', + rule_id: 'test-1', + body: { + synonyms: 'hello, hi, howdy' + } +) +puts response +---- diff --git a/docs/examples/guide/2c3207c0c985d253b2ecccc14e69e25a.asciidoc b/docs/examples/guide/2c3207c0c985d253b2ecccc14e69e25a.asciidoc new file mode 100644 index 0000000000..fa59cec745 --- /dev/null +++ b/docs/examples/guide/2c3207c0c985d253b2ecccc14e69e25a.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.indices.add_block( + index: '.ds-my-data-stream-2023.07.26-000001', + block: 'write' +) +puts response +---- diff --git a/docs/examples/guide/2c3dff44904d3d73ff47f1afe89c7f86.asciidoc b/docs/examples/guide/2c3dff44904d3d73ff47f1afe89c7f86.asciidoc index 9f4bfc6f90..18e0ef3c06 100644 --- a/docs/examples/guide/2c3dff44904d3d73ff47f1afe89c7f86.asciidoc +++ b/docs/examples/guide/2c3dff44904d3d73ff47f1afe89c7f86.asciidoc @@ -5,7 +5,7 @@ response = client.update_by_query( body: { query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, max_docs: 1 diff --git a/docs/examples/guide/2da48241cfc21d2c57dc970845470bda.asciidoc b/docs/examples/guide/2da48241cfc21d2c57dc970845470bda.asciidoc deleted file mode 100644 index 54e0e3e418..0000000000 --- a/docs/examples/guide/2da48241cfc21d2c57dc970845470bda.asciidoc +++ /dev/null @@ -1,46 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'my-index-000001', - body: { - mappings: { - properties: { - metrics: { - type: 'object', - subobjects: false - } - } - } - } -) -puts response - -response = client.index( - index: 'my-index-000001', - id: 'metric_1', - body: { - "metrics.time": 100, - "metrics.time.min": 10, - "metrics.time.max": 900 - } -) -puts response - -response = client.index( - index: 'my-index-000001', - id: 'metric_2', - body: { - metrics: { - time: 100, - "time.min": 10, - "time.max": 900 - } - } -) -puts response - -response = client.indices.get_mapping( - index: 'my-index-000001' -) -puts response ----- diff --git a/docs/examples/guide/2dad2b0c8ba503228f4b11cecca0b348.asciidoc b/docs/examples/guide/2dad2b0c8ba503228f4b11cecca0b348.asciidoc new file mode 100644 index 0000000000..dcb81b2791 --- /dev/null +++ b/docs/examples/guide/2dad2b0c8ba503228f4b11cecca0b348.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.indices.put_data_lifecycle( + name: 'dsl-data-stream', + body: { + data_retention: '7d' + } +) +puts response +---- diff --git a/docs/examples/guide/2e3d1b293da93f2a9ecfc26786ec28d6.asciidoc b/docs/examples/guide/2e3d1b293da93f2a9ecfc26786ec28d6.asciidoc new file mode 100644 index 0000000000..b86c696ba7 --- /dev/null +++ b/docs/examples/guide/2e3d1b293da93f2a9ecfc26786ec28d6.asciidoc @@ -0,0 +1,155 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'my-data-stream-template', + body: { + index_patterns: [ + 'my-data-stream*' + ], + data_stream: {}, + template: { + settings: { + index: { + mode: 'time_series', + routing_path: [ + 'kubernetes.namespace', + 'kubernetes.host', + 'kubernetes.node', + 'kubernetes.pod' + ], + number_of_replicas: 0, + number_of_shards: 2 + } + }, + mappings: { + properties: { + "@timestamp": { + type: 'date' + }, + kubernetes: { + properties: { + container: { + properties: { + cpu: { + properties: { + usage: { + properties: { + core: { + properties: { + ns: { + type: 'long' + } + } + }, + limit: { + properties: { + pct: { + type: 'float' + } + } + }, + nanocores: { + type: 'long', + time_series_metric: 'gauge' + }, + node: { + properties: { + pct: { + type: 'float' + } + } + } + } + } + } + }, + memory: { + properties: { + available: { + properties: { + bytes: { + type: 'long', + time_series_metric: 'gauge' + } + } + }, + majorpagefaults: { + type: 'long' + }, + pagefaults: { + type: 'long', + time_series_metric: 'gauge' + }, + rss: { + properties: { + bytes: { + type: 'long', + time_series_metric: 'gauge' + } + } + }, + usage: { + properties: { + bytes: { + type: 'long', + time_series_metric: 'gauge' + }, + limit: { + properties: { + pct: { + type: 'float' + } + } + }, + node: { + properties: { + pct: { + type: 'float' + } + } + } + } + }, + workingset: { + properties: { + bytes: { + type: 'long', + time_series_metric: 'gauge' + } + } + } + } + }, + name: { + type: 'keyword' + }, + start_time: { + type: 'date' + } + } + }, + host: { + type: 'keyword', + time_series_dimension: true + }, + namespace: { + type: 'keyword', + time_series_dimension: true + }, + node: { + type: 'keyword', + time_series_dimension: true + }, + pod: { + type: 'keyword', + time_series_dimension: true + } + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/2e796e5ca59768d4426abbf9a049db3e.asciidoc b/docs/examples/guide/2e796e5ca59768d4426abbf9a049db3e.asciidoc index 797f96de6a..c83ca430f7 100644 --- a/docs/examples/guide/2e796e5ca59768d4426abbf9a049db3e.asciidoc +++ b/docs/examples/guide/2e796e5ca59768d4426abbf9a049db3e.asciidoc @@ -5,7 +5,7 @@ response = client.indices.split( target: 'my_target_index', body: { settings: { - "index.number_of_shards": 2 + 'index.number_of_shards' => 2 } } ) diff --git a/docs/examples/guide/2e93eaaebf75fa4a2451e8a76ffa9f20.asciidoc b/docs/examples/guide/2e93eaaebf75fa4a2451e8a76ffa9f20.asciidoc new file mode 100644 index 0000000000..5588366d70 --- /dev/null +++ b/docs/examples/guide/2e93eaaebf75fa4a2451e8a76ffa9f20.asciidoc @@ -0,0 +1,23 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'my-data-stream-template', + body: { + index_patterns: [ + 'my-data-stream*' + ], + data_stream: {}, + priority: 500, + template: { + mappings: { + properties: { + message: { + type: 'text' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/2ebcdd00ccbf26b4c8e6d9c80dfb3d55.asciidoc b/docs/examples/guide/2ebcdd00ccbf26b4c8e6d9c80dfb3d55.asciidoc new file mode 100644 index 0000000000..f6b8216d96 --- /dev/null +++ b/docs/examples/guide/2ebcdd00ccbf26b4c8e6d9c80dfb3d55.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'linestring', + coordinates: [ + [ + -377.03653, + 389.897676 + ], + [ + -377.009051, + 389.889939 + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/2f07b81fd47ec3b074242a760f0c4e9e.asciidoc b/docs/examples/guide/2f07b81fd47ec3b074242a760f0c4e9e.asciidoc new file mode 100644 index 0000000000..bc4166eea6 --- /dev/null +++ b/docs/examples/guide/2f07b81fd47ec3b074242a760f0c4e9e.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.indices.put_settings( + index: 'my-index-000001', + body: { + 'index.indexing.slowlog.include.user' => true + } +) +puts response +---- diff --git a/docs/examples/guide/2f4a55dfeba8851b306ef9c1b216ef54.asciidoc b/docs/examples/guide/2f4a55dfeba8851b306ef9c1b216ef54.asciidoc index da26a701e8..a0314d9bd2 100644 --- a/docs/examples/guide/2f4a55dfeba8851b306ef9c1b216ef54.asciidoc +++ b/docs/examples/guide/2f4a55dfeba8851b306ef9c1b216ef54.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { term: { - "labels.release": 'v1.3.0' + 'labels.release' => 'v1.3.0' } } } diff --git a/docs/examples/guide/2f67db5e4d6c958258c3d70fb2d0b1c8.asciidoc b/docs/examples/guide/2f67db5e4d6c958258c3d70fb2d0b1c8.asciidoc index a0a7aba7cb..1e58a61ba4 100644 --- a/docs/examples/guide/2f67db5e4d6c958258c3d70fb2d0b1c8.asciidoc +++ b/docs/examples/guide/2f67db5e4d6c958258c3d70fb2d0b1c8.asciidoc @@ -3,7 +3,7 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { - "index.merge.policy.max_merge_at_once_explicit": nil + 'index.merge.policy.max_merge_at_once_explicit' => nil } ) puts response diff --git a/docs/examples/guide/2fa45d74ba9933188c4728f8a9e5372c.asciidoc b/docs/examples/guide/2fa45d74ba9933188c4728f8a9e5372c.asciidoc index 2ab87edf47..d45f7c2a0b 100644 --- a/docs/examples/guide/2fa45d74ba9933188c4728f8a9e5372c.asciidoc +++ b/docs/examples/guide/2fa45d74ba9933188c4728f8a9e5372c.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "action.auto_create_index": 'my-index-000001,index10,-index1*,+ind*' + 'action.auto_create_index' => 'my-index-000001,index10,-index1*,+ind*' } } ) @@ -12,7 +12,7 @@ puts response response = client.cluster.put_settings( body: { persistent: { - "action.auto_create_index": 'false' + 'action.auto_create_index' => 'false' } } ) @@ -21,7 +21,7 @@ puts response response = client.cluster.put_settings( body: { persistent: { - "action.auto_create_index": 'true' + 'action.auto_create_index' => 'true' } } ) diff --git a/docs/examples/guide/3182f26c61fbe5cf89400804533d5ed2.asciidoc b/docs/examples/guide/3182f26c61fbe5cf89400804533d5ed2.asciidoc new file mode 100644 index 0000000000..d2440332ca --- /dev/null +++ b/docs/examples/guide/3182f26c61fbe5cf89400804533d5ed2.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.render_search_template( + body: { + id: 'my-search-template', + params: { + query_string: 'My string', + text_fields: [ + { + user_name: 'John' + }, + { + user_name: 'kimchy' + } + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/318e209cc4d6f306e65cb2f5598a50b1.asciidoc b/docs/examples/guide/318e209cc4d6f306e65cb2f5598a50b1.asciidoc new file mode 100644 index 0000000000..5a85aab9fa --- /dev/null +++ b/docs/examples/guide/318e209cc4d6f306e65cb2f5598a50b1.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'LineString', + coordinates: [ + [ + -77.03653, + 38.897676 + ], + [ + -77.009051, + 38.889939 + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/31a79a57b242713edec6795599ba0d5d.asciidoc b/docs/examples/guide/31a79a57b242713edec6795599ba0d5d.asciidoc new file mode 100644 index 0000000000..1c42569f31 --- /dev/null +++ b/docs/examples/guide/31a79a57b242713edec6795599ba0d5d.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index', + body: { + mappings: { + properties: { + my_tokens: { + type: 'sparse_vector' + }, + my_text_field: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/32123981430e5a8b34fe14314fc48429.asciidoc b/docs/examples/guide/32123981430e5a8b34fe14314fc48429.asciidoc index 358af7b653..c280bf0245 100644 --- a/docs/examples/guide/32123981430e5a8b34fe14314fc48429.asciidoc +++ b/docs/examples/guide/32123981430e5a8b34fe14314fc48429.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/32a7acdfb7046966b28f394476c99126.asciidoc b/docs/examples/guide/32a7acdfb7046966b28f394476c99126.asciidoc new file mode 100644 index 0000000000..a6c171f4ad --- /dev/null +++ b/docs/examples/guide/32a7acdfb7046966b28f394476c99126.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'POINT (-377.03653 389.897676)' + } +) +puts response +---- diff --git a/docs/examples/guide/32de5dd306bd014d67053d2f175defcd.asciidoc b/docs/examples/guide/32de5dd306bd014d67053d2f175defcd.asciidoc index bdcfeff455..9639af9996 100644 --- a/docs/examples/guide/32de5dd306bd014d67053d2f175defcd.asciidoc +++ b/docs/examples/guide/32de5dd306bd014d67053d2f175defcd.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "logger.org.elasticsearch.xpack.security.authc.saml": 'debug' + 'logger.org.elasticsearch.xpack.security.authc.saml' => 'debug' } } ) diff --git a/docs/examples/guide/33732208fc6e6fe1e8d278299681932e.asciidoc b/docs/examples/guide/33732208fc6e6fe1e8d278299681932e.asciidoc new file mode 100644 index 0000000000..47d77f24bc --- /dev/null +++ b/docs/examples/guide/33732208fc6e6fe1e8d278299681932e.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'LINESTRING (-377.03653 389.897676, -377.009051 389.889939)' + } +) +puts response +---- diff --git a/docs/examples/guide/3386fe07e90844dbcdbbe7c07f09e04a.asciidoc b/docs/examples/guide/3386fe07e90844dbcdbbe7c07f09e04a.asciidoc new file mode 100644 index 0000000000..37570408e0 --- /dev/null +++ b/docs/examples/guide/3386fe07e90844dbcdbbe7c07f09e04a.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.synonyms.delete_synonym( + id: 'my-synonyms-set' +) +puts response +---- diff --git a/docs/examples/guide/33d480fc6812ada75756cf5337bc9092.asciidoc b/docs/examples/guide/33d480fc6812ada75756cf5337bc9092.asciidoc new file mode 100644 index 0000000000..0c4a9213ef --- /dev/null +++ b/docs/examples/guide/33d480fc6812ada75756cf5337bc9092.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.connector.sync_job_list( + from: 0, + size: 2 +) +puts response +---- diff --git a/docs/examples/guide/342ddf9121aeddd82fea2464665e25da.asciidoc b/docs/examples/guide/342ddf9121aeddd82fea2464665e25da.asciidoc new file mode 100644 index 0000000000..974b1eb6e5 --- /dev/null +++ b/docs/examples/guide/342ddf9121aeddd82fea2464665e25da.asciidoc @@ -0,0 +1,12 @@ +[source, ruby] +---- +response = client.connector.put( + connector_id: 'my-connector', + body: { + index_name: 'search-google-drive', + name: 'My Connector', + service_type: 'google_drive' + } +) +puts response +---- diff --git a/docs/examples/guide/34c5cd33ba371fb79a793baf9f6e9fad.asciidoc b/docs/examples/guide/34c5cd33ba371fb79a793baf9f6e9fad.asciidoc new file mode 100644 index 0000000000..b661b1af88 --- /dev/null +++ b/docs/examples/guide/34c5cd33ba371fb79a793baf9f6e9fad.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + query: { + text_expansion: { + my_tokens: { + model_id: '.elser_model_2', + model_text: 'the query string' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/34cdeefb09bbbe5206957a8bc1bd513d.asciidoc b/docs/examples/guide/34cdeefb09bbbe5206957a8bc1bd513d.asciidoc new file mode 100644 index 0000000000..fdf9888c07 --- /dev/null +++ b/docs/examples/guide/34cdeefb09bbbe5206957a8bc1bd513d.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.indices.put_settings( + index: 'my-index-000001', + body: { + 'index.search.slowlog.include.user' => true + } +) +puts response +---- diff --git a/docs/examples/guide/34d51c54b62e9a160c0ddacc10134bb0.asciidoc b/docs/examples/guide/34d51c54b62e9a160c0ddacc10134bb0.asciidoc index 6377f0f014..235589b2ca 100644 --- a/docs/examples/guide/34d51c54b62e9a160c0ddacc10134bb0.asciidoc +++ b/docs/examples/guide/34d51c54b62e9a160c0ddacc10134bb0.asciidoc @@ -6,7 +6,7 @@ response = client.search( span_first: { match: { span_term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, end: 3 diff --git a/docs/examples/guide/34d63740b58209a3d031212909743925.asciidoc b/docs/examples/guide/34d63740b58209a3d031212909743925.asciidoc new file mode 100644 index 0000000000..ae713fef54 --- /dev/null +++ b/docs/examples/guide/34d63740b58209a3d031212909743925.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.search( + index: 'openai-embeddings', + body: { + knn: { + field: 'content_embedding', + query_vector_builder: { + text_embedding: { + model_id: 'openai_embeddings', + model_text: 'Calculate fuel cost' + } + }, + k: 10, + num_candidates: 100 + }, + _source: [ + 'id', + 'content' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/357edc9d10e98ed776401c7a439a1a55.asciidoc b/docs/examples/guide/357edc9d10e98ed776401c7a439a1a55.asciidoc new file mode 100644 index 0000000000..3b7da07c1a --- /dev/null +++ b/docs/examples/guide/357edc9d10e98ed776401c7a439a1a55.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.indices.resolve_cluster( + name: 'not-present,clust*:my-index*,oldcluster:*', + ignore_unavailable: false +) +puts response +---- diff --git a/docs/examples/guide/35f892b475a1770f18328158be7039fd.asciidoc b/docs/examples/guide/35f892b475a1770f18328158be7039fd.asciidoc new file mode 100644 index 0000000000..c4bdfd9750 --- /dev/null +++ b/docs/examples/guide/35f892b475a1770f18328158be7039fd.asciidoc @@ -0,0 +1,18 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index-2', + body: { + mappings: { + properties: { + my_vector: { + type: 'dense_vector', + dims: 3, + similarity: 'dot_product' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/360b3cef34bbddc5d9579ca95f0cb061.asciidoc b/docs/examples/guide/360b3cef34bbddc5d9579ca95f0cb061.asciidoc new file mode 100644 index 0000000000..ea8c543dfd --- /dev/null +++ b/docs/examples/guide/360b3cef34bbddc5d9579ca95f0cb061.asciidoc @@ -0,0 +1,15 @@ +[source, ruby] +---- +response = client.indices.put_mapping( + index: 'my-data-stream', + write_index_only: true, + body: { + properties: { + message: { + type: 'text' + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/362dfccdb6f7933b22c909542e0b4e0a.asciidoc b/docs/examples/guide/362dfccdb6f7933b22c909542e0b4e0a.asciidoc index 65ba88d31a..6fc6004a03 100644 --- a/docs/examples/guide/362dfccdb6f7933b22c909542e0b4e0a.asciidoc +++ b/docs/examples/guide/362dfccdb6f7933b22c909542e0b4e0a.asciidoc @@ -5,7 +5,7 @@ response = client.update_by_query( body: { query: { match: { - "user.id": 'l7gk7f82' + 'user.id' => 'l7gk7f82' } }, script: { diff --git a/docs/examples/guide/365256ebdfa47b449780771d9beba8d9.asciidoc b/docs/examples/guide/365256ebdfa47b449780771d9beba8d9.asciidoc new file mode 100644 index 0000000000..4953bdb2e7 --- /dev/null +++ b/docs/examples/guide/365256ebdfa47b449780771d9beba8d9.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.sync_job_check_in( + connector_sync_job_id: 'my-connector-sync-job' +) +puts response +---- diff --git a/docs/examples/guide/36b86b97feedcf5632824eefc251d6ed.asciidoc b/docs/examples/guide/36b86b97feedcf5632824eefc251d6ed.asciidoc new file mode 100644 index 0000000000..0147fe261d --- /dev/null +++ b/docs/examples/guide/36b86b97feedcf5632824eefc251d6ed.asciidoc @@ -0,0 +1,14 @@ +[source, ruby] +---- +response = client.search( + index: 'books', + body: { + query: { + match: { + name: 'brave' + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/370b297ed3433577adf53e64f572d89d.asciidoc b/docs/examples/guide/370b297ed3433577adf53e64f572d89d.asciidoc new file mode 100644 index 0000000000..fdf6818555 --- /dev/null +++ b/docs/examples/guide/370b297ed3433577adf53e64f572d89d.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.sync_job_delete( + connector_sync_job_id: 'my-connector-sync-job-id' +) +puts response +---- diff --git a/docs/examples/guide/376ff4b2b5f657481af78a778aaab57f.asciidoc b/docs/examples/guide/376ff4b2b5f657481af78a778aaab57f.asciidoc new file mode 100644 index 0000000000..ebb19baedf --- /dev/null +++ b/docs/examples/guide/376ff4b2b5f657481af78a778aaab57f.asciidoc @@ -0,0 +1,75 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index', + body: { + mappings: { + properties: { + nr: { + type: 'integer' + }, + state: { + type: 'keyword' + } + } + } + } +) +puts response + +response = client.bulk( + index: 'my-index', + refresh: true, + body: [ + { + index: {} + }, + { + nr: 1, + state: 'started' + }, + { + index: {} + }, + { + nr: 2, + state: 'stopped' + }, + { + index: {} + }, + { + nr: 3, + state: 'N/A' + }, + { + index: {} + }, + { + nr: 4 + } + ] +) +puts response + +response = client.search( + index: 'my-index', + filter_path: 'aggregations', + body: { + aggregations: { + my_top_metrics: { + top_metrics: { + metrics: { + field: 'state', + missing: 'N/A' + }, + sort: { + nr: 'desc' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/377af0ea9b19c113f224d8150890b41b.asciidoc b/docs/examples/guide/377af0ea9b19c113f224d8150890b41b.asciidoc index 383aaf0032..cf052c9bc5 100644 --- a/docs/examples/guide/377af0ea9b19c113f224d8150890b41b.asciidoc +++ b/docs/examples/guide/377af0ea9b19c113f224d8150890b41b.asciidoc @@ -7,7 +7,7 @@ response = client.search( filter: [ { term: { - "event.outcome": 'failure' + 'event.outcome' => 'failure' } }, { @@ -20,7 +20,7 @@ response = client.search( }, { term: { - "service.name": { + 'service.name' => { value: 'frontend-node' } } @@ -37,7 +37,7 @@ response = client.search( must_not: [ { term: { - "event.outcome": 'failure' + 'event.outcome' => 'failure' } } ], @@ -52,7 +52,7 @@ response = client.search( }, { term: { - "service.name": { + 'service.name' => { value: 'frontend-node' } } diff --git a/docs/examples/guide/388ec2b038d3ad69378f4c2e5bc36dce.asciidoc b/docs/examples/guide/388ec2b038d3ad69378f4c2e5bc36dce.asciidoc new file mode 100644 index 0000000000..3ac6f22168 --- /dev/null +++ b/docs/examples/guide/388ec2b038d3ad69378f4c2e5bc36dce.asciidoc @@ -0,0 +1,37 @@ +[source, ruby] +---- +response = client.search( + body: { + query: { + span_near: { + clauses: [ + { + span_term: { + text: 'quick brown' + } + }, + { + span_field_masking: { + query: { + span_term: { + 'text.stems' => 'fox' + } + }, + field: 'text' + } + } + ], + slop: 5, + in_order: false + } + }, + highlight: { + require_field_match: false, + fields: { + "*": {} + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/39ce44333d28ed2b833722d3e3cb06f3.asciidoc b/docs/examples/guide/39ce44333d28ed2b833722d3e3cb06f3.asciidoc index 781a12134d..c176e1e0ea 100644 --- a/docs/examples/guide/39ce44333d28ed2b833722d3e3cb06f3.asciidoc +++ b/docs/examples/guide/39ce44333d28ed2b833722d3e3cb06f3.asciidoc @@ -8,7 +8,7 @@ response = client.search( should: [ { match: { - "name.first": { + 'name.first' => { query: 'shay', _name: 'first' } @@ -16,7 +16,7 @@ response = client.search( }, { match: { - "name.last": { + 'name.last' => { query: 'banon', _name: 'last' } @@ -25,7 +25,7 @@ response = client.search( ], filter: { terms: { - "name.last": [ + 'name.last' => [ 'banon', 'kimchy' ], diff --git a/docs/examples/guide/3a2953fd81d65118a776c87a81530e15.asciidoc b/docs/examples/guide/3a2953fd81d65118a776c87a81530e15.asciidoc index 53a66bc9f3..9e22c4ef00 100644 --- a/docs/examples/guide/3a2953fd81d65118a776c87a81530e15.asciidoc +++ b/docs/examples/guide/3a2953fd81d65118a776c87a81530e15.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { diff --git a/docs/examples/guide/3a3adae6dbb2c0316a7d98d0a6c1d4f8.asciidoc b/docs/examples/guide/3a3adae6dbb2c0316a7d98d0a6c1d4f8.asciidoc new file mode 100644 index 0000000000..24486d9f05 --- /dev/null +++ b/docs/examples/guide/3a3adae6dbb2c0316a7d98d0a6c1d4f8.asciidoc @@ -0,0 +1,42 @@ +[source, ruby] +---- +response = client.search( + index: 'quantized-image-index', + body: { + knn: { + field: 'image-vector', + query_vector: [ + 0.1, + -2 + ], + k: 15, + num_candidates: 100 + }, + fields: [ + 'title' + ], + rescore: { + window_size: 10, + query: { + rescore_query: { + script_score: { + query: { + match_all: {} + }, + script: { + source: "cosineSimilarity(params.query_vector, 'image-vector') + 1.0", + params: { + query_vector: [ + 0.1, + -2 + ] + } + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/3a64ae799cc03fadbb802794730c23da.asciidoc b/docs/examples/guide/3a64ae799cc03fadbb802794730c23da.asciidoc new file mode 100644 index 0000000000..eeb701b7b9 --- /dev/null +++ b/docs/examples/guide/3a64ae799cc03fadbb802794730c23da.asciidoc @@ -0,0 +1,30 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'example_points', + body: { + mappings: { + properties: { + location: { + type: 'geo_point' + } + } + } + } +) +puts response + +response = client.index( + index: 'example_points', + id: 1, + refresh: true, + body: { + name: 'Wind & Wetter, Berlin, Germany', + location: [ + 13.400544, + 52.530286 + ] + } +) +puts response +---- diff --git a/docs/examples/guide/3a7a6ab88a49b484fafb10c8eb09b562.asciidoc b/docs/examples/guide/3a7a6ab88a49b484fafb10c8eb09b562.asciidoc new file mode 100644 index 0000000000..5d641117d6 --- /dev/null +++ b/docs/examples/guide/3a7a6ab88a49b484fafb10c8eb09b562.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.ingest.put_pipeline( + id: 'cohere_embeddings', + body: { + processors: [ + { + inference: { + model_id: 'cohere_embeddings', + input_output: { + input_field: 'content', + output_field: 'content_embedding' + } + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/3af10fde8138d9d95df127d39d9a0ed2.asciidoc b/docs/examples/guide/3af10fde8138d9d95df127d39d9a0ed2.asciidoc index 220c95b658..d210a4ddb9 100644 --- a/docs/examples/guide/3af10fde8138d9d95df127d39d9a0ed2.asciidoc +++ b/docs/examples/guide/3af10fde8138d9d95df127d39d9a0ed2.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.max_shards_per_node": nil + 'cluster.max_shards_per_node' => nil } } ) diff --git a/docs/examples/guide/3afc6dacf90b42900ab571aad8a61d75.asciidoc b/docs/examples/guide/3afc6dacf90b42900ab571aad8a61d75.asciidoc new file mode 100644 index 0000000000..6d5393c31c --- /dev/null +++ b/docs/examples/guide/3afc6dacf90b42900ab571aad8a61d75.asciidoc @@ -0,0 +1,41 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'serbian_example', + body: { + settings: { + analysis: { + filter: { + serbian_stop: { + type: 'stop', + stopwords: '_serbian_' + }, + serbian_keywords: { + type: 'keyword_marker', + keywords: [ + 'пример' + ] + }, + serbian_stemmer: { + type: 'stemmer', + language: 'serbian' + } + }, + analyzer: { + rebuilt_serbian: { + tokenizer: 'standard', + filter: [ + 'lowercase', + 'serbian_stop', + 'serbian_keywords', + 'serbian_stemmer', + 'serbian_normalization' + ] + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/3c09ca91057216125ed0e3856a91ff95.asciidoc b/docs/examples/guide/3c09ca91057216125ed0e3856a91ff95.asciidoc index 0fed35d95d..fccfbc1f18 100644 --- a/docs/examples/guide/3c09ca91057216125ed0e3856a91ff95.asciidoc +++ b/docs/examples/guide/3c09ca91057216125ed0e3856a91ff95.asciidoc @@ -14,7 +14,7 @@ response = client.indices.put_index_template( number_of_replicas: 0, number_of_shards: 2 }, - "index.lifecycle.name": 'datastream_policy' + 'index.lifecycle.name' => 'datastream_policy' }, mappings: { properties: { diff --git a/docs/examples/guide/3c65cb58e131ef46f4dd081683b970ac.asciidoc b/docs/examples/guide/3c65cb58e131ef46f4dd081683b970ac.asciidoc index 492cae3168..5245ec03a8 100644 --- a/docs/examples/guide/3c65cb58e131ef46f4dd081683b970ac.asciidoc +++ b/docs/examples/guide/3c65cb58e131ef46f4dd081683b970ac.asciidoc @@ -11,7 +11,7 @@ response = client.search( filter: { geo_distance: { distance: '200km', - "pin.location": { + 'pin.location' => { lat: 40, lon: -70 } diff --git a/docs/examples/guide/3c7621a81fa982b79f040a6d2611530e.asciidoc b/docs/examples/guide/3c7621a81fa982b79f040a6d2611530e.asciidoc index 907746d154..957167898f 100644 --- a/docs/examples/guide/3c7621a81fa982b79f040a6d2611530e.asciidoc +++ b/docs/examples/guide/3c7621a81fa982b79f040a6d2611530e.asciidoc @@ -5,7 +5,7 @@ response = client.cluster.put_component_template( body: { template: { settings: { - "index.number_of_shards": 2 + 'index.number_of_shards' => 2 } } } @@ -17,7 +17,7 @@ response = client.cluster.put_component_template( body: { template: { settings: { - "index.number_of_replicas": 0 + 'index.number_of_replicas' => 0 }, mappings: { properties: { diff --git a/docs/examples/guide/3d1ff6097e2359f927c88c2ccdb36252.asciidoc b/docs/examples/guide/3d1ff6097e2359f927c88c2ccdb36252.asciidoc new file mode 100644 index 0000000000..e6a88d209d --- /dev/null +++ b/docs/examples/guide/3d1ff6097e2359f927c88c2ccdb36252.asciidoc @@ -0,0 +1,5 @@ +[source, ruby] +---- +response = client.info +puts response +---- diff --git a/docs/examples/guide/3da35090e093c2d83c3b7d0d83bcb4ae.asciidoc b/docs/examples/guide/3da35090e093c2d83c3b7d0d83bcb4ae.asciidoc index 795cd59958..f0e63d9178 100644 --- a/docs/examples/guide/3da35090e093c2d83c3b7d0d83bcb4ae.asciidoc +++ b/docs/examples/guide/3da35090e093c2d83c3b7d0d83bcb4ae.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.exclude._name": 'target-node-name' + 'cluster.routing.allocation.exclude._name' => 'target-node-name' } } ) diff --git a/docs/examples/guide/3e278e6c193b4c17dbdc70670e15d78c.asciidoc b/docs/examples/guide/3e278e6c193b4c17dbdc70670e15d78c.asciidoc index c34882e1b8..cf8694d9f2 100644 --- a/docs/examples/guide/3e278e6c193b4c17dbdc70670e15d78c.asciidoc +++ b/docs/examples/guide/3e278e6c193b4c17dbdc70670e15d78c.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { diff --git a/docs/examples/guide/3e4227250d49e81df48773f8ba803ea7.asciidoc b/docs/examples/guide/3e4227250d49e81df48773f8ba803ea7.asciidoc new file mode 100644 index 0000000000..b1a1e477b1 --- /dev/null +++ b/docs/examples/guide/3e4227250d49e81df48773f8ba803ea7.asciidoc @@ -0,0 +1,14 @@ +[source, ruby] +---- +response = client.indices.put_mapping( + index: 'my-data-stream', + body: { + properties: { + message: { + type: 'text' + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/3e6db3d80439c2c176dbd1bb1296b6cf.asciidoc b/docs/examples/guide/3e6db3d80439c2c176dbd1bb1296b6cf.asciidoc new file mode 100644 index 0000000000..f08535c752 --- /dev/null +++ b/docs/examples/guide/3e6db3d80439c2c176dbd1bb1296b6cf.asciidoc @@ -0,0 +1,12 @@ +[source, ruby] +---- +response = client.render_search_template( + body: { + id: 'my-search-template', + params: { + query_string: 'hello world' + } + } +) +puts response +---- diff --git a/docs/examples/guide/3ed39eb60fbfafb70f7825b8d103bf17.asciidoc b/docs/examples/guide/3ed39eb60fbfafb70f7825b8d103bf17.asciidoc index b7681145db..1676fd538e 100644 --- a/docs/examples/guide/3ed39eb60fbfafb70f7825b8d103bf17.asciidoc +++ b/docs/examples/guide/3ed39eb60fbfafb70f7825b8d103bf17.asciidoc @@ -11,7 +11,7 @@ response = client.search( filter: { geo_distance: { distance: '200km', - "pin.location": { + 'pin.location' => { lat: 40, lon: -70 } diff --git a/docs/examples/guide/3f3b3e207f79303ce6f86e03e928e062.asciidoc b/docs/examples/guide/3f3b3e207f79303ce6f86e03e928e062.asciidoc deleted file mode 100644 index 26796258c2..0000000000 --- a/docs/examples/guide/3f3b3e207f79303ce6f86e03e928e062.asciidoc +++ /dev/null @@ -1,8 +0,0 @@ -[source, ruby] ----- -response = client.get( - index: 'customer', - id: 1 -) -puts response ----- diff --git a/docs/examples/guide/3fb2f41ad229a31ad3ae408cc50cbed5.asciidoc b/docs/examples/guide/3fb2f41ad229a31ad3ae408cc50cbed5.asciidoc index b42cd912db..6e3527fee3 100644 --- a/docs/examples/guide/3fb2f41ad229a31ad3ae408cc50cbed5.asciidoc +++ b/docs/examples/guide/3fb2f41ad229a31ad3ae408cc50cbed5.asciidoc @@ -6,7 +6,7 @@ response = client.search( timeout: '2s', query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/4053de806dfd9172167999ce098107c4.asciidoc b/docs/examples/guide/4053de806dfd9172167999ce098107c4.asciidoc index a62f9aa2f6..32fab044ee 100644 --- a/docs/examples/guide/4053de806dfd9172167999ce098107c4.asciidoc +++ b/docs/examples/guide/4053de806dfd9172167999ce098107c4.asciidoc @@ -6,7 +6,7 @@ response = client.search( constant_score: { filter: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, boost: 1.2 diff --git a/docs/examples/guide/405511f7c1f12cc0a227b4563fe7b2e2.asciidoc b/docs/examples/guide/405511f7c1f12cc0a227b4563fe7b2e2.asciidoc new file mode 100644 index 0000000000..a8873e82b4 --- /dev/null +++ b/docs/examples/guide/405511f7c1f12cc0a227b4563fe7b2e2.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.esql.async_query_get( + id: 'FkpMRkJGS1gzVDRlM3g4ZzMyRGlLbkEaTXlJZHdNT09TU2VTZVBoNDM3cFZMUToxMDM=' +) +puts response +---- diff --git a/docs/examples/guide/405ac843a9156d3cab374e199cac87fb.asciidoc b/docs/examples/guide/405ac843a9156d3cab374e199cac87fb.asciidoc new file mode 100644 index 0000000000..14e1ae08cf --- /dev/null +++ b/docs/examples/guide/405ac843a9156d3cab374e199cac87fb.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.connector.sync_job_post( + body: { + id: 'connector-id', + job_type: 'full', + trigger_method: 'on_demand' + } +) +puts response +---- diff --git a/docs/examples/guide/41175d304e660da2931764f9a4418fd3.asciidoc b/docs/examples/guide/41175d304e660da2931764f9a4418fd3.asciidoc new file mode 100644 index 0000000000..4ea20b6a83 --- /dev/null +++ b/docs/examples/guide/41175d304e660da2931764f9a4418fd3.asciidoc @@ -0,0 +1,15 @@ +[source, ruby] +---- +response = client.connector.update_pipeline( + connector_id: 'my-connector', + body: { + pipeline: { + extract_binary_content: true, + name: 'my-connector-pipeline', + reduce_whitespace: true, + run_ml_inference: true + } + } +) +puts response +---- diff --git a/docs/examples/guide/416a3ba11232d3c078c1c31340cf356f.asciidoc b/docs/examples/guide/416a3ba11232d3c078c1c31340cf356f.asciidoc index cf39499999..3861cb273c 100644 --- a/docs/examples/guide/416a3ba11232d3c078c1c31340cf356f.asciidoc +++ b/docs/examples/guide/416a3ba11232d3c078c1c31340cf356f.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { diff --git a/docs/examples/guide/4207219a892339e8f3abe0df8723dd27.asciidoc b/docs/examples/guide/4207219a892339e8f3abe0df8723dd27.asciidoc index 94da51c2a4..0a4f6fda0e 100644 --- a/docs/examples/guide/4207219a892339e8f3abe0df8723dd27.asciidoc +++ b/docs/examples/guide/4207219a892339e8f3abe0df8723dd27.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.metadata.administrator": 'sysadmin@example.com' + 'cluster.metadata.administrator' => 'sysadmin@example.com' } } ) diff --git a/docs/examples/guide/42ba7c1d13aee91fe6f0a8a42c30eb74.asciidoc b/docs/examples/guide/42ba7c1d13aee91fe6f0a8a42c30eb74.asciidoc new file mode 100644 index 0000000000..0fa4e9159d --- /dev/null +++ b/docs/examples/guide/42ba7c1d13aee91fe6f0a8a42c30eb74.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.indices.rollover( + alias: 'my-data-stream', + lazy: true +) +puts response +---- diff --git a/docs/examples/guide/430705509f8367aef92be413f702520b.asciidoc b/docs/examples/guide/430705509f8367aef92be413f702520b.asciidoc new file mode 100644 index 0000000000..50cefc667e --- /dev/null +++ b/docs/examples/guide/430705509f8367aef92be413f702520b.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.connector.update_status( + connector_id: 'my-connector', + body: { + status: 'needs_configuration' + } +) +puts response +---- diff --git a/docs/examples/guide/435e0d6a7d86e074d572d9671b7b9676.asciidoc b/docs/examples/guide/435e0d6a7d86e074d572d9671b7b9676.asciidoc new file mode 100644 index 0000000000..7599f6105f --- /dev/null +++ b/docs/examples/guide/435e0d6a7d86e074d572d9671b7b9676.asciidoc @@ -0,0 +1,36 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'Polygon', + coordinates: [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/43854be6aae61edbea5f9ab988cb4ce5.asciidoc b/docs/examples/guide/43854be6aae61edbea5f9ab988cb4ce5.asciidoc index 59f9be4c4a..d870920056 100644 --- a/docs/examples/guide/43854be6aae61edbea5f9ab988cb4ce5.asciidoc +++ b/docs/examples/guide/43854be6aae61edbea5f9ab988cb4ce5.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "xpack.security.transport.filter.allow": '172.16.0.0/24' + 'xpack.security.transport.filter.allow' => '172.16.0.0/24' } } ) diff --git a/docs/examples/guide/43e86fbaeed068dcc981214338559b5a.asciidoc b/docs/examples/guide/43e86fbaeed068dcc981214338559b5a.asciidoc new file mode 100644 index 0000000000..ae3738c9fe --- /dev/null +++ b/docs/examples/guide/43e86fbaeed068dcc981214338559b5a.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.indices.resolve_cluster( + name: 'my-index-*,cluster*:my-index-*' +) +puts response +---- diff --git a/docs/examples/guide/4435b654994b575ba181ea679871c78c.asciidoc b/docs/examples/guide/4435b654994b575ba181ea679871c78c.asciidoc index 7a0544f0c0..b39662fadc 100644 --- a/docs/examples/guide/4435b654994b575ba181ea679871c78c.asciidoc +++ b/docs/examples/guide/4435b654994b575ba181ea679871c78c.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/443e8da9968f1c65f46a2a65a1e1e078.asciidoc b/docs/examples/guide/443e8da9968f1c65f46a2a65a1e1e078.asciidoc new file mode 100644 index 0000000000..8ef1002f6a --- /dev/null +++ b/docs/examples/guide/443e8da9968f1c65f46a2a65a1e1e078.asciidoc @@ -0,0 +1,46 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'my-weather-sensor-index-template', + body: { + index_patterns: [ + 'metrics-weather_sensors-*' + ], + data_stream: {}, + template: { + settings: { + 'index.mode' => 'time_series', + 'index.lifecycle.name' => 'my-lifecycle-policy' + }, + mappings: { + properties: { + sensor_id: { + type: 'keyword', + time_series_dimension: true + }, + location: { + type: 'keyword', + time_series_dimension: true + }, + temperature: { + type: 'half_float', + time_series_metric: 'gauge' + }, + humidity: { + type: 'half_float', + time_series_metric: 'gauge' + }, + "@timestamp": { + type: 'date' + } + } + } + }, + priority: 500, + _meta: { + description: 'Template for my weather sensor data' + } + } +) +puts response +---- diff --git a/docs/examples/guide/443f0e8fbba83777b2df624879d188d5.asciidoc b/docs/examples/guide/443f0e8fbba83777b2df624879d188d5.asciidoc new file mode 100644 index 0000000000..15426aec49 --- /dev/null +++ b/docs/examples/guide/443f0e8fbba83777b2df624879d188d5.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.reindex( + wait_for_completion: false, + body: { + source: { + index: 'test-data', + size: 50 + }, + dest: { + index: 'azure-openai-embeddings', + pipeline: 'azure_openai_embeddings' + } + } +) +puts response +---- diff --git a/docs/examples/guide/445f8a6ef75fb43da52990b3a9063c78.asciidoc b/docs/examples/guide/445f8a6ef75fb43da52990b3a9063c78.asciidoc index eae08a7cb1..1a881320d7 100644 --- a/docs/examples/guide/445f8a6ef75fb43da52990b3a9063c78.asciidoc +++ b/docs/examples/guide/445f8a6ef75fb43da52990b3a9063c78.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "http.responses": '304' + 'http.responses' => '304' } }, fields: [ diff --git a/docs/examples/guide/4479e8c63a04fa22207a6a8803eadcad.asciidoc b/docs/examples/guide/4479e8c63a04fa22207a6a8803eadcad.asciidoc new file mode 100644 index 0000000000..d6abceee23 --- /dev/null +++ b/docs/examples/guide/4479e8c63a04fa22207a6a8803eadcad.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.cluster.put_settings( + body: { + persistent: { + 'cluster.routing.allocation.awareness.attributes' => 'rack_id' + } + } +) +puts response +---- diff --git a/docs/examples/guide/4498b9d3b0c77e1b9ef6664ff5963ce2.asciidoc b/docs/examples/guide/4498b9d3b0c77e1b9ef6664ff5963ce2.asciidoc index fb9853e7b4..d28fe1e8ef 100644 --- a/docs/examples/guide/4498b9d3b0c77e1b9ef6664ff5963ce2.asciidoc +++ b/docs/examples/guide/4498b9d3b0c77e1b9ef6664ff5963ce2.asciidoc @@ -4,7 +4,7 @@ response = client.indices.create( index: 'my-index-000001', body: { settings: { - "index.requests.cache.enable": false + 'index.requests.cache.enable' => false } } ) diff --git a/docs/examples/guide/44da736ce0e1587c1e7c45eee606ead7.asciidoc b/docs/examples/guide/44da736ce0e1587c1e7c45eee606ead7.asciidoc index 32c75fb132..275b20b224 100644 --- a/docs/examples/guide/44da736ce0e1587c1e7c45eee606ead7.asciidoc +++ b/docs/examples/guide/44da736ce0e1587c1e7c45eee606ead7.asciidoc @@ -9,7 +9,7 @@ response = client.update_by_query( }, query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/451b441c3311103d0d2bdbab771b26d2.asciidoc b/docs/examples/guide/451b441c3311103d0d2bdbab771b26d2.asciidoc new file mode 100644 index 0000000000..b0001c15d6 --- /dev/null +++ b/docs/examples/guide/451b441c3311103d0d2bdbab771b26d2.asciidoc @@ -0,0 +1,13 @@ +[source, ruby] +---- +response = client.put_script( + id: 'my-search-template', + body: { + script: { + lang: 'mustache', + source: "\n {\n \"query\": {\n \"match\": {\n {{=( )=}}\n \"message\": \"(query_string)\"\n (={{ }}=)\n }\n }\n }\n " + } + } +) +puts response +---- diff --git a/docs/examples/guide/451e7c29b2cf738cfc822f7c175bef56.asciidoc b/docs/examples/guide/451e7c29b2cf738cfc822f7c175bef56.asciidoc new file mode 100644 index 0000000000..36eb2823df --- /dev/null +++ b/docs/examples/guide/451e7c29b2cf738cfc822f7c175bef56.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'my-index-template', + body: { + index_patterns: [ + 'my-data-stream*' + ], + data_stream: {}, + priority: 500, + template: { + lifecycle: { + data_retention: '7d' + } + }, + _meta: { + description: 'Template with data stream lifecycle' + } + } +) +puts response +---- diff --git a/docs/examples/guide/452a61fecda86dd5539451dd57ec73a9.asciidoc b/docs/examples/guide/452a61fecda86dd5539451dd57ec73a9.asciidoc new file mode 100644 index 0000000000..764336f6de --- /dev/null +++ b/docs/examples/guide/452a61fecda86dd5539451dd57ec73a9.asciidoc @@ -0,0 +1,36 @@ +[source, ruby] +---- +response = client.search( + index: 'my-image-index', + body: { + size: 3, + query: { + bool: { + should: [ + { + match: { + title: { + query: 'mountain lake', + boost: 1 + } + } + }, + { + knn: { + field: 'image-vector', + query_vector: [ + -5, + 9, + -12 + ], + num_candidates: 10, + boost: 2 + } + } + ] + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/455029c3d66306ad5d48f6dbddaf7324.asciidoc b/docs/examples/guide/455029c3d66306ad5d48f6dbddaf7324.asciidoc index 8128f01e2b..e662f4c869 100644 --- a/docs/examples/guide/455029c3d66306ad5d48f6dbddaf7324.asciidoc +++ b/docs/examples/guide/455029c3d66306ad5d48f6dbddaf7324.asciidoc @@ -19,7 +19,7 @@ response = client.index( id: 1, refresh: true, body: { - "network.name": 'net-1', + 'network.name' => 'net-1', latency_histo: { values: [ 0.1, @@ -45,7 +45,7 @@ response = client.index( id: 2, refresh: true, body: { - "network.name": 'net-2', + 'network.name' => 'net-2', latency_histo: { values: [ 0.1, diff --git a/docs/examples/guide/45c6e54a9c9e08623af96752b4bde346.asciidoc b/docs/examples/guide/45c6e54a9c9e08623af96752b4bde346.asciidoc index 5ebec85d11..7305b24a17 100644 --- a/docs/examples/guide/45c6e54a9c9e08623af96752b4bde346.asciidoc +++ b/docs/examples/guide/45c6e54a9c9e08623af96752b4bde346.asciidoc @@ -11,7 +11,7 @@ response = client.search( filter: { geo_distance: { distance: '12km', - "pin.location": 'POINT (-70 40)' + 'pin.location' => 'POINT (-70 40)' } } } diff --git a/docs/examples/guide/45ef5156dbd2d3fd4fd22b8d99f7aad4.asciidoc b/docs/examples/guide/45ef5156dbd2d3fd4fd22b8d99f7aad4.asciidoc index f894cb224b..2296b26fd4 100644 --- a/docs/examples/guide/45ef5156dbd2d3fd4fd22b8d99f7aad4.asciidoc +++ b/docs/examples/guide/45ef5156dbd2d3fd4fd22b8d99f7aad4.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.enable": nil + 'cluster.routing.allocation.enable' => nil } } ) diff --git a/docs/examples/guide/46103fee3cd5f53dc75123def82d52ad.asciidoc b/docs/examples/guide/46103fee3cd5f53dc75123def82d52ad.asciidoc new file mode 100644 index 0000000000..29176ceb6c --- /dev/null +++ b/docs/examples/guide/46103fee3cd5f53dc75123def82d52ad.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'my-data-stream-template', + body: { + index_patterns: [ + 'my-data-stream*' + ], + data_stream: {}, + priority: 500, + template: { + settings: { + 'index.refresh_interval' => '30s' + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/4670dd81a9865e07ae74ae8b0266e384.asciidoc b/docs/examples/guide/4670dd81a9865e07ae74ae8b0266e384.asciidoc index 5491959e6c..002b08a594 100644 --- a/docs/examples/guide/4670dd81a9865e07ae74ae8b0266e384.asciidoc +++ b/docs/examples/guide/4670dd81a9865e07ae74ae8b0266e384.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "startup_time_before.adjusted": { + 'startup_time_before.adjusted' => { type: 'long', script: { source: "emit(doc['startup_time_before'].value - params.adjustment)", diff --git a/docs/examples/guide/473c8ddd4e4b7814a64e5fe40d9d6dca.asciidoc b/docs/examples/guide/473c8ddd4e4b7814a64e5fe40d9d6dca.asciidoc new file mode 100644 index 0000000000..2667da9ed5 --- /dev/null +++ b/docs/examples/guide/473c8ddd4e4b7814a64e5fe40d9d6dca.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.tasks.cancel( + task_id: '2j8UKw1bRO283PMwDugNNg:5326' +) +puts response +---- diff --git a/docs/examples/guide/4824a823a830a2a5d990eacfd783ac22.asciidoc b/docs/examples/guide/4824a823a830a2a5d990eacfd783ac22.asciidoc index 411b6232c2..a4ee8c04c5 100644 --- a/docs/examples/guide/4824a823a830a2a5d990eacfd783ac22.asciidoc +++ b/docs/examples/guide/4824a823a830a2a5d990eacfd783ac22.asciidoc @@ -9,7 +9,7 @@ response = client.delete_by_query( }, query: { range: { - "http.response.bytes": { + 'http.response.bytes' => { lt: 2_000_000 } } @@ -27,7 +27,7 @@ response = client.delete_by_query( }, query: { range: { - "http.response.bytes": { + 'http.response.bytes' => { lt: 2_000_000 } } diff --git a/docs/examples/guide/484e24d1ed1a154ba9753e6090d38d78.asciidoc b/docs/examples/guide/484e24d1ed1a154ba9753e6090d38d78.asciidoc new file mode 100644 index 0000000000..9732d8b09b --- /dev/null +++ b/docs/examples/guide/484e24d1ed1a154ba9753e6090d38d78.asciidoc @@ -0,0 +1,16 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'point', + coordinates: [ + -377.03653, + 389.897676 + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/487f0e07fd83c05f9763e0795c525e2e.asciidoc b/docs/examples/guide/487f0e07fd83c05f9763e0795c525e2e.asciidoc new file mode 100644 index 0000000000..c0b6f657f8 --- /dev/null +++ b/docs/examples/guide/487f0e07fd83c05f9763e0795c525e2e.asciidoc @@ -0,0 +1,100 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'test', + body: { + mappings: { + properties: { + my_location: { + type: 'geo_point' + }, + group: { + type: 'keyword' + }, + "@timestamp": { + type: 'date' + } + } + } + } +) +puts response + +response = client.bulk( + index: 'test', + refresh: true, + body: [ + { + index: {} + }, + { + my_location: { + lat: 52.373184, + lon: 4.889187 + }, + "@timestamp": '2023-01-02T09:00:00Z' + }, + { + index: {} + }, + { + my_location: { + lat: 52.370159, + lon: 4.885057 + }, + "@timestamp": '2023-01-02T10:00:00Z' + }, + { + index: {} + }, + { + my_location: { + lat: 52.369219, + lon: 4.901618 + }, + "@timestamp": '2023-01-02T13:00:00Z' + }, + { + index: {} + }, + { + my_location: { + lat: 52.374081, + lon: 4.91235 + }, + "@timestamp": '2023-01-02T16:00:00Z' + }, + { + index: {} + }, + { + my_location: { + lat: 52.371667, + lon: 4.914722 + }, + "@timestamp": '2023-01-03T12:00:00Z' + } + ] +) +puts response + +response = client.search( + index: 'test', + filter_path: 'aggregations', + body: { + aggregations: { + line: { + geo_line: { + point: { + field: 'my_location' + }, + sort: { + field: '@timestamp' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/48d9697a14dfe131325521f48a7adc84.asciidoc b/docs/examples/guide/48d9697a14dfe131325521f48a7adc84.asciidoc new file mode 100644 index 0000000000..a67670c51d --- /dev/null +++ b/docs/examples/guide/48d9697a14dfe131325521f48a7adc84.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.render_search_template( + body: { + id: 'my-search-template', + params: { + query_string: 'My string', + text_fields: [ + { + user_name: 'John', + last: false + }, + { + user_name: 'kimchy', + last: true + } + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/49c40b51da2469a6e00fea8fa6fbf56e.asciidoc b/docs/examples/guide/49c40b51da2469a6e00fea8fa6fbf56e.asciidoc new file mode 100644 index 0000000000..f9af00a733 --- /dev/null +++ b/docs/examples/guide/49c40b51da2469a6e00fea8fa6fbf56e.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.tasks.list( + pretty: true, + detailed: true, + group_by: 'parents', + human: true, + actions: '*data/read/esql' +) +puts response +---- diff --git a/docs/examples/guide/4a7510a9c0468303658383c00796dad2.asciidoc b/docs/examples/guide/4a7510a9c0468303658383c00796dad2.asciidoc index bca4de8242..e230d141be 100644 --- a/docs/examples/guide/4a7510a9c0468303658383c00796dad2.asciidoc +++ b/docs/examples/guide/4a7510a9c0468303658383c00796dad2.asciidoc @@ -4,7 +4,7 @@ response = client.indices.create( index: 'my-index-000001', body: { settings: { - "index.mapping.ignore_malformed": true + 'index.mapping.ignore_malformed' => true }, mappings: { properties: { diff --git a/docs/examples/guide/4aa510f34a0358fecc8d764dd099b843.asciidoc b/docs/examples/guide/4aa510f34a0358fecc8d764dd099b843.asciidoc deleted file mode 100644 index 1c40f583bc..0000000000 --- a/docs/examples/guide/4aa510f34a0358fecc8d764dd099b843.asciidoc +++ /dev/null @@ -1,14 +0,0 @@ -[source, ruby] ----- -response = client.indices.put_settings( - index: 'my_source_index', - body: { - settings: { - "index.number_of_replicas": 0, - "index.routing.allocation.require._name": 'shrink_node_name', - "index.blocks.write": true - } - } -) -puts response ----- diff --git a/docs/examples/guide/4ae494d1e62231e832fc0436b04e2014.asciidoc b/docs/examples/guide/4ae494d1e62231e832fc0436b04e2014.asciidoc index 376524b79a..ebb5e33834 100644 --- a/docs/examples/guide/4ae494d1e62231e832fc0436b04e2014.asciidoc +++ b/docs/examples/guide/4ae494d1e62231e832fc0436b04e2014.asciidoc @@ -12,7 +12,7 @@ response = client.indices.validate_query( }, filter: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/4af15c4f26ddefb9c350e7a246a66a15.asciidoc b/docs/examples/guide/4af15c4f26ddefb9c350e7a246a66a15.asciidoc index ab1a7d764a..93fe623517 100644 --- a/docs/examples/guide/4af15c4f26ddefb9c350e7a246a66a15.asciidoc +++ b/docs/examples/guide/4af15c4f26ddefb9c350e7a246a66a15.asciidoc @@ -9,7 +9,7 @@ response = client.search( terms: { field: 'ip', order: { - "tm.m": 'desc' + 'tm.m' => 'desc' } }, aggregations: { diff --git a/docs/examples/guide/4b5110a21676cc0e26e050a4b4552235.asciidoc b/docs/examples/guide/4b5110a21676cc0e26e050a4b4552235.asciidoc new file mode 100644 index 0000000000..2c4ab85194 --- /dev/null +++ b/docs/examples/guide/4b5110a21676cc0e26e050a4b4552235.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.synonyms.get_synonym( + id: 'my-synonyms-set' +) +puts response +---- diff --git a/docs/examples/guide/4bba59cf745ac7b996bf90308bc26957.asciidoc b/docs/examples/guide/4bba59cf745ac7b996bf90308bc26957.asciidoc index 9e38458a93..96d1027978 100644 --- a/docs/examples/guide/4bba59cf745ac7b996bf90308bc26957.asciidoc +++ b/docs/examples/guide/4bba59cf745ac7b996bf90308bc26957.asciidoc @@ -12,7 +12,7 @@ response = client.search( }, filter: { term: { - "file_path.tree": '/User/alice' + 'file_path.tree' => '/User/alice' } } } diff --git a/docs/examples/guide/4be20da16d2b58216e8b307218c7bf3a.asciidoc b/docs/examples/guide/4be20da16d2b58216e8b307218c7bf3a.asciidoc new file mode 100644 index 0000000000..8410d14978 --- /dev/null +++ b/docs/examples/guide/4be20da16d2b58216e8b307218c7bf3a.asciidoc @@ -0,0 +1,28 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'my-data-stream-template', + body: { + index_patterns: [ + 'my-data-stream*' + ], + data_stream: {}, + priority: 500, + template: { + mappings: { + properties: { + host: { + properties: { + ip: { + type: 'ip', + ignore_malformed: true + } + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/4bfcb2861f1d572bd0d66acd66deab0b.asciidoc b/docs/examples/guide/4bfcb2861f1d572bd0d66acd66deab0b.asciidoc index 9bd102d9a6..7a13e0c476 100644 --- a/docs/examples/guide/4bfcb2861f1d572bd0d66acd66deab0b.asciidoc +++ b/docs/examples/guide/4bfcb2861f1d572bd0d66acd66deab0b.asciidoc @@ -5,7 +5,7 @@ response = client.ml.update_datafeed( body: { query: { term: { - "geo.src": 'US' + 'geo.src' => 'US' } } } diff --git a/docs/examples/guide/4cdcc3fde5cea165a3a7567962b9bd61.asciidoc b/docs/examples/guide/4cdcc3fde5cea165a3a7567962b9bd61.asciidoc new file mode 100644 index 0000000000..9866a59676 --- /dev/null +++ b/docs/examples/guide/4cdcc3fde5cea165a3a7567962b9bd61.asciidoc @@ -0,0 +1,72 @@ +[source, ruby] +---- +response = client.synonyms.put_synonym( + id: 'my-synonyms-set', + body: { + synonyms_set: [ + { + id: 'test-1', + synonyms: 'hello, hi' + } + ] + } +) +puts response + +response = client.indices.create( + index: 'test-index', + body: { + settings: { + analysis: { + filter: { + synonyms_filter: { + type: 'synonym_graph', + synonyms_set: 'my-synonyms-set', + updateable: true + } + }, + analyzer: { + my_index_analyzer: { + type: 'custom', + tokenizer: 'standard', + filter: [ + 'lowercase' + ] + }, + my_search_analyzer: { + type: 'custom', + tokenizer: 'standard', + filter: [ + 'lowercase', + 'synonyms_filter' + ] + } + } + } + }, + mappings: { + properties: { + title: { + type: 'text', + analyzer: 'my_index_analyzer', + search_analyzer: 'my_search_analyzer' + } + } + } + } +) +puts response + +response = client.synonyms.put_synonym( + id: 'my-synonyms-set', + body: { + synonyms_set: [ + { + id: 'test-1', + synonyms: 'hello, hi, howdy' + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/4e3414fc712b16311f9e433dd366f49d.asciidoc b/docs/examples/guide/4e3414fc712b16311f9e433dd366f49d.asciidoc new file mode 100644 index 0000000000..93ead6685d --- /dev/null +++ b/docs/examples/guide/4e3414fc712b16311f9e433dd366f49d.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.inference.delete_model( + task_type: 'sparse_embedding', + inference_id: 'my-elser-model' +) +puts response +---- diff --git a/docs/examples/guide/4f621ab694f62ddb89e0684a9e76c4d1.asciidoc b/docs/examples/guide/4f621ab694f62ddb89e0684a9e76c4d1.asciidoc index 9bc86e7a99..1db79c8d16 100644 --- a/docs/examples/guide/4f621ab694f62ddb89e0684a9e76c4d1.asciidoc +++ b/docs/examples/guide/4f621ab694f62ddb89e0684a9e76c4d1.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { diff --git a/docs/examples/guide/4fcca1687d7b2cf08de526539fea5a76.asciidoc b/docs/examples/guide/4fcca1687d7b2cf08de526539fea5a76.asciidoc new file mode 100644 index 0000000000..43ce1972c3 --- /dev/null +++ b/docs/examples/guide/4fcca1687d7b2cf08de526539fea5a76.asciidoc @@ -0,0 +1,43 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + query: { + bool: { + should: [ + { + text_expansion: { + 'ml.inference.title_expanded.predicted_value' => { + model_id: '.elser_model_2', + model_text: 'How is the weather in Jamaica?', + boost: 1 + } + } + }, + { + text_expansion: { + 'ml.inference.description_expanded.predicted_value' => { + model_id: '.elser_model_2', + model_text: 'How is the weather in Jamaica?', + boost: 1 + } + } + }, + { + multi_match: { + query: 'How is the weather in Jamaica?', + fields: [ + 'title', + 'description' + ], + boost: 4 + } + } + ] + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/50522d3d5b3d055f712ad737e3d1707a.asciidoc b/docs/examples/guide/50522d3d5b3d055f712ad737e3d1707a.asciidoc index d764ff26ac..be4556d408 100644 --- a/docs/examples/guide/50522d3d5b3d055f712ad737e3d1707a.asciidoc +++ b/docs/examples/guide/50522d3d5b3d055f712ad737e3d1707a.asciidoc @@ -43,7 +43,7 @@ response = client.search( body: { query: { term: { - "name.length": 3 + 'name.length' => 3 } } } diff --git a/docs/examples/guide/51390ca10aa22d7104e8970f09ea4512.asciidoc b/docs/examples/guide/51390ca10aa22d7104e8970f09ea4512.asciidoc new file mode 100644 index 0000000000..ca759417ef --- /dev/null +++ b/docs/examples/guide/51390ca10aa22d7104e8970f09ea4512.asciidoc @@ -0,0 +1,32 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'idx', + body: { + mappings: { + _source: { + mode: 'synthetic' + }, + properties: { + binary: { + type: 'binary', + doc_values: true + } + } + } + } +) +puts response + +response = client.index( + index: 'idx', + id: 1, + body: { + binary: [ + 'IAA=', + 'EAA=' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/515e1104d136082e826d1b32af011759.asciidoc b/docs/examples/guide/515e1104d136082e826d1b32af011759.asciidoc new file mode 100644 index 0000000000..8315b4829b --- /dev/null +++ b/docs/examples/guide/515e1104d136082e826d1b32af011759.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.index( + index: 'products', + id: 0, + refresh: true, + body: { + name: 'LED TV', + resellers: [ + { + reseller: 'companyA', + price: 350 + }, + { + reseller: 'companyB', + price: 500 + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/518fcf1dc1edd7dba0864accf71b49f4.asciidoc b/docs/examples/guide/518fcf1dc1edd7dba0864accf71b49f4.asciidoc index c1eb983975..e6c12a28bf 100644 --- a/docs/examples/guide/518fcf1dc1edd7dba0864accf71b49f4.asciidoc +++ b/docs/examples/guide/518fcf1dc1edd7dba0864accf71b49f4.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/51f6cb682424e110f289af79c106f4c7.asciidoc b/docs/examples/guide/51f6cb682424e110f289af79c106f4c7.asciidoc index 55af6a0920..447372ca01 100644 --- a/docs/examples/guide/51f6cb682424e110f289af79c106f4c7.asciidoc +++ b/docs/examples/guide/51f6cb682424e110f289af79c106f4c7.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.max_shards_per_node.frozen": 3200 + 'cluster.max_shards_per_node.frozen' => 3200 } } ) diff --git a/docs/examples/guide/5276a831513623e43ed567eb52b6dba9.asciidoc b/docs/examples/guide/5276a831513623e43ed567eb52b6dba9.asciidoc new file mode 100644 index 0000000000..a903a37bc9 --- /dev/null +++ b/docs/examples/guide/5276a831513623e43ed567eb52b6dba9.asciidoc @@ -0,0 +1,15 @@ +[source, ruby] +---- +response = client.index( + index: 'my-index-000001', + routing: 'my-routing-value', + body: { + "@timestamp": '2099-11-15T13:12:00', + message: 'GET /search HTTP/1.1 200 1070000', + user: { + id: 'kimchy' + } + } +) +puts response +---- diff --git a/docs/examples/guide/529b975b7cedaac58dce9821956adc37.asciidoc b/docs/examples/guide/529b975b7cedaac58dce9821956adc37.asciidoc new file mode 100644 index 0000000000..5afbbc21d5 --- /dev/null +++ b/docs/examples/guide/529b975b7cedaac58dce9821956adc37.asciidoc @@ -0,0 +1,84 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'MultiPolygon', + coordinates: [ + [ + [ + [ + 102, + 2 + ], + [ + 103, + 2 + ], + [ + 103, + 3 + ], + [ + 102, + 3 + ], + [ + 102, + 2 + ] + ] + ], + [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ], + [ + [ + 100.2, + 0.2 + ], + [ + 100.8, + 0.2 + ], + [ + 100.8, + 0.8 + ], + [ + 100.2, + 0.8 + ], + [ + 100.2, + 0.2 + ] + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/52a2d119addb15366a935115518335fd.asciidoc b/docs/examples/guide/52a2d119addb15366a935115518335fd.asciidoc new file mode 100644 index 0000000000..26c940ad2d --- /dev/null +++ b/docs/examples/guide/52a2d119addb15366a935115518335fd.asciidoc @@ -0,0 +1,13 @@ +[source, ruby] +---- +response = client.indices.put_settings( + index: 'my_source_index', + body: { + settings: { + 'index.number_of_replicas' => 0, + 'index.routing.allocation.require._name' => 'shrink_node_name' + } + } +) +puts response +---- diff --git a/docs/examples/guide/52bc577a0d0cd42b46f33e0ef5124df8.asciidoc b/docs/examples/guide/52bc577a0d0cd42b46f33e0ef5124df8.asciidoc new file mode 100644 index 0000000000..ca06e55db9 --- /dev/null +++ b/docs/examples/guide/52bc577a0d0cd42b46f33e0ef5124df8.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.put_script( + id: 'my-search-template', + body: { + script: { + lang: 'mustache', + source: { + query: { + match: { + message: '{{query_string}}' + } + }, + from: '{{from}}', + size: '{{size}}' + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/52be795b68e6ef3f396f35fea52d0481.asciidoc b/docs/examples/guide/52be795b68e6ef3f396f35fea52d0481.asciidoc new file mode 100644 index 0000000000..3c215c3b6e --- /dev/null +++ b/docs/examples/guide/52be795b68e6ef3f396f35fea52d0481.asciidoc @@ -0,0 +1,14 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'my-data-stream-template', + body: { + index_patterns: [ + 'my-data-stream*' + ], + data_stream: {}, + priority: 500 + } +) +puts response +---- diff --git a/docs/examples/guide/53aa8b21e2b1c4d48960343711296704.asciidoc b/docs/examples/guide/53aa8b21e2b1c4d48960343711296704.asciidoc index 4b7b3ae5dd..553658d9ff 100644 --- a/docs/examples/guide/53aa8b21e2b1c4d48960343711296704.asciidoc +++ b/docs/examples/guide/53aa8b21e2b1c4d48960343711296704.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { regexp: { - "my_field.keyword": 'a\\\\.*' + 'my_field.keyword' => 'a\\\\.*' } } } diff --git a/docs/examples/guide/53bb7f0e3429861aadb8dd3d588085cd.asciidoc b/docs/examples/guide/53bb7f0e3429861aadb8dd3d588085cd.asciidoc index 582810af28..f7ac8c0224 100644 --- a/docs/examples/guide/53bb7f0e3429861aadb8dd3d588085cd.asciidoc +++ b/docs/examples/guide/53bb7f0e3429861aadb8dd3d588085cd.asciidoc @@ -6,7 +6,7 @@ response = client.search( seq_no_primary_term: true, query: { match: { - "user.id": 'yWIumJd7' + 'user.id' => 'yWIumJd7' } } } diff --git a/docs/examples/guide/53c6256295111524d5ff2885bdcb99a9.asciidoc b/docs/examples/guide/53c6256295111524d5ff2885bdcb99a9.asciidoc index 7dd23fda14..9023a1e760 100644 --- a/docs/examples/guide/53c6256295111524d5ff2885bdcb99a9.asciidoc +++ b/docs/examples/guide/53c6256295111524d5ff2885bdcb99a9.asciidoc @@ -1,7 +1,7 @@ [source, ruby] ---- -response = client.indices.get( - index: '_transform', +response = client.transform.get_transform( + transform_id: '_stats', from: 5, size: 10 ) diff --git a/docs/examples/guide/543c3a77880adf281099df1a41f6b96a.asciidoc b/docs/examples/guide/543c3a77880adf281099df1a41f6b96a.asciidoc new file mode 100644 index 0000000000..d38d8a9c06 --- /dev/null +++ b/docs/examples/guide/543c3a77880adf281099df1a41f6b96a.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.esql.query( + body: { + locale: 'fr-FR', + query: "\n ROW birth_date_string = \"2023-01-15T00:00:00.000Z\"\n | EVAL birth_date = date_parse(birth_date_string)\n | EVAL month_of_birth = DATE_FORMAT(\"MMMM\",birth_date)\n | LIMIT 5\n ", + version: '2024.04.01' + } +) +puts response +---- diff --git a/docs/examples/guide/548b85bd9e6e7d33e36133953869449b.asciidoc b/docs/examples/guide/548b85bd9e6e7d33e36133953869449b.asciidoc index ed37c12a9d..72e7f48701 100644 --- a/docs/examples/guide/548b85bd9e6e7d33e36133953869449b.asciidoc +++ b/docs/examples/guide/548b85bd9e6e7d33e36133953869449b.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "xpack.monitoring.collection.enabled": false + 'xpack.monitoring.collection.enabled' => false } } ) diff --git a/docs/examples/guide/55096381f811388fafd8e244dd2402c8.asciidoc b/docs/examples/guide/55096381f811388fafd8e244dd2402c8.asciidoc index f149619242..24cdefa4b9 100644 --- a/docs/examples/guide/55096381f811388fafd8e244dd2402c8.asciidoc +++ b/docs/examples/guide/55096381f811388fafd8e244dd2402c8.asciidoc @@ -4,7 +4,7 @@ response = client.indices.rollover( alias: 'my-alias', body: { settings: { - "index.number_of_shards": 2 + 'index.number_of_shards' => 2 } } ) diff --git a/docs/examples/guide/5553cf7a02c22f616cd994747f2dd5a5.asciidoc b/docs/examples/guide/5553cf7a02c22f616cd994747f2dd5a5.asciidoc index c1da504695..33b7049e45 100644 --- a/docs/examples/guide/5553cf7a02c22f616cd994747f2dd5a5.asciidoc +++ b/docs/examples/guide/5553cf7a02c22f616cd994747f2dd5a5.asciidoc @@ -8,12 +8,12 @@ response = client.search( must: [ { match: { - "user.first": 'Alice' + 'user.first' => 'Alice' } }, { match: { - "user.last": 'Smith' + 'user.last' => 'Smith' } } ] diff --git a/docs/examples/guide/55838e0b21c4f4da2dc8aaec045a6d5f.asciidoc b/docs/examples/guide/55838e0b21c4f4da2dc8aaec045a6d5f.asciidoc index 90db32e316..207a8224ef 100644 --- a/docs/examples/guide/55838e0b21c4f4da2dc8aaec045a6d5f.asciidoc +++ b/docs/examples/guide/55838e0b21c4f4da2dc8aaec045a6d5f.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "load_time.seconds": { + 'load_time.seconds' => { type: 'long', script: { source: "emit(doc['load_time'].value / params.timeUnit)", diff --git a/docs/examples/guide/565908b03edff1d6e6e7cdfb92177faf.asciidoc b/docs/examples/guide/565908b03edff1d6e6e7cdfb92177faf.asciidoc index 1695e59451..8ec58ed61f 100644 --- a/docs/examples/guide/565908b03edff1d6e6e7cdfb92177faf.asciidoc +++ b/docs/examples/guide/565908b03edff1d6e6e7cdfb92177faf.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "grade.weighted": { + 'grade.weighted' => { type: 'double', script: "\n emit(doc['grade'].value * doc['weight'].value)\n " } diff --git a/docs/examples/guide/571314a948e49f1f9614d36fcf79392a.asciidoc b/docs/examples/guide/571314a948e49f1f9614d36fcf79392a.asciidoc new file mode 100644 index 0000000000..bf14021769 --- /dev/null +++ b/docs/examples/guide/571314a948e49f1f9614d36fcf79392a.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.async_search.get( + id: 'FjktRGJ1Y2w1U0phLTRhZnVyeUZ2MVEbWEJyeVBPQldTV3FGZGdIeUVabXBldzo5NzA4' +) +puts response +---- diff --git a/docs/examples/guide/578808065fee8691355b8f25c35782cd.asciidoc b/docs/examples/guide/578808065fee8691355b8f25c35782cd.asciidoc index b309f98009..e21912fc6c 100644 --- a/docs/examples/guide/578808065fee8691355b8f25c35782cd.asciidoc +++ b/docs/examples/guide/578808065fee8691355b8f25c35782cd.asciidoc @@ -7,7 +7,7 @@ response = client.search( profile: true, query: { term: { - "user.id": { + 'user.id' => { value: 'elkbee' } } diff --git a/docs/examples/guide/5865ca8d2bcd087ed5dbee33fafee57f.asciidoc b/docs/examples/guide/5865ca8d2bcd087ed5dbee33fafee57f.asciidoc new file mode 100644 index 0000000000..ba4759cad5 --- /dev/null +++ b/docs/examples/guide/5865ca8d2bcd087ed5dbee33fafee57f.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.indices.explain_data_lifecycle( + index: '.ds-my-data-stream-*' +) +puts response +---- diff --git a/docs/examples/guide/58f72be60c25752d7899a35fc60fe6eb.asciidoc b/docs/examples/guide/58f72be60c25752d7899a35fc60fe6eb.asciidoc index 139a5b7834..51ecd22796 100644 --- a/docs/examples/guide/58f72be60c25752d7899a35fc60fe6eb.asciidoc +++ b/docs/examples/guide/58f72be60c25752d7899a35fc60fe6eb.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "logger.org.elasticsearch.indices.recovery": 'DEBUG' + 'logger.org.elasticsearch.indices.recovery' => 'DEBUG' } } ) diff --git a/docs/examples/guide/591bf50bb5ad3134006efe5c3f46d7a6.asciidoc b/docs/examples/guide/591bf50bb5ad3134006efe5c3f46d7a6.asciidoc deleted file mode 100644 index 8c5d54139a..0000000000 --- a/docs/examples/guide/591bf50bb5ad3134006efe5c3f46d7a6.asciidoc +++ /dev/null @@ -1,31 +0,0 @@ -[source, ruby] ----- -response = client.cluster.put_settings( - body: { - persistent: { - cluster: { - remote: { - cluster_one: { - seeds: [ - '127.0.0.1:9300' - ] - }, - cluster_two: { - mode: 'sniff', - seeds: [ - '127.0.0.1:9301' - ], - "transport.compress": true, - skip_unavailable: true - }, - cluster_three: { - mode: 'proxy', - proxy_address: '127.0.0.1:9302' - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/5969c446688c8b326acc80276573e9d2.asciidoc b/docs/examples/guide/5969c446688c8b326acc80276573e9d2.asciidoc index 86384c4346..d67f8fc3d7 100644 --- a/docs/examples/guide/5969c446688c8b326acc80276573e9d2.asciidoc +++ b/docs/examples/guide/5969c446688c8b326acc80276573e9d2.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { @@ -19,13 +19,13 @@ response = client.search( '' ] }, - "blog.title": { + 'blog.title' => { number_of_fragments: 0 }, - "blog.author": { + 'blog.author' => { number_of_fragments: 0 }, - "blog.comment": { + 'blog.comment' => { number_of_fragments: 5, order: 'score' } diff --git a/docs/examples/guide/5a006feed86309b547bbaa1baca1c496.asciidoc b/docs/examples/guide/5a006feed86309b547bbaa1baca1c496.asciidoc new file mode 100644 index 0000000000..d502847953 --- /dev/null +++ b/docs/examples/guide/5a006feed86309b547bbaa1baca1c496.asciidoc @@ -0,0 +1,71 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index-000001', + body: { + mappings: { + dynamic_templates: [ + { + numeric_counts: { + match_mapping_type: [ + 'long', + 'double' + ], + match: 'count', + mapping: { + type: '{dynamic_type}', + index: false + } + } + }, + { + integers: { + match_mapping_type: 'long', + mapping: { + type: 'integer' + } + } + }, + { + strings: { + match_mapping_type: 'string', + mapping: { + type: 'text', + fields: { + raw: { + type: 'keyword', + ignore_above: 256 + } + } + } + } + }, + { + non_objects_keyword: { + match_mapping_type: '*', + unmatch_mapping_type: 'object', + mapping: { + type: 'keyword' + } + } + } + ] + } + } +) +puts response + +response = client.index( + index: 'my-index-000001', + id: 1, + body: { + my_integer: 5, + my_string: 'Some string', + my_boolean: 'false', + field: { + count: 4 + } + } +) +puts response +---- diff --git a/docs/examples/guide/5a7f05ab1d05b4eef5ff327168517165.asciidoc b/docs/examples/guide/5a7f05ab1d05b4eef5ff327168517165.asciidoc index 331127e9da..9f8c918a2c 100644 --- a/docs/examples/guide/5a7f05ab1d05b4eef5ff327168517165.asciidoc +++ b/docs/examples/guide/5a7f05ab1d05b4eef5ff327168517165.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/5c7ece1f30267adabdb832424871900a.asciidoc b/docs/examples/guide/5c7ece1f30267adabdb832424871900a.asciidoc new file mode 100644 index 0000000000..ae6b0b230b --- /dev/null +++ b/docs/examples/guide/5c7ece1f30267adabdb832424871900a.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.cat.allocation( + v: true +) +puts response +---- diff --git a/docs/examples/guide/5cbfc259df140862818c10eb8a96ba97.asciidoc b/docs/examples/guide/5cbfc259df140862818c10eb8a96ba97.asciidoc deleted file mode 100644 index 6cfb0c7f87..0000000000 --- a/docs/examples/guide/5cbfc259df140862818c10eb8a96ba97.asciidoc +++ /dev/null @@ -1,84 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'test', - body: { - mappings: { - dynamic: 'strict', - _source: { - enabled: false - }, - properties: { - my_location: { - type: 'geo_point' - }, - group: { - type: 'keyword' - }, - "@timestamp": { - type: 'date' - } - } - } - } -) -puts response - -response = client.bulk( - index: 'test', - refresh: true, - body: [ - { - index: {} - }, - { - my_location: { - lat: 37.345057, - lon: -122.049982 - }, - "@timestamp": '2013-09-06T16:00:36' - }, - { - index: {} - }, - { - my_location: { - lat: 37.345132, - lon: -122.049982 - }, - "@timestamp": '2013-09-06T16:00:37Z' - }, - { - index: {} - }, - { - my_location: { - lat: 37.349283, - lon: -122.050501 - }, - "@timestamp": '2013-09-06T16:00:37Z' - } - ] -) -puts response - -response = client.search( - index: 'test', - filter_path: 'aggregations', - body: { - aggregations: { - line: { - geo_line: { - point: { - field: 'my_location' - }, - sort: { - field: '@timestamp' - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/5db5349162a4fbe74bffb646926a2495.asciidoc b/docs/examples/guide/5db5349162a4fbe74bffb646926a2495.asciidoc new file mode 100644 index 0000000000..7a7e45ae07 --- /dev/null +++ b/docs/examples/guide/5db5349162a4fbe74bffb646926a2495.asciidoc @@ -0,0 +1,31 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'idx', + body: { + mappings: { + _source: { + mode: 'synthetic' + }, + properties: { + my_range: { + type: 'long_range' + } + } + } + } +) +puts response + +response = client.index( + index: 'idx', + id: 1, + body: { + my_range: { + gt: 200, + lt: 300 + } + } +) +puts response +---- diff --git a/docs/examples/guide/5e2f7097eb299de553d0fa0087d70a59.asciidoc b/docs/examples/guide/5e2f7097eb299de553d0fa0087d70a59.asciidoc index 0f08126e84..becbee211e 100644 --- a/docs/examples/guide/5e2f7097eb299de553d0fa0087d70a59.asciidoc +++ b/docs/examples/guide/5e2f7097eb299de553d0fa0087d70a59.asciidoc @@ -5,11 +5,11 @@ response = client.indices.create( body: { settings: { index: { - "sort.field": [ + 'sort.field' => [ 'username', 'timestamp' ], - "sort.order": [ + 'sort.order' => [ 'asc', 'desc' ] diff --git a/docs/examples/guide/5e415c490a46358643ee2aab554b4876.asciidoc b/docs/examples/guide/5e415c490a46358643ee2aab554b4876.asciidoc new file mode 100644 index 0000000000..4b992d5fe4 --- /dev/null +++ b/docs/examples/guide/5e415c490a46358643ee2aab554b4876.asciidoc @@ -0,0 +1,12 @@ +[source, ruby] +---- +response = client.cluster.allocation_explain( + filter_path: 'index,node_allocation_decisions.node_name,node_allocation_decisions.deciders.*', + body: { + index: 'my-index', + shard: 0, + primary: false + } +) +puts response +---- diff --git a/docs/examples/guide/5e9a7845e60b79685aab59877c5fbd1a.asciidoc b/docs/examples/guide/5e9a7845e60b79685aab59877c5fbd1a.asciidoc new file mode 100644 index 0000000000..227b9ffa09 --- /dev/null +++ b/docs/examples/guide/5e9a7845e60b79685aab59877c5fbd1a.asciidoc @@ -0,0 +1,15 @@ +[source, ruby] +---- +response = client.search( + body: { + aggregations: { + ignored_fields: { + terms: { + field: '_ignored' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/62e073b6b8ef533b5f3551bad623c070.asciidoc b/docs/examples/guide/62e073b6b8ef533b5f3551bad623c070.asciidoc deleted file mode 100644 index 7aba03f82b..0000000000 --- a/docs/examples/guide/62e073b6b8ef533b5f3551bad623c070.asciidoc +++ /dev/null @@ -1,45 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'my-index-000001', - body: { - mappings: { - dynamic_templates: [ - { - integers: { - match_mapping_type: 'long', - mapping: { - type: 'integer' - } - } - }, - { - strings: { - match_mapping_type: 'string', - mapping: { - type: 'text', - fields: { - raw: { - type: 'keyword', - ignore_above: 256 - } - } - } - } - } - ] - } - } -) -puts response - -response = client.index( - index: 'my-index-000001', - id: 1, - body: { - my_integer: 5, - my_string: 'Some string' - } -) -puts response ----- diff --git a/docs/examples/guide/6352e846bb83725ae6d853aa64d8697d.asciidoc b/docs/examples/guide/6352e846bb83725ae6d853aa64d8697d.asciidoc index ce4386f972..faf528cbcc 100644 --- a/docs/examples/guide/6352e846bb83725ae6d853aa64d8697d.asciidoc +++ b/docs/examples/guide/6352e846bb83725ae6d853aa64d8697d.asciidoc @@ -11,7 +11,7 @@ response = client.search( filter: { geo_distance: { distance: '12km', - "pin.location": { + 'pin.location' => { lat: 40, lon: -70 } diff --git a/docs/examples/guide/640621cea39cdeeb76fbc95bff31a18d.asciidoc b/docs/examples/guide/640621cea39cdeeb76fbc95bff31a18d.asciidoc new file mode 100644 index 0000000000..c3710d0691 --- /dev/null +++ b/docs/examples/guide/640621cea39cdeeb76fbc95bff31a18d.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.connector.last_sync( + connector_id: 'my-connector', + body: { + last_access_control_sync_error: 'Houston, we have a problem!', + last_access_control_sync_scheduled_at: '2023-11-09T15:13:08.231Z', + last_access_control_sync_status: 'pending', + last_deleted_document_count: 42, + last_incremental_sync_scheduled_at: '2023-11-09T15:13:08.231Z', + last_indexed_document_count: 42, + last_sync_error: 'Houston, we have a problem!', + last_sync_scheduled_at: '2024-11-09T15:13:08.231Z', + last_sync_status: 'completed', + last_synced: '2024-11-09T15:13:08.231Z' + } +) +puts response +---- diff --git a/docs/examples/guide/640da6dd719a34975b5627dfa5fcdd55.asciidoc b/docs/examples/guide/640da6dd719a34975b5627dfa5fcdd55.asciidoc index 87610fa161..ceb997d653 100644 --- a/docs/examples/guide/640da6dd719a34975b5627dfa5fcdd55.asciidoc +++ b/docs/examples/guide/640da6dd719a34975b5627dfa5fcdd55.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "xpack.monitoring.collection.enabled": true + 'xpack.monitoring.collection.enabled' => true } } ) diff --git a/docs/examples/guide/640e4f2c2d29f9851320a70927bd7a6c.asciidoc b/docs/examples/guide/640e4f2c2d29f9851320a70927bd7a6c.asciidoc index 59e12dc8bc..ade82466df 100644 --- a/docs/examples/guide/640e4f2c2d29f9851320a70927bd7a6c.asciidoc +++ b/docs/examples/guide/640e4f2c2d29f9851320a70927bd7a6c.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "indices.lifecycle.poll_interval": nil + 'indices.lifecycle.poll_interval' => nil } } ) diff --git a/docs/examples/guide/645433e8e479e5d71c100f66dd2de5d0.asciidoc b/docs/examples/guide/645433e8e479e5d71c100f66dd2de5d0.asciidoc new file mode 100644 index 0000000000..611047ac1d --- /dev/null +++ b/docs/examples/guide/645433e8e479e5d71c100f66dd2de5d0.asciidoc @@ -0,0 +1,531 @@ +[source, ruby] +---- +response = client.bulk( + index: 'my-data-stream', + refresh: true, + pipeline: 'my-timestamp-pipeline', + body: [ + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:49:00Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 91_153, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 463_314_616 + }, + usage: { + bytes: 307_007_078, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 585_236 + }, + rss: { + bytes: 102_728 + }, + pagefaults: 120_901, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:45:50Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 124_501, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 982_546_514 + }, + usage: { + bytes: 360_035_574, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 1_339_884 + }, + rss: { + bytes: 381_174 + }, + pagefaults: 178_473, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:44:50Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 38_907, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 862_723_768 + }, + usage: { + bytes: 379_572_388, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 431_227 + }, + rss: { + bytes: 386_580 + }, + pagefaults: 233_166, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:44:40Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 86_706, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 567_160_996 + }, + usage: { + bytes: 103_266_017, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 1_724_908 + }, + rss: { + bytes: 105_431 + }, + pagefaults: 233_166, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:44:00Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 150_069, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 639_054_643 + }, + usage: { + bytes: 265_142_477, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 1_786_511 + }, + rss: { + bytes: 189_235 + }, + pagefaults: 138_172, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:42:40Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 82_260, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 854_735_585 + }, + usage: { + bytes: 309_798_052, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 924_058 + }, + rss: { + bytes: 110_838 + }, + pagefaults: 259_073, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:42:10Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 153_404, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 279_586_406 + }, + usage: { + bytes: 214_904_955, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 1_047_265 + }, + rss: { + bytes: 91_914 + }, + pagefaults: 302_252, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:40:20Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 125_613, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 822_782_853 + }, + usage: { + bytes: 100_475_044, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 2_109_932 + }, + rss: { + bytes: 278_446 + }, + pagefaults: 74_843, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:40:10Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 100_046, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 567_160_996 + }, + usage: { + bytes: 362_826_547, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 1_986_724 + }, + rss: { + bytes: 402_801 + }, + pagefaults: 296_495, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + }, + { + create: {} + }, + { + "@timestamp": '2022-06-21T15:38:30Z', + kubernetes: { + host: 'gke-apps-0', + node: 'gke-apps-0-0', + pod: 'gke-apps-0-0-0', + container: { + cpu: { + usage: { + nanocores: 40_018, + core: { + ns: 12_828_317_850 + }, + node: { + pct: 2.77905e-05 + }, + limit: { + pct: 2.77905e-05 + } + } + }, + memory: { + available: { + bytes: 1_062_428_344 + }, + usage: { + bytes: 265_142_477, + node: { + pct: 0.01770037710617187 + }, + limit: { + pct: 9.923134671484496e-05 + } + }, + workingset: { + bytes: 2_294_743 + }, + rss: { + bytes: 340_623 + }, + pagefaults: 224_530, + majorpagefaults: 0 + }, + start_time: '2021-03-30T07:59:06Z', + name: 'container-name-44' + }, + namespace: 'namespace26' + } + } + ] +) +puts response +---- diff --git a/docs/examples/guide/64622409407316d2d47094e692d9b516.asciidoc b/docs/examples/guide/64622409407316d2d47094e692d9b516.asciidoc index 7a2a276282..f258e13d73 100644 --- a/docs/examples/guide/64622409407316d2d47094e692d9b516.asciidoc +++ b/docs/examples/guide/64622409407316d2d47094e692d9b516.asciidoc @@ -5,7 +5,7 @@ response = client.ml.evaluate_data_frame( index: 'student_performance_mathematics_reg', query: { term: { - "ml.is_training": { + 'ml.is_training' => { value: false } } diff --git a/docs/examples/guide/64b9baa6d7556b960b29698f3383aa31.asciidoc b/docs/examples/guide/64b9baa6d7556b960b29698f3383aa31.asciidoc deleted file mode 100644 index d17c9ffd6f..0000000000 --- a/docs/examples/guide/64b9baa6d7556b960b29698f3383aa31.asciidoc +++ /dev/null @@ -1,23 +0,0 @@ -[source, ruby] ----- -response = client.reindex( - body: { - source: { - remote: { - host: 'http://otherhost:9200' - }, - index: 'source', - size: 10, - query: { - match: { - test: 'data' - } - } - }, - dest: { - index: 'dest' - } - } -) -puts response ----- diff --git a/docs/examples/guide/657cf67bbc48f3b8c7fa15e275a5ef72.asciidoc b/docs/examples/guide/657cf67bbc48f3b8c7fa15e275a5ef72.asciidoc index c0677f3cf4..c19003cff0 100644 --- a/docs/examples/guide/657cf67bbc48f3b8c7fa15e275a5ef72.asciidoc +++ b/docs/examples/guide/657cf67bbc48f3b8c7fa15e275a5ef72.asciidoc @@ -6,7 +6,7 @@ response = client.cluster.put_component_template( template: { mappings: { properties: { - "host.name": { + 'host.name' => { type: 'keyword' } } diff --git a/docs/examples/guide/65e892a362d940e4a74965f21c15ca09.asciidoc b/docs/examples/guide/65e892a362d940e4a74965f21c15ca09.asciidoc new file mode 100644 index 0000000000..41754cb744 --- /dev/null +++ b/docs/examples/guide/65e892a362d940e4a74965f21c15ca09.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.reindex( + wait_for_completion: false, + body: { + source: { + index: 'test-data', + size: 50 + }, + dest: { + index: 'openai-embeddings', + pipeline: 'openai_embeddings' + } + } +) +puts response +---- diff --git a/docs/examples/guide/6606d46685d10377b996b5f20f1229b5.asciidoc b/docs/examples/guide/6606d46685d10377b996b5f20f1229b5.asciidoc new file mode 100644 index 0000000000..53dc0cf460 --- /dev/null +++ b/docs/examples/guide/6606d46685d10377b996b5f20f1229b5.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.connector.update_index_name( + connector_id: 'my-connector', + body: { + index_name: 'data-from-my-google-drive' + } +) +puts response +---- diff --git a/docs/examples/guide/66c64bffe3a15cf260baa0c0118aa4ea.asciidoc b/docs/examples/guide/66c64bffe3a15cf260baa0c0118aa4ea.asciidoc deleted file mode 100644 index 0db9a2f14a..0000000000 --- a/docs/examples/guide/66c64bffe3a15cf260baa0c0118aa4ea.asciidoc +++ /dev/null @@ -1,7 +0,0 @@ -[source, ruby] ----- -response = client.enrich.execute_policy( - name: 'my-policy' -) -puts response ----- diff --git a/docs/examples/guide/682336e5232c9ad3d866cb203d1c58c1.asciidoc b/docs/examples/guide/682336e5232c9ad3d866cb203d1c58c1.asciidoc new file mode 100644 index 0000000000..e8846eef91 --- /dev/null +++ b/docs/examples/guide/682336e5232c9ad3d866cb203d1c58c1.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'azure-openai-embeddings', + body: { + mappings: { + properties: { + content_embedding: { + type: 'dense_vector', + dims: 1536, + element_type: 'float', + similarity: 'dot_product' + }, + content: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/6843d859e2965d17cad4f033c81db83f.asciidoc b/docs/examples/guide/6843d859e2965d17cad4f033c81db83f.asciidoc new file mode 100644 index 0000000000..2ee2a2cd46 --- /dev/null +++ b/docs/examples/guide/6843d859e2965d17cad4f033c81db83f.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'my-data-stream-template', + body: { + index_patterns: [ + 'my-data-stream*' + ], + data_stream: {}, + priority: 500, + template: { + settings: { + 'sort.field' => [ + '@timestamp' + ], + 'sort.order' => [ + 'desc' + ] + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/6856f7c6a732ab55ca71c1ee2ec2bbad.asciidoc b/docs/examples/guide/6856f7c6a732ab55ca71c1ee2ec2bbad.asciidoc index 38fd9ee855..7d703f6c47 100644 --- a/docs/examples/guide/6856f7c6a732ab55ca71c1ee2ec2bbad.asciidoc +++ b/docs/examples/guide/6856f7c6a732ab55ca71c1ee2ec2bbad.asciidoc @@ -19,7 +19,7 @@ response = client.index( id: 1, refresh: true, body: { - "network.name": 'net-1', + 'network.name' => 'net-1', latency_histo: { values: [ 0.1, @@ -45,7 +45,7 @@ response = client.index( id: 2, refresh: true, body: { - "network.name": 'net-2', + 'network.name' => 'net-2', latency_histo: { values: [ 0.1, diff --git a/docs/examples/guide/6894596e924b6180bfc77428ba89769f.asciidoc b/docs/examples/guide/6894596e924b6180bfc77428ba89769f.asciidoc deleted file mode 100644 index a2364c6792..0000000000 --- a/docs/examples/guide/6894596e924b6180bfc77428ba89769f.asciidoc +++ /dev/null @@ -1,31 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'image-index', - body: { - mappings: { - properties: { - "image-vector": { - type: 'dense_vector', - dims: 3, - index: true, - similarity: 'l2_norm' - }, - "title-vector": { - type: 'dense_vector', - dims: 5, - index: true, - similarity: 'l2_norm' - }, - title: { - type: 'text' - }, - "file-type": { - type: 'keyword' - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/692606cc6d6462becc321d92961a3bac.asciidoc b/docs/examples/guide/692606cc6d6462becc321d92961a3bac.asciidoc new file mode 100644 index 0000000000..5c2ccaeef8 --- /dev/null +++ b/docs/examples/guide/692606cc6d6462becc321d92961a3bac.asciidoc @@ -0,0 +1,13 @@ +[source, ruby] +---- +response = client.text_structure.test_grok_pattern( + body: { + grok_pattern: 'Hello %{WORD:first_name} %{WORD:last_name}', + text: [ + 'Hello John Doe', + 'this does not match' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/698e0a2b67ba7842caa801d9ef46ebe3.asciidoc b/docs/examples/guide/698e0a2b67ba7842caa801d9ef46ebe3.asciidoc index 6c7b87e34c..8122a10ef3 100644 --- a/docs/examples/guide/698e0a2b67ba7842caa801d9ef46ebe3.asciidoc +++ b/docs/examples/guide/698e0a2b67ba7842caa801d9ef46ebe3.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { diff --git a/docs/examples/guide/69d9b8fd364596aa37eae6864d8a6d89.asciidoc b/docs/examples/guide/69d9b8fd364596aa37eae6864d8a6d89.asciidoc index 9d6669c3d0..6e4b5cb2d9 100644 --- a/docs/examples/guide/69d9b8fd364596aa37eae6864d8a6d89.asciidoc +++ b/docs/examples/guide/69d9b8fd364596aa37eae6864d8a6d89.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { sort: [ { - "result.execution_time": 'desc' + 'result.execution_time' => 'desc' } ] } diff --git a/docs/examples/guide/6a3a578ce37fb2c63ccfab7f75db9bae.asciidoc b/docs/examples/guide/6a3a578ce37fb2c63ccfab7f75db9bae.asciidoc index fadbfec9dc..f3a30d6ace 100644 --- a/docs/examples/guide/6a3a578ce37fb2c63ccfab7f75db9bae.asciidoc +++ b/docs/examples/guide/6a3a578ce37fb2c63ccfab7f75db9bae.asciidoc @@ -3,8 +3,8 @@ response = client.cluster.put_settings( body: { persistent: { - "ingest.geoip.downloader.enabled": false, - "indices.lifecycle.history_index_enabled": false + 'ingest.geoip.downloader.enabled' => false, + 'indices.lifecycle.history_index_enabled' => false } } ) diff --git a/docs/examples/guide/6aa2941855d13f365f70aa8767ecb137.asciidoc b/docs/examples/guide/6aa2941855d13f365f70aa8767ecb137.asciidoc index 444945ae1a..735e95268d 100644 --- a/docs/examples/guide/6aa2941855d13f365f70aa8767ecb137.asciidoc +++ b/docs/examples/guide/6aa2941855d13f365f70aa8767ecb137.asciidoc @@ -46,7 +46,7 @@ response = client.search( } }, sort: { - "city.raw": 'asc' + 'city.raw' => 'asc' }, aggregations: { "Cities": { diff --git a/docs/examples/guide/6af9dc1c3240aa8e623ff3622bcb1b48.asciidoc b/docs/examples/guide/6af9dc1c3240aa8e623ff3622bcb1b48.asciidoc index fae4bd7ec7..24cec3e577 100644 --- a/docs/examples/guide/6af9dc1c3240aa8e623ff3622bcb1b48.asciidoc +++ b/docs/examples/guide/6af9dc1c3240aa8e623ff3622bcb1b48.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.exclude._ip": '192.168.2.*' + 'cluster.routing.allocation.exclude._ip' => '192.168.2.*' } } ) diff --git a/docs/examples/guide/6b8c5c8145c287c4fc535fa57ccf95a7.asciidoc b/docs/examples/guide/6b8c5c8145c287c4fc535fa57ccf95a7.asciidoc new file mode 100644 index 0000000000..d3fd22a7a7 --- /dev/null +++ b/docs/examples/guide/6b8c5c8145c287c4fc535fa57ccf95a7.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.sync_job_list( + status: 'pending' +) +puts response +---- diff --git a/docs/examples/guide/6bbc613bd4f9aec1bbdbabf5db021d28.asciidoc b/docs/examples/guide/6bbc613bd4f9aec1bbdbabf5db021d28.asciidoc index e5d610f46c..cb4d64e948 100644 --- a/docs/examples/guide/6bbc613bd4f9aec1bbdbabf5db021d28.asciidoc +++ b/docs/examples/guide/6bbc613bd4f9aec1bbdbabf5db021d28.asciidoc @@ -12,12 +12,12 @@ response = client.search( }, { match: { - "title.original": 'quick brown fox' + 'title.original' => 'quick brown fox' } }, { match: { - "title.shingles": 'quick brown fox' + 'title.shingles' => 'quick brown fox' } } ] diff --git a/docs/examples/guide/6c72f6791ba9223943f7556c5bfaa728.asciidoc b/docs/examples/guide/6c72f6791ba9223943f7556c5bfaa728.asciidoc index 4a22713d9e..5cb5c17ec4 100644 --- a/docs/examples/guide/6c72f6791ba9223943f7556c5bfaa728.asciidoc +++ b/docs/examples/guide/6c72f6791ba9223943f7556c5bfaa728.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, fields: [ diff --git a/docs/examples/guide/6cd083045bf06e80b83889a939a18451.asciidoc b/docs/examples/guide/6cd083045bf06e80b83889a939a18451.asciidoc index 26d04bf588..4e3c9675a1 100644 --- a/docs/examples/guide/6cd083045bf06e80b83889a939a18451.asciidoc +++ b/docs/examples/guide/6cd083045bf06e80b83889a939a18451.asciidoc @@ -44,12 +44,12 @@ response = client.search( must: [ { match: { - "user.first": 'Alice' + 'user.first' => 'Alice' } }, { match: { - "user.last": 'Smith' + 'user.last' => 'Smith' } } ] @@ -72,12 +72,12 @@ response = client.search( must: [ { match: { - "user.first": 'Alice' + 'user.first' => 'Alice' } }, { match: { - "user.last": 'White' + 'user.last' => 'White' } } ] @@ -86,7 +86,7 @@ response = client.search( inner_hits: { highlight: { fields: { - "user.first": {} + 'user.first' => {} } } } diff --git a/docs/examples/guide/6cf3307c00f464c46475e352e067d714.asciidoc b/docs/examples/guide/6cf3307c00f464c46475e352e067d714.asciidoc index d6910c7aa2..97ada0749d 100644 --- a/docs/examples/guide/6cf3307c00f464c46475e352e067d714.asciidoc +++ b/docs/examples/guide/6cf3307c00f464c46475e352e067d714.asciidoc @@ -10,7 +10,7 @@ response = client.search( }, filter: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { top_left: { lat: 40.73, lon: -74.1 diff --git a/docs/examples/guide/6e1ae8d6103e0b77f14fb0ea1bfb7ffa.asciidoc b/docs/examples/guide/6e1ae8d6103e0b77f14fb0ea1bfb7ffa.asciidoc new file mode 100644 index 0000000000..b9e5cc79c0 --- /dev/null +++ b/docs/examples/guide/6e1ae8d6103e0b77f14fb0ea1bfb7ffa.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'GEOMETRYCOLLECTION (POINT (1000.0 100.0), LINESTRING (1001.0 100.0, 1002.0 100.0))' + } +) +puts response +---- diff --git a/docs/examples/guide/6ea062455229151e311869a81ee40252.asciidoc b/docs/examples/guide/6ea062455229151e311869a81ee40252.asciidoc index ad44163eb6..c597c84956 100644 --- a/docs/examples/guide/6ea062455229151e311869a81ee40252.asciidoc +++ b/docs/examples/guide/6ea062455229151e311869a81ee40252.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } @@ -16,7 +16,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } @@ -28,7 +28,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/6edfc35a66afd9b884431fccf48fdbf5.asciidoc b/docs/examples/guide/6edfc35a66afd9b884431fccf48fdbf5.asciidoc new file mode 100644 index 0000000000..474dddba52 --- /dev/null +++ b/docs/examples/guide/6edfc35a66afd9b884431fccf48fdbf5.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.indices.analyze( + body: { + tokenizer: 'standard', + filter: [ + 'lowercase', + { + type: 'synonym_graph', + synonyms: [ + 'pc => personal computer', + 'computer, pc, laptop' + ] + } + ], + text: 'Check how PC synonyms work' + } +) +puts response +---- diff --git a/docs/examples/guide/6f2208e90810ea6da751fe25fcf456ec.asciidoc b/docs/examples/guide/6f2208e90810ea6da751fe25fcf456ec.asciidoc deleted file mode 100644 index b16b009d0c..0000000000 --- a/docs/examples/guide/6f2208e90810ea6da751fe25fcf456ec.asciidoc +++ /dev/null @@ -1,84 +0,0 @@ -[source, ruby] ----- -response = client.index( - index: 'metrics_index', - id: 1, - body: { - "network.name": 'net-1', - latency_histo: { - values: [ - 1, - 3, - 8, - 12, - 15 - ], - counts: [ - 3, - 7, - 23, - 12, - 6 - ] - } - } -) -puts response - -response = client.index( - index: 'metrics_index', - id: 2, - body: { - "network.name": 'net-2', - latency_histo: { - values: [ - 1, - 6, - 8, - 12, - 14 - ], - counts: [ - 8, - 17, - 8, - 7, - 6 - ] - } - } -) -puts response - -response = client.search( - index: 'metrics_index', - size: 0, - filter_path: 'aggregations', - body: { - aggregations: { - latency_ranges: { - range: { - field: 'latency_histo', - ranges: [ - { - to: 2 - }, - { - from: 2, - to: 3 - }, - { - from: 3, - to: 10 - }, - { - from: 10 - } - ] - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/6f5adbd55a3a2760e7fe9d32df18b1a1.asciidoc b/docs/examples/guide/6f5adbd55a3a2760e7fe9d32df18b1a1.asciidoc new file mode 100644 index 0000000000..589c3faf80 --- /dev/null +++ b/docs/examples/guide/6f5adbd55a3a2760e7fe9d32df18b1a1.asciidoc @@ -0,0 +1,13 @@ +[source, ruby] +---- +response = client.index( + index: 'logs', + body: { + timestamp: '2015-05-17T18:12:07.613Z', + request: 'GET index.html', + status_code: 404, + message: 'Error: File not found' + } +) +puts response +---- diff --git a/docs/examples/guide/6fbbf40cab0187f544ff7bca31d18d57.asciidoc b/docs/examples/guide/6fbbf40cab0187f544ff7bca31d18d57.asciidoc new file mode 100644 index 0000000000..fce927f338 --- /dev/null +++ b/docs/examples/guide/6fbbf40cab0187f544ff7bca31d18d57.asciidoc @@ -0,0 +1,58 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'Polygon', + coordinates: [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ], + [ + [ + 100.2, + 0.2 + ], + [ + 100.8, + 0.2 + ], + [ + 100.8, + 0.8 + ], + [ + 100.2, + 0.8 + ], + [ + 100.2, + 0.2 + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/6fd82baa17a48e09e3d2eed514af7f46.asciidoc b/docs/examples/guide/6fd82baa17a48e09e3d2eed514af7f46.asciidoc new file mode 100644 index 0000000000..1b94f68c05 --- /dev/null +++ b/docs/examples/guide/6fd82baa17a48e09e3d2eed514af7f46.asciidoc @@ -0,0 +1,68 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'MultiLineString', + coordinates: [ + [ + [ + 102, + 2 + ], + [ + 103, + 2 + ], + [ + 103, + 3 + ], + [ + 102, + 3 + ] + ], + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ] + ], + [ + [ + 100.2, + 0.2 + ], + [ + 100.8, + 0.2 + ], + [ + 100.8, + 0.8 + ], + [ + 100.2, + 0.8 + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/7011fcdd231804f9c3894154ae2c3fbc.asciidoc b/docs/examples/guide/7011fcdd231804f9c3894154ae2c3fbc.asciidoc new file mode 100644 index 0000000000..24da6ea4c5 --- /dev/null +++ b/docs/examples/guide/7011fcdd231804f9c3894154ae2c3fbc.asciidoc @@ -0,0 +1,16 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index', + body: { + mappings: { + properties: { + 'text.tokens' => { + type: 'sparse_vector' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/7067a498bb6c788854a26443a64b843a.asciidoc b/docs/examples/guide/7067a498bb6c788854a26443a64b843a.asciidoc index 668aae3272..fc0773bed3 100644 --- a/docs/examples/guide/7067a498bb6c788854a26443a64b843a.asciidoc +++ b/docs/examples/guide/7067a498bb6c788854a26443a64b843a.asciidoc @@ -3,7 +3,7 @@ response = client.search( body: { runtime_mappings: { - "amount.signed": { + 'amount.signed' => { type: 'double', script: "\n double amount = doc['amount'].value;\n if (doc['type'].value == 'expense') {\n amount *= -1;\n }\n emit(amount);\n " } @@ -12,7 +12,7 @@ response = client.search( bool: { filter: { range: { - "amount.signed": { + 'amount.signed' => { lt: 10 } } diff --git a/docs/examples/guide/711443504b69d0d296e717c716a223e2.asciidoc b/docs/examples/guide/711443504b69d0d296e717c716a223e2.asciidoc index 9cc3a1c9b2..fbab109146 100644 --- a/docs/examples/guide/711443504b69d0d296e717c716a223e2.asciidoc +++ b/docs/examples/guide/711443504b69d0d296e717c716a223e2.asciidoc @@ -14,12 +14,12 @@ response = client.search( must: [ { match: { - "driver.vehicle.make": 'Powell Motors' + 'driver.vehicle.make' => 'Powell Motors' } }, { match: { - "driver.vehicle.model": 'Canyonero' + 'driver.vehicle.model' => 'Canyonero' } } ] diff --git a/docs/examples/guide/72a3668ddc95d9aec47cc679d1e7afc5.asciidoc b/docs/examples/guide/72a3668ddc95d9aec47cc679d1e7afc5.asciidoc new file mode 100644 index 0000000000..a5e4bdb3ea --- /dev/null +++ b/docs/examples/guide/72a3668ddc95d9aec47cc679d1e7afc5.asciidoc @@ -0,0 +1,31 @@ +[source, ruby] +---- +response = client.cluster.put_settings( + body: { + persistent: { + cluster: { + remote: { + cluster_one: { + seeds: [ + '35.238.149.1:9300' + ], + skip_unavailable: true + }, + cluster_two: { + seeds: [ + '35.238.149.2:9300' + ], + skip_unavailable: false + }, + cluster_three: { + seeds: [ + '35.238.149.3:9300' + ] + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/73250f845738c428246a3ade66a8f54c.asciidoc b/docs/examples/guide/73250f845738c428246a3ade66a8f54c.asciidoc index 08acec51c1..78d1509e59 100644 --- a/docs/examples/guide/73250f845738c428246a3ade66a8f54c.asciidoc +++ b/docs/examples/guide/73250f845738c428246a3ade66a8f54c.asciidoc @@ -29,7 +29,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "weight.combined": { + 'weight.combined' => { type: 'double', script: "\n double s = 0;\n for (double w : doc['weight']) {\n s += w;\n }\n emit(s);\n " } diff --git a/docs/examples/guide/7353d42289155bb864504fd62efc6979.asciidoc b/docs/examples/guide/7353d42289155bb864504fd62efc6979.asciidoc new file mode 100644 index 0000000000..541412dae2 --- /dev/null +++ b/docs/examples/guide/7353d42289155bb864504fd62efc6979.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.search( + index: 'my-image-index', + body: { + size: 3, + query: { + knn: { + field: 'image-vector', + query_vector: [ + -5, + 9, + -12 + ], + num_candidates: 10 + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/73be1f93d789264e5b972ddb5991bc66.asciidoc b/docs/examples/guide/73be1f93d789264e5b972ddb5991bc66.asciidoc index 97a5797419..ddaf86b2a1 100644 --- a/docs/examples/guide/73be1f93d789264e5b972ddb5991bc66.asciidoc +++ b/docs/examples/guide/73be1f93d789264e5b972ddb5991bc66.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "logger.org.elasticsearch.discovery": 'DEBUG' + 'logger.org.elasticsearch.discovery' => 'DEBUG' } } ) diff --git a/docs/examples/guide/73ebc89cb32adb389ae16bb088d7c7e6.asciidoc b/docs/examples/guide/73ebc89cb32adb389ae16bb088d7c7e6.asciidoc index f894cb224b..2296b26fd4 100644 --- a/docs/examples/guide/73ebc89cb32adb389ae16bb088d7c7e6.asciidoc +++ b/docs/examples/guide/73ebc89cb32adb389ae16bb088d7c7e6.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.enable": nil + 'cluster.routing.allocation.enable' => nil } } ) diff --git a/docs/examples/guide/7456ef459d510d66ba4492cc9fbdc6c6.asciidoc b/docs/examples/guide/7456ef459d510d66ba4492cc9fbdc6c6.asciidoc index 2913c0d787..7f77edf783 100644 --- a/docs/examples/guide/7456ef459d510d66ba4492cc9fbdc6c6.asciidoc +++ b/docs/examples/guide/7456ef459d510d66ba4492cc9fbdc6c6.asciidoc @@ -9,7 +9,7 @@ response = client.cluster.put_settings( mode: nil, seeds: nil, skip_unavailable: nil, - "transport.compress": nil + 'transport.compress' => nil } } } diff --git a/docs/examples/guide/747a4b5001423938d7d05399d28f1995.asciidoc b/docs/examples/guide/747a4b5001423938d7d05399d28f1995.asciidoc index f1a516a9e3..a388fcf38a 100644 --- a/docs/examples/guide/747a4b5001423938d7d05399d28f1995.asciidoc +++ b/docs/examples/guide/747a4b5001423938d7d05399d28f1995.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "indices.lifecycle.poll_interval": '1m' + 'indices.lifecycle.poll_interval' => '1m' } } ) diff --git a/docs/examples/guide/74da377bccad43da2b0e276c086d26ba.asciidoc b/docs/examples/guide/74da377bccad43da2b0e276c086d26ba.asciidoc new file mode 100644 index 0000000000..2f9c916c48 --- /dev/null +++ b/docs/examples/guide/74da377bccad43da2b0e276c086d26ba.asciidoc @@ -0,0 +1,32 @@ +[source, ruby] +---- +response = client.cluster.info( + target: '_all' +) +puts response + +response = client.cluster.info( + target: 'http' +) +puts response + +response = client.cluster.info( + target: 'ingest' +) +puts response + +response = client.cluster.info( + target: 'thread_pool' +) +puts response + +response = client.cluster.info( + target: 'script' +) +puts response + +response = client.cluster.info( + target: 'http,ingest' +) +puts response +---- diff --git a/docs/examples/guide/75c2bb6bbeb70d263cb9a5c588e8298e.asciidoc b/docs/examples/guide/75c2bb6bbeb70d263cb9a5c588e8298e.asciidoc deleted file mode 100644 index d19b25d283..0000000000 --- a/docs/examples/guide/75c2bb6bbeb70d263cb9a5c588e8298e.asciidoc +++ /dev/null @@ -1,23 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'byte-image-index', - body: { - mappings: { - properties: { - "byte-image-vector": { - type: 'dense_vector', - element_type: 'byte', - dims: 2, - index: true, - similarity: 'cosine' - }, - title: { - type: 'text' - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/75c347b181112d2c4538c01ade903afe.asciidoc b/docs/examples/guide/75c347b181112d2c4538c01ade903afe.asciidoc index 210ad8e32c..87a6ce8cf2 100644 --- a/docs/examples/guide/75c347b181112d2c4538c01ade903afe.asciidoc +++ b/docs/examples/guide/75c347b181112d2c4538c01ade903afe.asciidoc @@ -6,7 +6,7 @@ response = client.indices.validate_query( body: { query: { match: { - "user.id": { + 'user.id' => { query: 'kimchy', fuzziness: 'auto' } diff --git a/docs/examples/guide/75e229852d1404040bb2e83723c0f1db.asciidoc b/docs/examples/guide/75e229852d1404040bb2e83723c0f1db.asciidoc deleted file mode 100644 index e158dbf7ca..0000000000 --- a/docs/examples/guide/75e229852d1404040bb2e83723c0f1db.asciidoc +++ /dev/null @@ -1,14 +0,0 @@ -[source, ruby] ----- -response = client.search( - index: 'customer', - body: { - query: { - match: { - firstname: 'Jennifer' - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/763ce1377c8dfa1ca6a042d8ee99f4f5.asciidoc b/docs/examples/guide/763ce1377c8dfa1ca6a042d8ee99f4f5.asciidoc new file mode 100644 index 0000000000..2d38c96984 --- /dev/null +++ b/docs/examples/guide/763ce1377c8dfa1ca6a042d8ee99f4f5.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.indices.rollover( + alias: 'k9s' +) +puts response +---- diff --git a/docs/examples/guide/76c167d8ab305cb43b594f140c902dfe.asciidoc b/docs/examples/guide/76c167d8ab305cb43b594f140c902dfe.asciidoc index 645b18d17d..1096e55f6b 100644 --- a/docs/examples/guide/76c167d8ab305cb43b594f140c902dfe.asciidoc +++ b/docs/examples/guide/76c167d8ab305cb43b594f140c902dfe.asciidoc @@ -5,9 +5,9 @@ response = client.indices.shrink( target: 'my_target_index', body: { settings: { - "index.number_of_replicas": 1, - "index.number_of_shards": 1, - "index.codec": 'best_compression' + 'index.number_of_replicas' => 1, + 'index.number_of_shards' => 1, + 'index.codec' => 'best_compression' }, aliases: { my_search_indices: {} diff --git a/docs/examples/guide/77518e8c6198acfe77c0934fd2fe65cb.asciidoc b/docs/examples/guide/77518e8c6198acfe77c0934fd2fe65cb.asciidoc new file mode 100644 index 0000000000..ea938fe04b --- /dev/null +++ b/docs/examples/guide/77518e8c6198acfe77c0934fd2fe65cb.asciidoc @@ -0,0 +1,32 @@ +[source, ruby] +---- +response = client.text_structure.find_message_structure( + body: { + messages: [ + '[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128', + '[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]', + '[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]', + '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]', + '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]', + '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]', + '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]', + '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]', + '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]', + '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]', + '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]', + '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]', + '[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]', + '[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]', + '[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]', + '[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled', + '[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled', + '[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled', + '[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]', + '[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]', + '[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized', + '[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/78e20b4cff470ed7357de1fd74bcfeb7.asciidoc b/docs/examples/guide/78e20b4cff470ed7357de1fd74bcfeb7.asciidoc new file mode 100644 index 0000000000..b8e9fdf7cc --- /dev/null +++ b/docs/examples/guide/78e20b4cff470ed7357de1fd74bcfeb7.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.indices.update_aliases( + body: { + actions: [ + { + remove: { + index: 'index1', + alias: 'logs-non-existing' + } + }, + { + add: { + index: 'index2', + alias: 'logs-non-existing' + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/790c49fe2ec638e5e8db51a9236bba35.asciidoc b/docs/examples/guide/790c49fe2ec638e5e8db51a9236bba35.asciidoc index 3a498a77b6..ea327204d5 100644 --- a/docs/examples/guide/790c49fe2ec638e5e8db51a9236bba35.asciidoc +++ b/docs/examples/guide/790c49fe2ec638e5e8db51a9236bba35.asciidoc @@ -10,7 +10,7 @@ response = client.search( }, filter: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { top_left: { lat: 40.73, lon: -74.1 diff --git a/docs/examples/guide/79e8bbbd6c440a21b0b4260c8cb1a61c.asciidoc b/docs/examples/guide/79e8bbbd6c440a21b0b4260c8cb1a61c.asciidoc new file mode 100644 index 0000000000..1a46160372 --- /dev/null +++ b/docs/examples/guide/79e8bbbd6c440a21b0b4260c8cb1a61c.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'LINESTRING (-77.03653 38.897676, -77.009051 38.889939)' + } +) +puts response +---- diff --git a/docs/examples/guide/79feb4a0c0a21b7015a52f9736cd4683.asciidoc b/docs/examples/guide/79feb4a0c0a21b7015a52f9736cd4683.asciidoc index 31807ef9ce..5aa84331b4 100644 --- a/docs/examples/guide/79feb4a0c0a21b7015a52f9736cd4683.asciidoc +++ b/docs/examples/guide/79feb4a0c0a21b7015a52f9736cd4683.asciidoc @@ -58,7 +58,7 @@ response = client.search( path: 'comments.votes', query: { match: { - "comments.votes.voter": 'kimchy' + 'comments.votes.voter' => 'kimchy' } }, inner_hits: {} diff --git a/docs/examples/guide/7b3e913368e96eaa6e22e0d03c81310e.asciidoc b/docs/examples/guide/7b3e913368e96eaa6e22e0d03c81310e.asciidoc index c8ce52a6ab..fea4b10462 100644 --- a/docs/examples/guide/7b3e913368e96eaa6e22e0d03c81310e.asciidoc +++ b/docs/examples/guide/7b3e913368e96eaa6e22e0d03c81310e.asciidoc @@ -4,7 +4,7 @@ response = client.indices.create( index: 'my-index-000001', body: { settings: { - "index.store.type": 'hybridfs' + 'index.store.type' => 'hybridfs' } } ) diff --git a/docs/examples/guide/7b7a828c21c856a3cbc41fd2f85108bf.asciidoc b/docs/examples/guide/7b7a828c21c856a3cbc41fd2f85108bf.asciidoc index ae39efe336..bfe7b4214e 100644 --- a/docs/examples/guide/7b7a828c21c856a3cbc41fd2f85108bf.asciidoc +++ b/docs/examples/guide/7b7a828c21c856a3cbc41fd2f85108bf.asciidoc @@ -10,7 +10,7 @@ response = client.search( body: { query: { range: { - "http.response.bytes": { + 'http.response.bytes' => { lt: 2_000_000 } } diff --git a/docs/examples/guide/7c2b45de463c8c5a06e933b1793b584b.asciidoc b/docs/examples/guide/7c2b45de463c8c5a06e933b1793b584b.asciidoc deleted file mode 100644 index 14bcc33dea..0000000000 --- a/docs/examples/guide/7c2b45de463c8c5a06e933b1793b584b.asciidoc +++ /dev/null @@ -1,38 +0,0 @@ -[source, ruby] ----- -response = client.cluster.put_component_template( - name: 'my-weather-sensor-mappings', - body: { - template: { - mappings: { - properties: { - sensor_id: { - type: 'keyword', - time_series_dimension: true - }, - location: { - type: 'keyword', - time_series_dimension: true - }, - temperature: { - type: 'half_float', - time_series_metric: 'gauge' - }, - humidity: { - type: 'half_float', - time_series_metric: 'gauge' - }, - "@timestamp": { - type: 'date', - format: 'strict_date_optional_time' - } - } - } - }, - _meta: { - description: 'Mappings for weather sensor data' - } - } -) -puts response ----- diff --git a/docs/examples/guide/7c8f207e43115ea8f20d2298be5aaebc.asciidoc b/docs/examples/guide/7c8f207e43115ea8f20d2298be5aaebc.asciidoc new file mode 100644 index 0000000000..9a73648d67 --- /dev/null +++ b/docs/examples/guide/7c8f207e43115ea8f20d2298be5aaebc.asciidoc @@ -0,0 +1,36 @@ +[source, ruby] +---- +response = client.simulate.ingest( + body: { + docs: [ + { + _index: 'my-index', + _id: 'id', + _source: { + foo: 'bar' + } + }, + { + _index: 'my-index', + _id: 'id', + _source: { + foo: 'rab' + } + } + ], + pipeline_substitutions: { + "my-pipeline": { + processors: [ + { + set: { + field: 'field3', + value: 'value3' + } + } + ] + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/7d3ffd32f2747efb7d0fb1f0dc617ff4.asciidoc b/docs/examples/guide/7d3ffd32f2747efb7d0fb1f0dc617ff4.asciidoc deleted file mode 100644 index ce117d4c25..0000000000 --- a/docs/examples/guide/7d3ffd32f2747efb7d0fb1f0dc617ff4.asciidoc +++ /dev/null @@ -1,26 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'test_index', - body: { - settings: { - index: { - analysis: { - filter: { - synonym: { - type: 'synonym', - format: 'wordnet', - synonyms: [ - "s(100000001,1,'abstain',v,1,0).", - "s(100000001,2,'refrain',v,1,0).", - "s(100000001,3,'desist',v,1,0)." - ] - } - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/7e48648ca27024831c60b455e836c496.asciidoc b/docs/examples/guide/7e48648ca27024831c60b455e836c496.asciidoc new file mode 100644 index 0000000000..86a64fc64d --- /dev/null +++ b/docs/examples/guide/7e48648ca27024831c60b455e836c496.asciidoc @@ -0,0 +1,26 @@ +[source, ruby] +---- +response = client.search( + body: { + query: { + pinned: { + docs: [ + { + _index: 'my-index-000001', + _id: '1' + }, + { + _id: '4' + } + ], + organic: { + match: { + description: 'iphone' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/7f697eb436dfa3c30dfe610d8c32d132.asciidoc b/docs/examples/guide/7f697eb436dfa3c30dfe610d8c32d132.asciidoc deleted file mode 100644 index a975cb57d0..0000000000 --- a/docs/examples/guide/7f697eb436dfa3c30dfe610d8c32d132.asciidoc +++ /dev/null @@ -1,24 +0,0 @@ -[source, ruby] ----- -response = client.reindex( - body: { - source: { - remote: { - host: 'http://otherhost:9200', - socket_timeout: '1m', - connect_timeout: '10s' - }, - index: 'source', - query: { - match: { - test: 'data' - } - } - }, - dest: { - index: 'dest' - } - } -) -puts response ----- diff --git a/docs/examples/guide/7fe9f0a583e079f7fc6fd64d12b6e9e5.asciidoc b/docs/examples/guide/7fe9f0a583e079f7fc6fd64d12b6e9e5.asciidoc index 0b4e314432..22721e0621 100644 --- a/docs/examples/guide/7fe9f0a583e079f7fc6fd64d12b6e9e5.asciidoc +++ b/docs/examples/guide/7fe9f0a583e079f7fc6fd64d12b6e9e5.asciidoc @@ -5,7 +5,7 @@ response = client.search( size: 0, body: { runtime_mappings: { - "price.weighted": { + 'price.weighted' => { type: 'double', script: "\n double price = doc['price'].value;\n if (doc['promoted'].value) {\n price *= 0.8;\n }\n emit(price);\n " } diff --git a/docs/examples/guide/80edd2124a822d9f9bf22ecc49d2c2e9.asciidoc b/docs/examples/guide/80edd2124a822d9f9bf22ecc49d2c2e9.asciidoc new file mode 100644 index 0000000000..a7f8eeaa34 --- /dev/null +++ b/docs/examples/guide/80edd2124a822d9f9bf22ecc49d2c2e9.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.synonyms.get_synonym_rule( + set_id: 'my-synonyms-set', + rule_id: 'test-1' +) +puts response +---- diff --git a/docs/examples/guide/81612c2537386e031b7eb604f6756a71.asciidoc b/docs/examples/guide/81612c2537386e031b7eb604f6756a71.asciidoc index 8824a16df7..4db274b124 100644 --- a/docs/examples/guide/81612c2537386e031b7eb604f6756a71.asciidoc +++ b/docs/examples/guide/81612c2537386e031b7eb604f6756a71.asciidoc @@ -5,7 +5,7 @@ response = client.indices.clone( target: 'my_target_index', body: { settings: { - "index.number_of_shards": 5 + 'index.number_of_shards' => 5 }, aliases: { my_search_indices: {} diff --git a/docs/examples/guide/8194f1fae6aa72ab91ea559daad932d4.asciidoc b/docs/examples/guide/8194f1fae6aa72ab91ea559daad932d4.asciidoc index aa8bd31262..7b23195fec 100644 --- a/docs/examples/guide/8194f1fae6aa72ab91ea559daad932d4.asciidoc +++ b/docs/examples/guide/8194f1fae6aa72ab91ea559daad932d4.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/819e00cc6547d925d80090b94e0650d7.asciidoc b/docs/examples/guide/819e00cc6547d925d80090b94e0650d7.asciidoc index 2ebb8a7559..85d352a923 100644 --- a/docs/examples/guide/819e00cc6547d925d80090b94e0650d7.asciidoc +++ b/docs/examples/guide/819e00cc6547d925d80090b94e0650d7.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, _source: [ diff --git a/docs/examples/guide/8206a7cc615ad93fec322513b8fdd4fd.asciidoc b/docs/examples/guide/8206a7cc615ad93fec322513b8fdd4fd.asciidoc new file mode 100644 index 0000000000..20cd926790 --- /dev/null +++ b/docs/examples/guide/8206a7cc615ad93fec322513b8fdd4fd.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.index( + index: 'job-candidates', + id: 2, + refresh: true, + body: { + name: 'Jason Response', + programming_languages: [ + 'java', + 'php' + ], + required_matches: 2 + } +) +puts response +---- diff --git a/docs/examples/guide/820f689eaaef15fc07abd1073fa880f8.asciidoc b/docs/examples/guide/820f689eaaef15fc07abd1073fa880f8.asciidoc index 610639a4b6..3a68cccb2f 100644 --- a/docs/examples/guide/820f689eaaef15fc07abd1073fa880f8.asciidoc +++ b/docs/examples/guide/820f689eaaef15fc07abd1073fa880f8.asciidoc @@ -6,7 +6,7 @@ response = client.search( size: 20, query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/84490ee2c6c07dbd2101ce2e3751e1aa.asciidoc b/docs/examples/guide/84490ee2c6c07dbd2101ce2e3751e1aa.asciidoc new file mode 100644 index 0000000000..c3f423d9bf --- /dev/null +++ b/docs/examples/guide/84490ee2c6c07dbd2101ce2e3751e1aa.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.reindex( + wait_for_completion: false, + body: { + source: { + index: 'test-data', + size: 50 + }, + dest: { + index: 'cohere-embeddings', + pipeline: 'cohere_embeddings' + } + } +) +puts response +---- diff --git a/docs/examples/guide/844928da2ff9a1394af5347a5e2e4f78.asciidoc b/docs/examples/guide/844928da2ff9a1394af5347a5e2e4f78.asciidoc index 213478f0d9..43ed7d73c0 100644 --- a/docs/examples/guide/844928da2ff9a1394af5347a5e2e4f78.asciidoc +++ b/docs/examples/guide/844928da2ff9a1394af5347a5e2e4f78.asciidoc @@ -3,11 +3,11 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { - "index.indexing.slowlog.threshold.index.warn": '10s', - "index.indexing.slowlog.threshold.index.info": '5s', - "index.indexing.slowlog.threshold.index.debug": '2s', - "index.indexing.slowlog.threshold.index.trace": '500ms', - "index.indexing.slowlog.source": '1000' + 'index.indexing.slowlog.threshold.index.warn' => '10s', + 'index.indexing.slowlog.threshold.index.info' => '5s', + 'index.indexing.slowlog.threshold.index.debug' => '2s', + 'index.indexing.slowlog.threshold.index.trace' => '500ms', + 'index.indexing.slowlog.source' => '1000' } ) puts response diff --git a/docs/examples/guide/84f3e8524f6ff80e870c03ab71551538.asciidoc b/docs/examples/guide/84f3e8524f6ff80e870c03ab71551538.asciidoc index 12e721f93c..48a97dd3c2 100644 --- a/docs/examples/guide/84f3e8524f6ff80e870c03ab71551538.asciidoc +++ b/docs/examples/guide/84f3e8524f6ff80e870c03ab71551538.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/850bfd0a00d32475a54ac7f87fb4cc4d.asciidoc b/docs/examples/guide/850bfd0a00d32475a54ac7f87fb4cc4d.asciidoc new file mode 100644 index 0000000000..c1f28b57bb --- /dev/null +++ b/docs/examples/guide/850bfd0a00d32475a54ac7f87fb4cc4d.asciidoc @@ -0,0 +1,25 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index-000001', + body: { + runtime_mappings: { + 'measures.voltage' => { + type: 'double', + script: { + source: "if (doc['model_number.keyword'].value.equals('HG537PU'))\n {emit(1.7 * params._source['measures']['voltage']);}\n else{emit(params._source['measures']['voltage']);}" + } + } + }, + query: { + match: { + model_number: 'HG537PU' + } + }, + fields: [ + 'measures.voltage' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/85519a614ae18c998986d46bbad82b76.asciidoc b/docs/examples/guide/85519a614ae18c998986d46bbad82b76.asciidoc index c4dff197e6..6a687a5c7a 100644 --- a/docs/examples/guide/85519a614ae18c998986d46bbad82b76.asciidoc +++ b/docs/examples/guide/85519a614ae18c998986d46bbad82b76.asciidoc @@ -10,8 +10,8 @@ response = client.indices.put_index_template( settings: { number_of_shards: 1, number_of_replicas: 1, - "index.lifecycle.name": 'my_policy', - "index.lifecycle.rollover_alias": 'test-alias' + 'index.lifecycle.name' => 'my_policy', + 'index.lifecycle.rollover_alias' => 'test-alias' } } } diff --git a/docs/examples/guide/856c10ad554c26b70f1121454caff40a.asciidoc b/docs/examples/guide/856c10ad554c26b70f1121454caff40a.asciidoc new file mode 100644 index 0000000000..f0ffaae57a --- /dev/null +++ b/docs/examples/guide/856c10ad554c26b70f1121454caff40a.asciidoc @@ -0,0 +1,18 @@ +[source, ruby] +---- +response = client.search( + index: 'byte-image-index', + body: { + knn: { + field: 'byte-image-vector', + query_vector: 'fb09', + k: 10, + num_candidates: 100 + }, + fields: [ + 'title' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/8575c966b004fb124c7afd6bb5827b50.asciidoc b/docs/examples/guide/8575c966b004fb124c7afd6bb5827b50.asciidoc new file mode 100644 index 0000000000..e85d828755 --- /dev/null +++ b/docs/examples/guide/8575c966b004fb124c7afd6bb5827b50.asciidoc @@ -0,0 +1,13 @@ +[source, ruby] +---- +response = client.index( + index: 'books', + body: { + name: 'Snow Crash', + author: 'Neal Stephenson', + release_date: '1992-06-01', + page_count: 470 + } +) +puts response +---- diff --git a/docs/examples/guide/8582e918a6275472d2eba2e95f1dbe77.asciidoc b/docs/examples/guide/8582e918a6275472d2eba2e95f1dbe77.asciidoc index ea1b4705f6..d9c5bd0e03 100644 --- a/docs/examples/guide/8582e918a6275472d2eba2e95f1dbe77.asciidoc +++ b/docs/examples/guide/8582e918a6275472d2eba2e95f1dbe77.asciidoc @@ -3,14 +3,14 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.disk.watermark.low": '90%', - "cluster.routing.allocation.disk.watermark.low.max_headroom": '100GB', - "cluster.routing.allocation.disk.watermark.high": '95%', - "cluster.routing.allocation.disk.watermark.high.max_headroom": '20GB', - "cluster.routing.allocation.disk.watermark.flood_stage": '97%', - "cluster.routing.allocation.disk.watermark.flood_stage.max_headroom": '5GB', - "cluster.routing.allocation.disk.watermark.flood_stage.frozen": '97%', - "cluster.routing.allocation.disk.watermark.flood_stage.frozen.max_headroom": '5GB' + 'cluster.routing.allocation.disk.watermark.low' => '90%', + 'cluster.routing.allocation.disk.watermark.low.max_headroom' => '100GB', + 'cluster.routing.allocation.disk.watermark.high' => '95%', + 'cluster.routing.allocation.disk.watermark.high.max_headroom' => '20GB', + 'cluster.routing.allocation.disk.watermark.flood_stage' => '97%', + 'cluster.routing.allocation.disk.watermark.flood_stage.max_headroom' => '5GB', + 'cluster.routing.allocation.disk.watermark.flood_stage.frozen' => '97%', + 'cluster.routing.allocation.disk.watermark.flood_stage.frozen.max_headroom' => '5GB' } } ) @@ -20,7 +20,7 @@ response = client.indices.put_settings( index: '*', expand_wildcards: 'all', body: { - "index.blocks.read_only_allow_delete": nil + 'index.blocks.read_only_allow_delete' => nil } ) puts response diff --git a/docs/examples/guide/863253bf0ab7d227ff72a0a384f4de8c.asciidoc b/docs/examples/guide/863253bf0ab7d227ff72a0a384f4de8c.asciidoc index 59e12dc8bc..ade82466df 100644 --- a/docs/examples/guide/863253bf0ab7d227ff72a0a384f4de8c.asciidoc +++ b/docs/examples/guide/863253bf0ab7d227ff72a0a384f4de8c.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "indices.lifecycle.poll_interval": nil + 'indices.lifecycle.poll_interval' => nil } } ) diff --git a/docs/examples/guide/867f7d43a78066731ead2e223960fc07.asciidoc b/docs/examples/guide/867f7d43a78066731ead2e223960fc07.asciidoc index 7e90c71357..83c0726045 100644 --- a/docs/examples/guide/867f7d43a78066731ead2e223960fc07.asciidoc +++ b/docs/examples/guide/867f7d43a78066731ead2e223960fc07.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "action.destructive_requires_name": false + 'action.destructive_requires_name' => false } } ) diff --git a/docs/examples/guide/8703f3b1b3895543abc36e2a7a0013d3.asciidoc b/docs/examples/guide/8703f3b1b3895543abc36e2a7a0013d3.asciidoc index df27435751..420db430b5 100644 --- a/docs/examples/guide/8703f3b1b3895543abc36e2a7a0013d3.asciidoc +++ b/docs/examples/guide/8703f3b1b3895543abc36e2a7a0013d3.asciidoc @@ -14,7 +14,7 @@ response = client.indices.create( index: 'index_3', body: { settings: { - "index.priority": 10 + 'index.priority' => 10 } } ) @@ -24,7 +24,7 @@ response = client.indices.create( index: 'index_4', body: { settings: { - "index.priority": 5 + 'index.priority' => 5 } } ) diff --git a/docs/examples/guide/87416e6a1ca2da324dbed6deb05303eb.asciidoc b/docs/examples/guide/87416e6a1ca2da324dbed6deb05303eb.asciidoc index 7c7389a3f0..6f14013326 100644 --- a/docs/examples/guide/87416e6a1ca2da324dbed6deb05303eb.asciidoc +++ b/docs/examples/guide/87416e6a1ca2da324dbed6deb05303eb.asciidoc @@ -5,7 +5,7 @@ response = client.index( id: 1, refresh: true, body: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } ) puts response @@ -21,7 +21,7 @@ response = client.count( body: { query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/88b19973b970adf9b73fca82017d4951.asciidoc b/docs/examples/guide/88b19973b970adf9b73fca82017d4951.asciidoc index deb1b100fd..280dfb3ffa 100644 --- a/docs/examples/guide/88b19973b970adf9b73fca82017d4951.asciidoc +++ b/docs/examples/guide/88b19973b970adf9b73fca82017d4951.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/89d2a3748dc14c6d5d4c6f94b9b03938.asciidoc b/docs/examples/guide/89d2a3748dc14c6d5d4c6f94b9b03938.asciidoc new file mode 100644 index 0000000000..70ef33abaf --- /dev/null +++ b/docs/examples/guide/89d2a3748dc14c6d5d4c6f94b9b03938.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.indices.add_block( + index: 'my_source_index', + block: 'write' +) +puts response +---- diff --git a/docs/examples/guide/89dee10a24ea2727af5b00039a4271bd.asciidoc b/docs/examples/guide/89dee10a24ea2727af5b00039a4271bd.asciidoc new file mode 100644 index 0000000000..36b9db8182 --- /dev/null +++ b/docs/examples/guide/89dee10a24ea2727af5b00039a4271bd.asciidoc @@ -0,0 +1,162 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'tour', + body: { + mappings: { + properties: { + city: { + type: 'keyword', + time_series_dimension: true + }, + category: { + type: 'keyword' + }, + route: { + type: 'long' + }, + name: { + type: 'keyword' + }, + location: { + type: 'geo_point' + }, + "@timestamp": { + type: 'date' + } + } + }, + settings: { + index: { + mode: 'time_series', + routing_path: [ + 'city' + ], + time_series: { + start_time: '2023-01-01T00:00:00Z', + end_time: '2024-01-01T00:00:00Z' + } + } + } + } +) +puts response + +response = client.bulk( + index: 'tour', + refresh: true, + body: [ + { + index: {} + }, + { + "@timestamp": '2023-01-02T09:00:00Z', + route: 0, + location: 'POINT(4.889187 52.373184)', + city: 'Amsterdam', + category: 'Attraction', + name: 'Royal Palace Amsterdam' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-02T10:00:00Z', + route: 1, + location: 'POINT(4.885057 52.370159)', + city: 'Amsterdam', + category: 'Attraction', + name: 'The Amsterdam Dungeon' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-02T13:00:00Z', + route: 2, + location: 'POINT(4.901618 52.369219)', + city: 'Amsterdam', + category: 'Museum', + name: 'Museum Het Rembrandthuis' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-02T16:00:00Z', + route: 3, + location: 'POINT(4.912350 52.374081)', + city: 'Amsterdam', + category: 'Museum', + name: 'NEMO Science Museum' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-03T12:00:00Z', + route: 4, + location: 'POINT(4.914722 52.371667)', + city: 'Amsterdam', + category: 'Museum', + name: 'Nederlands Scheepvaartmuseum' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-04T09:00:00Z', + route: 5, + location: 'POINT(4.401384 51.220292)', + city: 'Antwerp', + category: 'Attraction', + name: 'Cathedral of Our Lady' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-04T12:00:00Z', + route: 6, + location: 'POINT(4.405819 51.221758)', + city: 'Antwerp', + category: 'Museum', + name: 'Snijders&Rockoxhuis' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-04T15:00:00Z', + route: 7, + location: 'POINT(4.405200 51.222900)', + city: 'Antwerp', + category: 'Museum', + name: 'Letterenhuis' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-05T10:00:00Z', + route: 8, + location: 'POINT(2.336389 48.861111)', + city: 'Paris', + category: 'Museum', + name: 'Musée du Louvre' + }, + { + index: {} + }, + { + "@timestamp": '2023-01-05T14:00:00Z', + route: 9, + location: 'POINT(2.327000 48.860000)', + city: 'Paris', + category: 'Museum', + name: 'Musée dOrsay' + } + ] +) +puts response +---- diff --git a/docs/examples/guide/8b301122cbf42be6eafeda714a36559e.asciidoc b/docs/examples/guide/8b301122cbf42be6eafeda714a36559e.asciidoc new file mode 100644 index 0000000000..ad59d2c541 --- /dev/null +++ b/docs/examples/guide/8b301122cbf42be6eafeda714a36559e.asciidoc @@ -0,0 +1,25 @@ +[source, ruby] +---- +response = client.logstash.put_pipeline( + id: 'my_pipeline', + body: { + description: 'Sample pipeline for illustration purposes', + last_modified: '2021-01-02T02:50:51.250Z', + pipeline_metadata: { + type: 'logstash_pipeline', + version: '1' + }, + username: 'elastic', + pipeline: "input {}\n filter { grok {} }\n output {}", + pipeline_settings: { + 'pipeline.workers' => 1, + 'pipeline.batch.size' => 125, + 'pipeline.batch.delay' => 50, + 'queue.type' => 'memory', + 'queue.max_bytes' => '1gb', + 'queue.checkpoint.writes' => 1024 + } + } +) +puts response +---- diff --git a/docs/examples/guide/8b7956a2b88fd798a895d3466d671b58.asciidoc b/docs/examples/guide/8b7956a2b88fd798a895d3466d671b58.asciidoc index d7c32d6de8..031541c239 100644 --- a/docs/examples/guide/8b7956a2b88fd798a895d3466d671b58.asciidoc +++ b/docs/examples/guide/8b7956a2b88fd798a895d3466d671b58.asciidoc @@ -3,8 +3,8 @@ response = client.cluster.put_settings( body: { persistent: { - "http.tracer.include": '*', - "http.tracer.exclude": '' + 'http.tracer.include' => '*', + 'http.tracer.exclude' => '' } } ) diff --git a/docs/examples/guide/8bf1e7a6d529547906ba8b1d6501fa0c.asciidoc b/docs/examples/guide/8bf1e7a6d529547906ba8b1d6501fa0c.asciidoc new file mode 100644 index 0000000000..ba63948337 --- /dev/null +++ b/docs/examples/guide/8bf1e7a6d529547906ba8b1d6501fa0c.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.connector.sync_job_error( + connector_sync_job_id: 'my-connector-sync-job', + body: { + error: 'some-error' + } +) +puts response +---- diff --git a/docs/examples/guide/8c619666488927dac6ecb7dcebca44c2.asciidoc b/docs/examples/guide/8c619666488927dac6ecb7dcebca44c2.asciidoc new file mode 100644 index 0000000000..623878106b --- /dev/null +++ b/docs/examples/guide/8c619666488927dac6ecb7dcebca44c2.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'cohere-embeddings', + body: { + mappings: { + properties: { + content_embedding: { + type: 'dense_vector', + dims: 1024, + element_type: 'byte' + }, + content: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/8d064eda2199de52e5be9ee68a5b7c68.asciidoc b/docs/examples/guide/8d064eda2199de52e5be9ee68a5b7c68.asciidoc new file mode 100644 index 0000000000..8059cf7cea --- /dev/null +++ b/docs/examples/guide/8d064eda2199de52e5be9ee68a5b7c68.asciidoc @@ -0,0 +1,23 @@ +[source, ruby] +---- +response = client.ingest.put_pipeline( + id: 'my-text-embeddings-pipeline', + body: { + description: 'Text embedding pipeline', + processors: [ + { + inference: { + model_id: '.elser_model_2', + input_output: [ + { + input_field: 'my_text_field', + output_field: 'my_tokens' + } + ] + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/8d421c5bec38eecce4679b219cacc9db.asciidoc b/docs/examples/guide/8d421c5bec38eecce4679b219cacc9db.asciidoc index 43956146fa..b89963631f 100644 --- a/docs/examples/guide/8d421c5bec38eecce4679b219cacc9db.asciidoc +++ b/docs/examples/guide/8d421c5bec38eecce4679b219cacc9db.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "load_time.seconds": { + 'load_time.seconds' => { type: 'long', script: { source: "emit(doc['load_time'].value / params.timeUnit)", diff --git a/docs/examples/guide/8d7193902a353872740a3324c60c5001.asciidoc b/docs/examples/guide/8d7193902a353872740a3324c60c5001.asciidoc index bfd706f083..4d7923342e 100644 --- a/docs/examples/guide/8d7193902a353872740a3324c60c5001.asciidoc +++ b/docs/examples/guide/8d7193902a353872740a3324c60c5001.asciidoc @@ -5,8 +5,8 @@ response = client.indices.create( body: { settings: { index: { - "sort.field": 'timestamp', - "sort.order": 'desc' + 'sort.field' => 'timestamp', + 'sort.order' => 'desc' } }, mappings: { diff --git a/docs/examples/guide/8d9b04f2a97f4229dec9e620126de049.asciidoc b/docs/examples/guide/8d9b04f2a97f4229dec9e620126de049.asciidoc new file mode 100644 index 0000000000..f474f9b86f --- /dev/null +++ b/docs/examples/guide/8d9b04f2a97f4229dec9e620126de049.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.cluster.put_settings( + body: { + persistent: { + 'logger.com.amazonaws.request' => 'DEBUG' + } + } +) +puts response +---- diff --git a/docs/examples/guide/8e286a205a1f84f888a6d99f2620c80e.asciidoc b/docs/examples/guide/8e286a205a1f84f888a6d99f2620c80e.asciidoc index 2d08ee5400..59b020a4a3 100644 --- a/docs/examples/guide/8e286a205a1f84f888a6d99f2620c80e.asciidoc +++ b/docs/examples/guide/8e286a205a1f84f888a6d99f2620c80e.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "logger.org.elasticsearch.deprecation": 'OFF' + 'logger.org.elasticsearch.deprecation' => 'OFF' } } ) diff --git a/docs/examples/guide/8e89fee0be6a436c4e3d7c152659c47e.asciidoc b/docs/examples/guide/8e89fee0be6a436c4e3d7c152659c47e.asciidoc new file mode 100644 index 0000000000..412cbd8e26 --- /dev/null +++ b/docs/examples/guide/8e89fee0be6a436c4e3d7c152659c47e.asciidoc @@ -0,0 +1,23 @@ +[source, ruby] +---- +response = client.connector.update_scheduling( + connector_id: 'my-connector', + body: { + scheduling: { + access_control: { + enabled: true, + interval: '0 10 0 * * ?' + }, + full: { + enabled: true, + interval: '0 20 0 * * ?' + }, + incremental: { + enabled: false, + interval: '0 30 0 * * ?' + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/8f0c5c81cdb902c136db821947ee70a1.asciidoc b/docs/examples/guide/8f0c5c81cdb902c136db821947ee70a1.asciidoc index 9d8c1a9970..29f8328a5c 100644 --- a/docs/examples/guide/8f0c5c81cdb902c136db821947ee70a1.asciidoc +++ b/docs/examples/guide/8f0c5c81cdb902c136db821947ee70a1.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "price.adjusted": { + 'price.adjusted' => { type: 'double', script: "\n double price = doc['price'].value;\n if (doc['promoted'].value) {\n price *= 0.8;\n }\n emit(price);\n " } diff --git a/docs/examples/guide/8f7936f219500305e5b2518dbbf949ea.asciidoc b/docs/examples/guide/8f7936f219500305e5b2518dbbf949ea.asciidoc new file mode 100644 index 0000000000..8eb8cd85ab --- /dev/null +++ b/docs/examples/guide/8f7936f219500305e5b2518dbbf949ea.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.async_search.status( + id: 'FmpwbThueVB4UkRDeUxqb1l4akIza3cbWEJyeVBPQldTV3FGZGdIeUVabXBldzoyMDIw' +) +puts response +---- diff --git a/docs/examples/guide/8fec06a98d0151c1d717a01491d0b8f0.asciidoc b/docs/examples/guide/8fec06a98d0151c1d717a01491d0b8f0.asciidoc new file mode 100644 index 0000000000..6626475dae --- /dev/null +++ b/docs/examples/guide/8fec06a98d0151c1d717a01491d0b8f0.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.index( + index: 'dsl-data-stream', + body: { + "@timestamp": '2023-10-18T16:21:15.000Z', + message: '192.0.2.42 - - [06/May/2099:16:21:15 +0000] "GET /images/bg.jpg HTTP/1.0" 200 24736' + } +) +puts response +---- diff --git a/docs/examples/guide/90083d93e46fad2524755b8d4d1306fc.asciidoc b/docs/examples/guide/90083d93e46fad2524755b8d4d1306fc.asciidoc new file mode 100644 index 0000000000..06608f987c --- /dev/null +++ b/docs/examples/guide/90083d93e46fad2524755b8d4d1306fc.asciidoc @@ -0,0 +1,14 @@ +[source, ruby] +---- +response = client.connector.sync_job_update_stats( + connector_sync_job_id: 'my-connector-sync-job', + body: { + deleted_document_count: 10, + indexed_document_count: 20, + indexed_document_volume: 1000, + total_document_count: 2000, + last_seen: '2023-01-02T10:00:00Z' + } +) +puts response +---- diff --git a/docs/examples/guide/90112d594b934c0111b7303b9f91cb7f.asciidoc b/docs/examples/guide/90112d594b934c0111b7303b9f91cb7f.asciidoc deleted file mode 100644 index 22fea04517..0000000000 --- a/docs/examples/guide/90112d594b934c0111b7303b9f91cb7f.asciidoc +++ /dev/null @@ -1,12 +0,0 @@ -[source, ruby] ----- -response = client.index( - index: 'customer', - id: 1, - body: { - firstname: 'Jennifer', - lastname: 'Walters' - } -) -puts response ----- diff --git a/docs/examples/guide/902cfd5aeec2f65b3adf55f5e38b21f0.asciidoc b/docs/examples/guide/902cfd5aeec2f65b3adf55f5e38b21f0.asciidoc new file mode 100644 index 0000000000..31de8448f8 --- /dev/null +++ b/docs/examples/guide/902cfd5aeec2f65b3adf55f5e38b21f0.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'kibana_sample_data_ecommerce2', + body: { + user: 'kimchy' + } +) +puts response +---- diff --git a/docs/examples/guide/909a032a9c1f7095b798444705b09ad6.asciidoc b/docs/examples/guide/909a032a9c1f7095b798444705b09ad6.asciidoc new file mode 100644 index 0000000000..48852d5949 --- /dev/null +++ b/docs/examples/guide/909a032a9c1f7095b798444705b09ad6.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'GEOMETRYCOLLECTION (POINT (100.0 0.0), LINESTRING (101.0 0.0, 102.0 1.0))' + } +) +puts response +---- diff --git a/docs/examples/guide/92d343eb755971c44a939d0660bf5ac2.asciidoc b/docs/examples/guide/92d343eb755971c44a939d0660bf5ac2.asciidoc new file mode 100644 index 0000000000..2810b67022 --- /dev/null +++ b/docs/examples/guide/92d343eb755971c44a939d0660bf5ac2.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.index( + index: 'test', + id: 1, + refresh: true, + body: { + test: 'test' + } +) +puts response + +response = client.index( + index: 'test', + id: 2, + refresh: true, + body: { + test: 'test' + } +) +puts response +---- diff --git a/docs/examples/guide/2cafbc456bed3b7c8780e5557aab1d6b.asciidoc b/docs/examples/guide/93cca1eb4d9ee4c65ab259e18469d9d6.asciidoc similarity index 100% rename from docs/examples/guide/2cafbc456bed3b7c8780e5557aab1d6b.asciidoc rename to docs/examples/guide/93cca1eb4d9ee4c65ab259e18469d9d6.asciidoc diff --git a/docs/examples/guide/93cd0fdd5ca22838db06aa1cabdbe8bd.asciidoc b/docs/examples/guide/93cd0fdd5ca22838db06aa1cabdbe8bd.asciidoc new file mode 100644 index 0000000000..6c8e28514c --- /dev/null +++ b/docs/examples/guide/93cd0fdd5ca22838db06aa1cabdbe8bd.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.search( + index: 'hugging-face-embeddings', + body: { + knn: { + field: 'content_embedding', + query_vector_builder: { + text_embedding: { + model_id: 'hugging_face_embeddings', + model_text: "What's margin of error?" + } + }, + k: 10, + num_candidates: 100 + }, + _source: [ + 'id', + 'content' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/93d7ba4130722cae04f9690e52a8f54f.asciidoc b/docs/examples/guide/93d7ba4130722cae04f9690e52a8f54f.asciidoc new file mode 100644 index 0000000000..fc118e7869 --- /dev/null +++ b/docs/examples/guide/93d7ba4130722cae04f9690e52a8f54f.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'envelope', + coordinates: [ + [ + 100, + 1 + ], + [ + 101, + 0 + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/94cd66bf93f99881c1bda547283a0357.asciidoc b/docs/examples/guide/94cd66bf93f99881c1bda547283a0357.asciidoc new file mode 100644 index 0000000000..2373173148 --- /dev/null +++ b/docs/examples/guide/94cd66bf93f99881c1bda547283a0357.asciidoc @@ -0,0 +1,46 @@ +[source, ruby] +---- +response = client.bulk( + index: 'quantized-image-index', + refresh: true, + body: [ + { + index: { + _id: '1' + } + }, + { + "image-vector": [ + 0.1, + -2 + ], + title: 'moose family' + }, + { + index: { + _id: '2' + } + }, + { + "image-vector": [ + 0.75, + -1 + ], + title: 'alpine lake' + }, + { + index: { + _id: '3' + } + }, + { + "image-vector": [ + 1.2, + 0.1 + ], + title: 'full moon' + } + ] +) +puts response +---- diff --git a/docs/examples/guide/9501e6c8e95c21838653ea15b9b7ed5f.asciidoc b/docs/examples/guide/9501e6c8e95c21838653ea15b9b7ed5f.asciidoc index 24760e7df4..b8bf89c539 100644 --- a/docs/examples/guide/9501e6c8e95c21838653ea15b9b7ed5f.asciidoc +++ b/docs/examples/guide/9501e6c8e95c21838653ea15b9b7ed5f.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { term: { - "query.extraction_result": 'failed' + 'query.extraction_result' => 'failed' } } } diff --git a/docs/examples/guide/956cb470258024af964cd2dabbaf7c7c.asciidoc b/docs/examples/guide/956cb470258024af964cd2dabbaf7c7c.asciidoc index 81c880d75c..97b8b27b64 100644 --- a/docs/examples/guide/956cb470258024af964cd2dabbaf7c7c.asciidoc +++ b/docs/examples/guide/956cb470258024af964cd2dabbaf7c7c.asciidoc @@ -3,8 +3,8 @@ response = client.indices.put_settings( index: 'my-index', body: { - "index.routing.allocation.require.data": nil, - "index.routing.allocation.include._tier_preference": 'data_warm,data_hot' + 'index.routing.allocation.require.data' => nil, + 'index.routing.allocation.include._tier_preference' => 'data_warm,data_hot' } ) puts response diff --git a/docs/examples/guide/95c03bdef4faf6bef039c986f4cb3aba.asciidoc b/docs/examples/guide/95c03bdef4faf6bef039c986f4cb3aba.asciidoc index 907339e3e7..89264f02cf 100644 --- a/docs/examples/guide/95c03bdef4faf6bef039c986f4cb3aba.asciidoc +++ b/docs/examples/guide/95c03bdef4faf6bef039c986f4cb3aba.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { query: { match: { - "result.condition.met": true + 'result.condition.met' => true } } } diff --git a/docs/examples/guide/96b9289c3c4c6b135ab3386562c4ee8d.asciidoc b/docs/examples/guide/96b9289c3c4c6b135ab3386562c4ee8d.asciidoc index c22ee2bed1..7f7016e5c3 100644 --- a/docs/examples/guide/96b9289c3c4c6b135ab3386562c4ee8d.asciidoc +++ b/docs/examples/guide/96b9289c3c4c6b135ab3386562c4ee8d.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.max_shards_per_node": 1200 + 'cluster.max_shards_per_node' => 1200 } } ) diff --git a/docs/examples/guide/96ea0e80323d6d2d99964625c004a44d.asciidoc b/docs/examples/guide/96ea0e80323d6d2d99964625c004a44d.asciidoc new file mode 100644 index 0000000000..3d89ed2f22 --- /dev/null +++ b/docs/examples/guide/96ea0e80323d6d2d99964625c004a44d.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.indices.put_data_lifecycle( + name: 'dsl-data-stream', + body: { + data_retention: '7d', + enabled: false + } +) +puts response +---- diff --git a/docs/examples/guide/97f5df84efec655f479fad78bc392d4d.asciidoc b/docs/examples/guide/97f5df84efec655f479fad78bc392d4d.asciidoc index f3a35a8297..e8d52a980f 100644 --- a/docs/examples/guide/97f5df84efec655f479fad78bc392d4d.asciidoc +++ b/docs/examples/guide/97f5df84efec655f479fad78bc392d4d.asciidoc @@ -6,7 +6,7 @@ response = client.search( profile: true, query: { term: { - "user.id": { + 'user.id' => { value: 'elkbee' } } diff --git a/docs/examples/guide/983fbb78e57e8fe98db38cf2d217e943.asciidoc b/docs/examples/guide/983fbb78e57e8fe98db38cf2d217e943.asciidoc index 2cb4aca699..41a31c1d5d 100644 --- a/docs/examples/guide/983fbb78e57e8fe98db38cf2d217e943.asciidoc +++ b/docs/examples/guide/983fbb78e57e8fe98db38cf2d217e943.asciidoc @@ -42,7 +42,7 @@ response = client.search( path: 'comments', query: { match: { - "comments.text": 'words' + 'comments.text' => 'words' } }, inner_hits: { diff --git a/docs/examples/guide/98b403c356a9b14544e9b9f646845e9f.asciidoc b/docs/examples/guide/98b403c356a9b14544e9b9f646845e9f.asciidoc new file mode 100644 index 0000000000..a113257b59 --- /dev/null +++ b/docs/examples/guide/98b403c356a9b14544e9b9f646845e9f.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.put_script( + id: 'my-search-template', + body: { + script: { + lang: 'mustache', + source: { + query: { + multi_match: { + query: '{{query_string}}', + fields: '[{{#text_fields}}{{user_name}}{{^last}},{{/last}}{{/text_fields}}]' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/990c0d794ed6f05d1620b5d49f7aff6e.asciidoc b/docs/examples/guide/990c0d794ed6f05d1620b5d49f7aff6e.asciidoc new file mode 100644 index 0000000000..1a8323c1ee --- /dev/null +++ b/docs/examples/guide/990c0d794ed6f05d1620b5d49f7aff6e.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.indices.get_data_lifecycle( + name: 'my-data-stream' +) +puts response +---- diff --git a/docs/examples/guide/991b9ba53f0eccec8ec5a42f8d9b655c.asciidoc b/docs/examples/guide/991b9ba53f0eccec8ec5a42f8d9b655c.asciidoc index 12202c8fb0..90467c2fbc 100644 --- a/docs/examples/guide/991b9ba53f0eccec8ec5a42f8d9b655c.asciidoc +++ b/docs/examples/guide/991b9ba53f0eccec8ec5a42f8d9b655c.asciidoc @@ -4,13 +4,13 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { fields: { body: {}, - "blog.title": { + 'blog.title' => { number_of_fragments: 0 } } diff --git a/docs/examples/guide/998651b98e152add530084a631a4ab5a.asciidoc b/docs/examples/guide/998651b98e152add530084a631a4ab5a.asciidoc index f1a516a9e3..a388fcf38a 100644 --- a/docs/examples/guide/998651b98e152add530084a631a4ab5a.asciidoc +++ b/docs/examples/guide/998651b98e152add530084a631a4ab5a.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "indices.lifecycle.poll_interval": '1m' + 'indices.lifecycle.poll_interval' => '1m' } } ) diff --git a/docs/examples/guide/99b617a0a83fcfbe5755ccc724a4ce62.asciidoc b/docs/examples/guide/99b617a0a83fcfbe5755ccc724a4ce62.asciidoc new file mode 100644 index 0000000000..8970b060ad --- /dev/null +++ b/docs/examples/guide/99b617a0a83fcfbe5755ccc724a4ce62.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.index( + index: 'place_path_category', + id: 1, + body: { + suggest: [ + "timmy's", + 'starbucks', + 'dunkin donuts' + ], + cat: [ + 'cafe', + 'food' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/9a4d5e41c52c20635d1fd9c6e13f6c7a.asciidoc b/docs/examples/guide/9a4d5e41c52c20635d1fd9c6e13f6c7a.asciidoc index 73bd4a608f..70760c333e 100644 --- a/docs/examples/guide/9a4d5e41c52c20635d1fd9c6e13f6c7a.asciidoc +++ b/docs/examples/guide/9a4d5e41c52c20635d1fd9c6e13f6c7a.asciidoc @@ -5,7 +5,7 @@ response = client.index( id: 1, refresh: true, body: { - "system.cpu.idle.pct": 0.908 + 'system.cpu.idle.pct' => 0.908 } ) puts response @@ -15,7 +15,7 @@ response = client.index( id: 1, refresh: true, body: { - "system.cpu.idle.pct": 0.105 + 'system.cpu.idle.pct' => 0.105 } ) puts response diff --git a/docs/examples/guide/9aa2327ae315c39f2bce2bd22e0deb1b.asciidoc b/docs/examples/guide/9aa2327ae315c39f2bce2bd22e0deb1b.asciidoc index 8d62dee41a..f0162ba4a2 100644 --- a/docs/examples/guide/9aa2327ae315c39f2bce2bd22e0deb1b.asciidoc +++ b/docs/examples/guide/9aa2327ae315c39f2bce2bd22e0deb1b.asciidoc @@ -9,12 +9,12 @@ response = client.search( must: [ { match: { - "result.condition.met": true + 'result.condition.met' => true } }, { range: { - "result.execution_time": { + 'result.execution_time' => { from: 'now-10s' } } diff --git a/docs/examples/guide/9b0f34d122a4b348dc86df7410d6ebb6.asciidoc b/docs/examples/guide/9b0f34d122a4b348dc86df7410d6ebb6.asciidoc new file mode 100644 index 0000000000..bb0b6a0db3 --- /dev/null +++ b/docs/examples/guide/9b0f34d122a4b348dc86df7410d6ebb6.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.sync_job_cancel( + connector_sync_job_id: 'my-connector-sync-job-id' +) +puts response +---- diff --git a/docs/examples/guide/9beb260834f8cfb240f6308950dbb9c2.asciidoc b/docs/examples/guide/9beb260834f8cfb240f6308950dbb9c2.asciidoc index 94679c0064..0bc4d3a406 100644 --- a/docs/examples/guide/9beb260834f8cfb240f6308950dbb9c2.asciidoc +++ b/docs/examples/guide/9beb260834f8cfb240f6308950dbb9c2.asciidoc @@ -5,7 +5,7 @@ response = client.search( sort: [ { _geo_distance: { - "pin.location": 'drm3btev3e86', + 'pin.location' => 'drm3btev3e86', order: 'asc', unit: 'km' } diff --git a/docs/examples/guide/9cfbc41bb7b6fbdb26550dd2789c274e.asciidoc b/docs/examples/guide/9cfbc41bb7b6fbdb26550dd2789c274e.asciidoc index 5b60e24e06..cce1d3cf75 100644 --- a/docs/examples/guide/9cfbc41bb7b6fbdb26550dd2789c274e.asciidoc +++ b/docs/examples/guide/9cfbc41bb7b6fbdb26550dd2789c274e.asciidoc @@ -7,7 +7,7 @@ response = client.delete_by_query( body: { query: { range: { - "http.response.bytes": { + 'http.response.bytes' => { lt: 2_000_000 } } diff --git a/docs/examples/guide/9e563b8d5a7845f644db8d5bbf453eb6.asciidoc b/docs/examples/guide/9e563b8d5a7845f644db8d5bbf453eb6.asciidoc new file mode 100644 index 0000000000..232e0d5c9d --- /dev/null +++ b/docs/examples/guide/9e563b8d5a7845f644db8d5bbf453eb6.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.synonyms.put_synonym( + id: 'my-synonyms-set', + body: { + synonyms_set: [ + { + id: 'test-1', + synonyms: 'hello, hi' + }, + { + synonyms: 'bye, goodbye' + }, + { + id: 'test-2', + synonyms: 'test => check' + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/9f214a468014a83809935e7b808afc53.asciidoc b/docs/examples/guide/9f214a468014a83809935e7b808afc53.asciidoc deleted file mode 100644 index ace423fa44..0000000000 --- a/docs/examples/guide/9f214a468014a83809935e7b808afc53.asciidoc +++ /dev/null @@ -1,31 +0,0 @@ -[source, ruby] ----- -response = client.search( - body: { - query: { - pinned: { - docs: [ - { - _index: 'my-index-000001', - _id: '1' - }, - { - _index: 'my-index-000001', - _id: '4' - }, - { - _index: 'my-index-000002', - _id: '100' - } - ], - organic: { - match: { - description: 'iphone' - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/9f22a0920cc763eefa233ced963d9624.asciidoc b/docs/examples/guide/9f22a0920cc763eefa233ced963d9624.asciidoc index a3af576f72..fe31c4fb37 100644 --- a/docs/examples/guide/9f22a0920cc763eefa233ced963d9624.asciidoc +++ b/docs/examples/guide/9f22a0920cc763eefa233ced963d9624.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { span_term: { - "user.id": { + 'user.id' => { term: 'kimchy', boost: 2 } diff --git a/docs/examples/guide/9feff356f302ea4915347ab71cc4887a.asciidoc b/docs/examples/guide/9feff356f302ea4915347ab71cc4887a.asciidoc index b48d9b2e4e..b8df274c04 100644 --- a/docs/examples/guide/9feff356f302ea4915347ab71cc4887a.asciidoc +++ b/docs/examples/guide/9feff356f302ea4915347ab71cc4887a.asciidoc @@ -11,7 +11,7 @@ response = client.indices.simulate_template( priority: 10, template: { settings: { - "index.number_of_replicas": 1 + 'index.number_of_replicas' => 1 } } } diff --git a/docs/examples/guide/a0497157fdefecd04e597edb800a1a95.asciidoc b/docs/examples/guide/a0497157fdefecd04e597edb800a1a95.asciidoc index 408abd5f8c..35c9f3782d 100644 --- a/docs/examples/guide/a0497157fdefecd04e597edb800a1a95.asciidoc +++ b/docs/examples/guide/a0497157fdefecd04e597edb800a1a95.asciidoc @@ -5,7 +5,7 @@ response = client.search( _source: 'obj.*', query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/a0c64894f14d28b7e0c902add71d2e9a.asciidoc b/docs/examples/guide/a0c64894f14d28b7e0c902add71d2e9a.asciidoc new file mode 100644 index 0000000000..9af8726e17 --- /dev/null +++ b/docs/examples/guide/a0c64894f14d28b7e0c902add71d2e9a.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.cluster.put_settings( + body: { + persistent: { + 'xpack.profiling.templates.enabled' => true + } + } +) +puts response +---- diff --git a/docs/examples/guide/a0d53dcb3df938fc0a01d248571a41e4.asciidoc b/docs/examples/guide/a0d53dcb3df938fc0a01d248571a41e4.asciidoc index a881ef5a09..a01190e805 100644 --- a/docs/examples/guide/a0d53dcb3df938fc0a01d248571a41e4.asciidoc +++ b/docs/examples/guide/a0d53dcb3df938fc0a01d248571a41e4.asciidoc @@ -3,7 +3,7 @@ response = client.search( body: { runtime_mappings: { - "price.discounted": { + 'price.discounted' => { type: 'double', script: "\n double price = doc['price'].value;\n if (doc['product'].value == 'mad max') {\n price *= 0.8;\n }\n emit(price);\n " } diff --git a/docs/examples/guide/a1f6383373084d874d3365eef2c0e96e.asciidoc b/docs/examples/guide/a1f6383373084d874d3365eef2c0e96e.asciidoc deleted file mode 100644 index 469fc34234..0000000000 --- a/docs/examples/guide/a1f6383373084d874d3365eef2c0e96e.asciidoc +++ /dev/null @@ -1,7 +0,0 @@ -[source, ruby] ----- -response = client.indices.delete( - index: 'sample-01' -) -puts response ----- diff --git a/docs/examples/guide/a1f70bc71b763b58206814c40a7440e7.asciidoc b/docs/examples/guide/a1f70bc71b763b58206814c40a7440e7.asciidoc index e6c9b5e937..273dbddda4 100644 --- a/docs/examples/guide/a1f70bc71b763b58206814c40a7440e7.asciidoc +++ b/docs/examples/guide/a1f70bc71b763b58206814c40a7440e7.asciidoc @@ -2,7 +2,7 @@ ---- response = client.watcher.update_settings( body: { - "index.auto_expand_replicas": '0-4' + 'index.auto_expand_replicas' => '0-4' } ) puts response diff --git a/docs/examples/guide/a2bd0782aadfd0a902d7f590ee7f49fe.asciidoc b/docs/examples/guide/a2bd0782aadfd0a902d7f590ee7f49fe.asciidoc new file mode 100644 index 0000000000..d285e699fc --- /dev/null +++ b/docs/examples/guide/a2bd0782aadfd0a902d7f590ee7f49fe.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index', + body: { + mappings: { + properties: { + content_embedding: { + type: 'sparse_vector' + }, + content: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/a425fcab60f603504becee7d001f0a4b.asciidoc b/docs/examples/guide/a425fcab60f603504becee7d001f0a4b.asciidoc index ee51e07015..c2fe7ecb23 100644 --- a/docs/examples/guide/a425fcab60f603504becee7d001f0a4b.asciidoc +++ b/docs/examples/guide/a425fcab60f603504becee7d001f0a4b.asciidoc @@ -3,7 +3,7 @@ response = client.indices.put_settings( index: 'index_4', body: { - "index.priority": 1 + 'index.priority' => 1 } ) puts response diff --git a/docs/examples/guide/a45d80a3fdba70c1b1ba493e51652c8a.asciidoc b/docs/examples/guide/a45d80a3fdba70c1b1ba493e51652c8a.asciidoc new file mode 100644 index 0000000000..823884c927 --- /dev/null +++ b/docs/examples/guide/a45d80a3fdba70c1b1ba493e51652c8a.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'multipoint', + coordinates: [ + [ + 1002, + 1002 + ], + [ + 1003, + 2000 + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/a4a3c3cd09efa75168dab90105afb2e9.asciidoc b/docs/examples/guide/a4a3c3cd09efa75168dab90105afb2e9.asciidoc new file mode 100644 index 0000000000..e6a4f843ab --- /dev/null +++ b/docs/examples/guide/a4a3c3cd09efa75168dab90105afb2e9.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.inference.get_model( + task_type: 'sparse_embedding', + inference_id: 'my-elser-model' +) +puts response +---- diff --git a/docs/examples/guide/a4f259522b4dc10a0323aff58236c2c2.asciidoc b/docs/examples/guide/a4f259522b4dc10a0323aff58236c2c2.asciidoc new file mode 100644 index 0000000000..f72d60cf07 --- /dev/null +++ b/docs/examples/guide/a4f259522b4dc10a0323aff58236c2c2.asciidoc @@ -0,0 +1,18 @@ +[source, ruby] +---- +response = client.index( + index: 'music', + id: 1, + refresh: true, + body: { + suggest: { + input: [ + 'Nevermind', + 'Nirvana' + ], + weight: 34 + } + } +) +puts response +---- diff --git a/docs/examples/guide/a53ff77d83222c0e76453e630d64787e.asciidoc b/docs/examples/guide/a53ff77d83222c0e76453e630d64787e.asciidoc new file mode 100644 index 0000000000..446177b2b5 --- /dev/null +++ b/docs/examples/guide/a53ff77d83222c0e76453e630d64787e.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.ingest.put_pipeline( + id: 'openai_embeddings', + body: { + processors: [ + { + inference: { + model_id: 'openai_embeddings', + input_output: { + input_field: 'content', + output_field: 'content_embedding' + } + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/a547bb926c25f670078b98fbe67de3cc.asciidoc b/docs/examples/guide/a547bb926c25f670078b98fbe67de3cc.asciidoc new file mode 100644 index 0000000000..d7ebbe1cb7 --- /dev/null +++ b/docs/examples/guide/a547bb926c25f670078b98fbe67de3cc.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.synonyms.delete_synonym_rule( + set_id: 'my-synonyms-set', + rule_id: 'test-1' +) +puts response +---- diff --git a/docs/examples/guide/a5e6ccfb6019238e6db602373b9af147.asciidoc b/docs/examples/guide/a5e6ccfb6019238e6db602373b9af147.asciidoc new file mode 100644 index 0000000000..ea47306dc2 --- /dev/null +++ b/docs/examples/guide/a5e6ccfb6019238e6db602373b9af147.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.indices.put_data_lifecycle( + name: 'my-data-stream', + body: {} +) +puts response +---- diff --git a/docs/examples/guide/a62833baf15f2c9ac094a9289e56a012.asciidoc b/docs/examples/guide/a62833baf15f2c9ac094a9289e56a012.asciidoc new file mode 100644 index 0000000000..721e75a76e --- /dev/null +++ b/docs/examples/guide/a62833baf15f2c9ac094a9289e56a012.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.index( + index: 'timeseries', + body: { + message: 'logged the request', + "@timestamp": '1591890611' + } +) +puts response +---- diff --git a/docs/examples/guide/a62fda257bdc3ffdd98f39cd38d112f1.asciidoc b/docs/examples/guide/a62fda257bdc3ffdd98f39cd38d112f1.asciidoc deleted file mode 100644 index bf1d52a596..0000000000 --- a/docs/examples/guide/a62fda257bdc3ffdd98f39cd38d112f1.asciidoc +++ /dev/null @@ -1,29 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'test_index', - body: { - settings: { - index: { - analysis: { - analyzer: { - synonym: { - tokenizer: 'whitespace', - filter: [ - 'synonym' - ] - } - }, - filter: { - synonym: { - type: 'synonym', - synonyms_path: 'analysis/synonym.txt' - } - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/a63e0d0504e0c9313814b7f4e2641353.asciidoc b/docs/examples/guide/a63e0d0504e0c9313814b7f4e2641353.asciidoc new file mode 100644 index 0000000000..4c99bb36fe --- /dev/null +++ b/docs/examples/guide/a63e0d0504e0c9313814b7f4e2641353.asciidoc @@ -0,0 +1,107 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'metrics_index', + body: { + mappings: { + properties: { + network: { + properties: { + name: { + type: 'keyword' + } + } + }, + latency_histo: { + type: 'histogram' + } + } + } + } +) +puts response + +response = client.index( + index: 'metrics_index', + id: 1, + refresh: true, + body: { + 'network.name' => 'net-1', + latency_histo: { + values: [ + 1, + 3, + 8, + 12, + 15 + ], + counts: [ + 3, + 7, + 23, + 12, + 6 + ] + } + } +) +puts response + +response = client.index( + index: 'metrics_index', + id: 2, + refresh: true, + body: { + 'network.name' => 'net-2', + latency_histo: { + values: [ + 1, + 6, + 8, + 12, + 14 + ], + counts: [ + 8, + 17, + 8, + 7, + 6 + ] + } + } +) +puts response + +response = client.search( + index: 'metrics_index', + size: 0, + filter_path: 'aggregations', + body: { + aggregations: { + latency_ranges: { + range: { + field: 'latency_histo', + ranges: [ + { + to: 2 + }, + { + from: 2, + to: 3 + }, + { + from: 3, + to: 10 + }, + { + from: 10 + } + ] + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/a6b2815d54df34b6b8d00226e9a1af0c.asciidoc b/docs/examples/guide/a6b2815d54df34b6b8d00226e9a1af0c.asciidoc new file mode 100644 index 0000000000..d57dc991c2 --- /dev/null +++ b/docs/examples/guide/a6b2815d54df34b6b8d00226e9a1af0c.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index', + body: { + mappings: { + properties: { + 'my_embeddings.predicted_value' => { + type: 'dense_vector', + dims: 384 + }, + my_text_field: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/a6ccac9f80c5e5efdaab992f3a32d919.asciidoc b/docs/examples/guide/a6ccac9f80c5e5efdaab992f3a32d919.asciidoc new file mode 100644 index 0000000000..657939dede --- /dev/null +++ b/docs/examples/guide/a6ccac9f80c5e5efdaab992f3a32d919.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.indices.get_data_stream( + name: 'dsl-data-stream' +) +puts response +---- diff --git a/docs/examples/guide/a735081e715d385b4d471eea0f2b57da.asciidoc b/docs/examples/guide/a735081e715d385b4d471eea0f2b57da.asciidoc index eab23a6161..a53ca0b4b8 100644 --- a/docs/examples/guide/a735081e715d385b4d471eea0f2b57da.asciidoc +++ b/docs/examples/guide/a735081e715d385b4d471eea0f2b57da.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "slm.retention_schedule": '0 30 1 * * ?' + 'slm.retention_schedule' => '0 30 1 * * ?' } } ) diff --git a/docs/examples/guide/a73a9a6f19516b8ead63182a9ae5b540.asciidoc b/docs/examples/guide/a73a9a6f19516b8ead63182a9ae5b540.asciidoc new file mode 100644 index 0000000000..4572bd40b9 --- /dev/null +++ b/docs/examples/guide/a73a9a6f19516b8ead63182a9ae5b540.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'MULTILINESTRING ((1002.0 200.0, 1003.0 200.0, 1003.0 300.0, 1002.0 300.0), (1000.0 100.0, 1001.0 100.0, 1001.0 100.0, 1000.0 100.0), (1000.2 0.2, 1000.8 100.2, 1000.8 100.8, 1000.2 100.8))' + } +) +puts response +---- diff --git a/docs/examples/guide/a810da963d3b28d79dcd17be829bb271.asciidoc b/docs/examples/guide/a810da963d3b28d79dcd17be829bb271.asciidoc index 54a70e04c0..41aab2f2eb 100644 --- a/docs/examples/guide/a810da963d3b28d79dcd17be829bb271.asciidoc +++ b/docs/examples/guide/a810da963d3b28d79dcd17be829bb271.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, docvalue_fields: [ diff --git a/docs/examples/guide/a89052bcdfe40e604a98d12be6ae59d2.asciidoc b/docs/examples/guide/a89052bcdfe40e604a98d12be6ae59d2.asciidoc new file mode 100644 index 0000000000..8e362dc364 --- /dev/null +++ b/docs/examples/guide/a89052bcdfe40e604a98d12be6ae59d2.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'BBOX (100.0, 102.0, 2.0, 0.0)' + } +) +puts response +---- diff --git a/docs/examples/guide/a8add749c3f41ad1308a45308df14103.asciidoc b/docs/examples/guide/a8add749c3f41ad1308a45308df14103.asciidoc new file mode 100644 index 0000000000..fc67c30409 --- /dev/null +++ b/docs/examples/guide/a8add749c3f41ad1308a45308df14103.asciidoc @@ -0,0 +1,29 @@ +[source, ruby] +---- +response = client.index( + index: 'sales', + id: 1, + refresh: true, + body: { + tags: [ + 'car', + 'auto' + ], + comments: [ + { + username: 'baddriver007', + comment: 'This car could have better brakes' + }, + { + username: 'dr_who', + comment: "Where's the autopilot? Can't find it" + }, + { + username: 'ilovemotorbikes', + comment: 'This car has two extra wheels' + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/a941fd568f2e20e13df909ab24506073.asciidoc b/docs/examples/guide/a941fd568f2e20e13df909ab24506073.asciidoc index cbbb572709..f8027fdd08 100644 --- a/docs/examples/guide/a941fd568f2e20e13df909ab24506073.asciidoc +++ b/docs/examples/guide/a941fd568f2e20e13df909ab24506073.asciidoc @@ -6,7 +6,7 @@ puts response response = client.cluster.put_settings( body: { persistent: { - "xpack.monitoring.collection.enabled": false + 'xpack.monitoring.collection.enabled' => false } } ) diff --git a/docs/examples/guide/a9554396506888e392a1aee0ca28e6fc.asciidoc b/docs/examples/guide/a9554396506888e392a1aee0ca28e6fc.asciidoc index 195cfb4f69..9c77b62780 100644 --- a/docs/examples/guide/a9554396506888e392a1aee0ca28e6fc.asciidoc +++ b/docs/examples/guide/a9554396506888e392a1aee0ca28e6fc.asciidoc @@ -20,7 +20,7 @@ response = client.indices.update_aliases( }, { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } ] diff --git a/docs/examples/guide/a960b43e720b4934edb74ab4b085ca77.asciidoc b/docs/examples/guide/a960b43e720b4934edb74ab4b085ca77.asciidoc new file mode 100644 index 0000000000..124637796e --- /dev/null +++ b/docs/examples/guide/a960b43e720b4934edb74ab4b085ca77.asciidoc @@ -0,0 +1,5 @@ +[source, ruby] +---- +response = client.connector.list +puts response +---- diff --git a/docs/examples/guide/a99bf70ae38bdf1c6f350140b25e0422.asciidoc b/docs/examples/guide/a99bf70ae38bdf1c6f350140b25e0422.asciidoc index 6f09d3d3bc..270145cd97 100644 --- a/docs/examples/guide/a99bf70ae38bdf1c6f350140b25e0422.asciidoc +++ b/docs/examples/guide/a99bf70ae38bdf1c6f350140b25e0422.asciidoc @@ -6,7 +6,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/aaba346e0becdf12db13658296e0b8a1.asciidoc b/docs/examples/guide/aaba346e0becdf12db13658296e0b8a1.asciidoc index ae00732886..d085b8a838 100644 --- a/docs/examples/guide/aaba346e0becdf12db13658296e0b8a1.asciidoc +++ b/docs/examples/guide/aaba346e0becdf12db13658296e0b8a1.asciidoc @@ -4,8 +4,8 @@ response = client.indices.create( index: 'my-index-000001', body: { settings: { - "index.number_of_shards": 2, - "index.lifecycle.name": 'shrink-index' + 'index.number_of_shards' => 2, + 'index.lifecycle.name' => 'shrink-index' } } ) diff --git a/docs/examples/guide/ab1372270c11bcd6f36d1a13e6c69276.asciidoc b/docs/examples/guide/ab1372270c11bcd6f36d1a13e6c69276.asciidoc new file mode 100644 index 0000000000..e3b2dbd0df --- /dev/null +++ b/docs/examples/guide/ab1372270c11bcd6f36d1a13e6c69276.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.async_search.submit( + index: 'my-index-000001,cluster_one:my-index-000001,cluster_two:my-index-000001', + ccs_minimize_roundtrips: true, + body: { + query: { + match: { + 'user.id' => 'kimchy' + } + }, + _source: [ + 'user.id', + 'message', + 'http.response.status_code' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/ab1a989958c1d345a9dc3dd36ad90c27.asciidoc b/docs/examples/guide/ab1a989958c1d345a9dc3dd36ad90c27.asciidoc new file mode 100644 index 0000000000..8a9983834c --- /dev/null +++ b/docs/examples/guide/ab1a989958c1d345a9dc3dd36ad90c27.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'POLYGON ((1000.0 1000.0, 1001.0 1000.0, 1001.0 1001.0, 1000.0 1001.0, 1000.0 1000.0), (1000.2 1000.2, 1000.8 1000.2, 1000.8 1000.8, 1000.2 1000.8, 1000.2 1000.2))' + } +) +puts response +---- diff --git a/docs/examples/guide/ac73895ca1882cd1ac65b1facfbb5c63.asciidoc b/docs/examples/guide/ac73895ca1882cd1ac65b1facfbb5c63.asciidoc index e2a8588ade..33b2a00167 100644 --- a/docs/examples/guide/ac73895ca1882cd1ac65b1facfbb5c63.asciidoc +++ b/docs/examples/guide/ac73895ca1882cd1ac65b1facfbb5c63.asciidoc @@ -5,7 +5,7 @@ response = client.delete_by_query( body: { query: { match: { - "user.id": 'elkbee' + 'user.id' => 'elkbee' } } } diff --git a/docs/examples/guide/ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc b/docs/examples/guide/ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc index f3f73f378f..7b7834d1f7 100644 --- a/docs/examples/guide/ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc +++ b/docs/examples/guide/ac85e05c0bf2fd5099fbcb9c492f447e.asciidoc @@ -4,7 +4,7 @@ response = client.cluster.put_settings( flat_settings: true, body: { transient: { - "indices.recovery.max_bytes_per_sec": '20mb' + 'indices.recovery.max_bytes_per_sec' => '20mb' } } ) diff --git a/docs/examples/guide/ad2b8aed84c67cdc295917b47a12d3dc.asciidoc b/docs/examples/guide/ad2b8aed84c67cdc295917b47a12d3dc.asciidoc new file mode 100644 index 0000000000..1e3b94b96d --- /dev/null +++ b/docs/examples/guide/ad2b8aed84c67cdc295917b47a12d3dc.asciidoc @@ -0,0 +1,52 @@ +[source, ruby] +---- +response = client.bulk( + index: 'my-image-index', + refresh: true, + body: [ + { + index: { + _id: '1' + } + }, + { + "image-vector": [ + 1, + 5, + -20 + ], + "file-type": 'jpg', + title: 'mountain lake' + }, + { + index: { + _id: '2' + } + }, + { + "image-vector": [ + 42, + 8, + -15 + ], + "file-type": 'png', + title: 'frozen lake' + }, + { + index: { + _id: '3' + } + }, + { + "image-vector": [ + 15, + 11, + 23 + ], + "file-type": 'jpg', + title: 'mountain lake lodge' + } + ] +) +puts response +---- diff --git a/docs/examples/guide/aee4734ee63dbbbd12a21ee886f7a829.asciidoc b/docs/examples/guide/aee4734ee63dbbbd12a21ee886f7a829.asciidoc index add8e9257a..ea7e8a865b 100644 --- a/docs/examples/guide/aee4734ee63dbbbd12a21ee886f7a829.asciidoc +++ b/docs/examples/guide/aee4734ee63dbbbd12a21ee886f7a829.asciidoc @@ -5,7 +5,7 @@ response = client.search( sort: [ { _geo_distance: { - "pin.location": [ + 'pin.location' => [ -70, 40 ], diff --git a/docs/examples/guide/afa11ebb493ebbfd77acbbe50d2ce6db.asciidoc b/docs/examples/guide/afa11ebb493ebbfd77acbbe50d2ce6db.asciidoc new file mode 100644 index 0000000000..e90ad10592 --- /dev/null +++ b/docs/examples/guide/afa11ebb493ebbfd77acbbe50d2ce6db.asciidoc @@ -0,0 +1,42 @@ +[source, ruby] +---- +response = client.search( + index: 'my-data-stream', + body: { + size: 0, + aggregations: { + tsid: { + terms: { + field: '_tsid' + }, + aggregations: { + over_time: { + date_histogram: { + field: '@timestamp', + fixed_interval: '1d' + }, + aggregations: { + min: { + min: { + field: 'kubernetes.container.memory.usage.bytes' + } + }, + max: { + max: { + field: 'kubernetes.container.memory.usage.bytes' + } + }, + avg: { + avg: { + field: 'kubernetes.container.memory.usage.bytes' + } + } + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/afe30f159937b38d74c869570cfcd369.asciidoc b/docs/examples/guide/afe30f159937b38d74c869570cfcd369.asciidoc new file mode 100644 index 0000000000..69b89face8 --- /dev/null +++ b/docs/examples/guide/afe30f159937b38d74c869570cfcd369.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.indices.close( + index: 'index_1' +) +puts response + +response = client.snapshot.restore( + repository: 'my_repository', + snapshot: 'snapshot_2', + wait_for_completion: true, + body: { + indices: 'index_1' + } +) +puts response +---- diff --git a/docs/examples/guide/b0d3f839237fabf8cdc2221734c668ad.asciidoc b/docs/examples/guide/b0d3f839237fabf8cdc2221734c668ad.asciidoc new file mode 100644 index 0000000000..cea45cab9b --- /dev/null +++ b/docs/examples/guide/b0d3f839237fabf8cdc2221734c668ad.asciidoc @@ -0,0 +1,47 @@ +[source, ruby] +---- +response = client.index( + index: 'items', + id: 1, + refresh: true, + body: { + name: 'chocolate', + production_date: '2018-02-01', + location: [ + -71.34, + 41.12 + ] + } +) +puts response + +response = client.index( + index: 'items', + id: 2, + refresh: true, + body: { + name: 'chocolate', + production_date: '2018-01-01', + location: [ + -71.3, + 41.15 + ] + } +) +puts response + +response = client.index( + index: 'items', + id: 3, + refresh: true, + body: { + name: 'chocolate', + production_date: '2017-12-01', + location: [ + -71.3, + 41.12 + ] + } +) +puts response +---- diff --git a/docs/examples/guide/b10668cc742e666fe0eb6a53fd38a93e.asciidoc b/docs/examples/guide/b10668cc742e666fe0eb6a53fd38a93e.asciidoc deleted file mode 100644 index 092bfb4a27..0000000000 --- a/docs/examples/guide/b10668cc742e666fe0eb6a53fd38a93e.asciidoc +++ /dev/null @@ -1,17 +0,0 @@ -[source, ruby] ----- -response = client.search( - body: { - query: { - wildcard: { - "user.id": { - value: 'ki*y', - boost: 1, - rewrite: 'constant_score' - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/b195068563b1dc0f721f5f8c8d172312.asciidoc b/docs/examples/guide/b195068563b1dc0f721f5f8c8d172312.asciidoc new file mode 100644 index 0000000000..70bfebbe9c --- /dev/null +++ b/docs/examples/guide/b195068563b1dc0f721f5f8c8d172312.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'MULTIPOINT (1002.0 2000.0, 1003.0 2000.0)' + } +) +puts response +---- diff --git a/docs/examples/guide/b1f7cb4157b13368373383abd7d2b8cb.asciidoc b/docs/examples/guide/b1f7cb4157b13368373383abd7d2b8cb.asciidoc index 1b11ed339e..43a4205f66 100644 --- a/docs/examples/guide/b1f7cb4157b13368373383abd7d2b8cb.asciidoc +++ b/docs/examples/guide/b1f7cb4157b13368373383abd7d2b8cb.asciidoc @@ -6,11 +6,11 @@ response = client.cluster.put_settings( cluster: { remote: { cluster_two: { - "transport.compress": false + 'transport.compress' => false }, cluster_three: { - "transport.compress": true, - "transport.ping_schedule": '60s' + 'transport.compress' => true, + 'transport.ping_schedule' => '60s' } } } diff --git a/docs/examples/guide/b2652b1763a5fd31e95c983869b433bd.asciidoc b/docs/examples/guide/b2652b1763a5fd31e95c983869b433bd.asciidoc index fb327d8967..884fb4084f 100644 --- a/docs/examples/guide/b2652b1763a5fd31e95c983869b433bd.asciidoc +++ b/docs/examples/guide/b2652b1763a5fd31e95c983869b433bd.asciidoc @@ -4,7 +4,7 @@ response = client.index( index: 'metrics_index', id: 1, body: { - "network.name": 'net-1', + 'network.name' => 'net-1', latency_histo: { values: [ 0.1, @@ -29,7 +29,7 @@ response = client.index( index: 'metrics_index', id: 2, body: { - "network.name": 'net-2', + 'network.name' => 'net-2', latency_histo: { values: [ 0.1, diff --git a/docs/examples/guide/b2e4f3257c0e0aa3311f7270034bbc42.asciidoc b/docs/examples/guide/b2e4f3257c0e0aa3311f7270034bbc42.asciidoc index 18e11dd68a..f933bdc4b6 100644 --- a/docs/examples/guide/b2e4f3257c0e0aa3311f7270034bbc42.asciidoc +++ b/docs/examples/guide/b2e4f3257c0e0aa3311f7270034bbc42.asciidoc @@ -3,8 +3,8 @@ response = client.indices.put_settings( index: 'my-index', body: { - "index.routing.allocation.require.data": nil, - "index.routing.allocation.include._tier_preference": 'data_hot' + 'index.routing.allocation.require.data' => nil, + 'index.routing.allocation.include._tier_preference' => 'data_hot' } ) puts response diff --git a/docs/examples/guide/b3fffd96fdb118cd059b5f1d67d928de.asciidoc b/docs/examples/guide/b3fffd96fdb118cd059b5f1d67d928de.asciidoc new file mode 100644 index 0000000000..047e9266da --- /dev/null +++ b/docs/examples/guide/b3fffd96fdb118cd059b5f1d67d928de.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'MultiPoint', + coordinates: [ + [ + 102, + 2 + ], + [ + 103, + 2 + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/b45a8c6fc746e9c90fd181e69a605fad.asciidoc b/docs/examples/guide/b45a8c6fc746e9c90fd181e69a605fad.asciidoc new file mode 100644 index 0000000000..404b498679 --- /dev/null +++ b/docs/examples/guide/b45a8c6fc746e9c90fd181e69a605fad.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.inference.inference( + task_type: 'completion', + inference_id: 'openai_chat_completions', + body: { + input: 'What is Elastic?' + } +) +puts response +---- diff --git a/docs/examples/guide/b468d0124dc485385a34504d5b7af82a.asciidoc b/docs/examples/guide/b468d0124dc485385a34504d5b7af82a.asciidoc new file mode 100644 index 0000000000..ba765740ff --- /dev/null +++ b/docs/examples/guide/b468d0124dc485385a34504d5b7af82a.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.reindex( + wait_for_completion: false, + body: { + source: { + index: 'test-data', + size: 50 + }, + dest: { + index: 'hugging-face-embeddings', + pipeline: 'hugging_face_embeddings' + } + } +) +puts response +---- diff --git a/docs/examples/guide/b4693f2aa9fa65db04ab2499355c54fc.asciidoc b/docs/examples/guide/b4693f2aa9fa65db04ab2499355c54fc.asciidoc new file mode 100644 index 0000000000..0b81c86c08 --- /dev/null +++ b/docs/examples/guide/b4693f2aa9fa65db04ab2499355c54fc.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.search( + index: 'cohere-embeddings', + body: { + knn: { + field: 'content_embedding', + query_vector_builder: { + text_embedding: { + model_id: 'cohere_embeddings', + model_text: 'Muscles in human body' + } + }, + k: 10, + num_candidates: 100 + }, + _source: [ + 'id', + 'content' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/b4d1fc887e40885cdf6ac2d01487cb76.asciidoc b/docs/examples/guide/b4d1fc887e40885cdf6ac2d01487cb76.asciidoc index d707ea61c8..dcf7020036 100644 --- a/docs/examples/guide/b4d1fc887e40885cdf6ac2d01487cb76.asciidoc +++ b/docs/examples/guide/b4d1fc887e40885cdf6ac2d01487cb76.asciidoc @@ -6,7 +6,7 @@ response = client.search( span_multi: { match: { prefix: { - "user.id": { + 'user.id' => { value: 'ki', boost: 1.08 } diff --git a/docs/examples/guide/b504119238b44cddd3b5944da20a498d.asciidoc b/docs/examples/guide/b504119238b44cddd3b5944da20a498d.asciidoc new file mode 100644 index 0000000000..f85e58adbc --- /dev/null +++ b/docs/examples/guide/b504119238b44cddd3b5944da20a498d.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'POLYGON ((1000.0 -1001.0, 1001.0 -1001.0, 1001.0 -1000.0, 1000.0 -1000.0, 1000.0 -1001.0))' + } +) +puts response +---- diff --git a/docs/examples/guide/b52951b78cd5fb2f9353d1c7e6d37070.asciidoc b/docs/examples/guide/b52951b78cd5fb2f9353d1c7e6d37070.asciidoc new file mode 100644 index 0000000000..2261272f20 --- /dev/null +++ b/docs/examples/guide/b52951b78cd5fb2f9353d1c7e6d37070.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.search( + body: { + query: { + wildcard: { + 'user.id' => { + value: 'ki*y', + boost: 1, + rewrite: 'constant_score_blended' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/b557f114e21dbc6f531d4e7621a08e8f.asciidoc b/docs/examples/guide/b557f114e21dbc6f531d4e7621a08e8f.asciidoc index cfea3caa37..39e3185163 100644 --- a/docs/examples/guide/b557f114e21dbc6f531d4e7621a08e8f.asciidoc +++ b/docs/examples/guide/b557f114e21dbc6f531d4e7621a08e8f.asciidoc @@ -44,7 +44,7 @@ response = client.search( body: { query: { match: { - "meta.other.foo": 'one' + 'meta.other.foo' => 'one' } } } diff --git a/docs/examples/guide/b583bf8d3a2f49d633aa2cfed5606418.asciidoc b/docs/examples/guide/b583bf8d3a2f49d633aa2cfed5606418.asciidoc index c28dcdd1d6..295a10de52 100644 --- a/docs/examples/guide/b583bf8d3a2f49d633aa2cfed5606418.asciidoc +++ b/docs/examples/guide/b583bf8d3a2f49d633aa2cfed5606418.asciidoc @@ -12,7 +12,7 @@ response = client.cluster.put_component_template( "alias2": { filter: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, routing: 'shard-1' diff --git a/docs/examples/guide/b58b17975bbce307b2ccce5051a449e8.asciidoc b/docs/examples/guide/b58b17975bbce307b2ccce5051a449e8.asciidoc index 7a008b052c..bda784836c 100644 --- a/docs/examples/guide/b58b17975bbce307b2ccce5051a449e8.asciidoc +++ b/docs/examples/guide/b58b17975bbce307b2ccce5051a449e8.asciidoc @@ -7,7 +7,7 @@ response = client.search( body: { query: { range: { - "http.response.bytes": { + 'http.response.bytes' => { lt: 2_000_000 } } diff --git a/docs/examples/guide/b62eaa20c4e0e48134a6d1d1b3c30b26.asciidoc b/docs/examples/guide/b62eaa20c4e0e48134a6d1d1b3c30b26.asciidoc new file mode 100644 index 0000000000..3fecc83c71 --- /dev/null +++ b/docs/examples/guide/b62eaa20c4e0e48134a6d1d1b3c30b26.asciidoc @@ -0,0 +1,191 @@ +[source, ruby] +---- +response = client.bulk( + refresh: true, + body: [ + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized' + }, + { + index: { + _index: 'test-logs' + } + }, + { + message: '[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...' + } + ] +) +puts response + +response = client.text_structure.find_field_structure( + index: 'test-logs', + field: 'message' +) +puts response +---- diff --git a/docs/examples/guide/b638e11d6a8a084290f8934d224abd52.asciidoc b/docs/examples/guide/b638e11d6a8a084290f8934d224abd52.asciidoc index 87c0e6cb06..eba6cdec04 100644 --- a/docs/examples/guide/b638e11d6a8a084290f8934d224abd52.asciidoc +++ b/docs/examples/guide/b638e11d6a8a084290f8934d224abd52.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.max_shards_per_node.frozen": nil + 'cluster.max_shards_per_node.frozen' => nil } } ) diff --git a/docs/examples/guide/b67fa8c560dd10a8e6f226048cd21562.asciidoc b/docs/examples/guide/b67fa8c560dd10a8e6f226048cd21562.asciidoc index ee517ec29d..abfb71a3f5 100644 --- a/docs/examples/guide/b67fa8c560dd10a8e6f226048cd21562.asciidoc +++ b/docs/examples/guide/b67fa8c560dd10a8e6f226048cd21562.asciidoc @@ -7,12 +7,12 @@ response = client.render_search_template( clauses: [ { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, { term: { - "url.domain": 'example.com' + 'url.domain' => 'example.com' } } ] diff --git a/docs/examples/guide/b6a6aa9ba20e9a019371ae268488833f.asciidoc b/docs/examples/guide/b6a6aa9ba20e9a019371ae268488833f.asciidoc new file mode 100644 index 0000000000..a4f24c10ad --- /dev/null +++ b/docs/examples/guide/b6a6aa9ba20e9a019371ae268488833f.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.cluster.get_settings( + filter_path: 'persistent.cluster.remote' +) +puts response +---- diff --git a/docs/examples/guide/b724f547c5d67e95bbc0a9920e47033c.asciidoc b/docs/examples/guide/b724f547c5d67e95bbc0a9920e47033c.asciidoc index 716647e93a..aebebd604f 100644 --- a/docs/examples/guide/b724f547c5d67e95bbc0a9920e47033c.asciidoc +++ b/docs/examples/guide/b724f547c5d67e95bbc0a9920e47033c.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { term: { - "file_path.tree": '/User/alice/photos/2017/05/16' + 'file_path.tree' => '/User/alice/photos/2017/05/16' } } } diff --git a/docs/examples/guide/b7a9f60b3646efe3834ca8381f8aa560.asciidoc b/docs/examples/guide/b7a9f60b3646efe3834ca8381f8aa560.asciidoc index 875fedeb33..3fdf15b9d7 100644 --- a/docs/examples/guide/b7a9f60b3646efe3834ca8381f8aa560.asciidoc +++ b/docs/examples/guide/b7a9f60b3646efe3834ca8381f8aa560.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "logger.org.elasticsearch.discovery": nil + 'logger.org.elasticsearch.discovery' => nil } } ) diff --git a/docs/examples/guide/b8ff63c3d7561d27d035ef204097d631.asciidoc b/docs/examples/guide/b8ff63c3d7561d27d035ef204097d631.asciidoc deleted file mode 100644 index 8d98383046..0000000000 --- a/docs/examples/guide/b8ff63c3d7561d27d035ef204097d631.asciidoc +++ /dev/null @@ -1,24 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'test_index', - body: { - settings: { - index: { - analysis: { - filter: { - synonym: { - type: 'synonym_graph', - synonyms: [ - 'lol, laughing out loud', - 'universe, cosmos' - ] - } - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/bcc75fc01b45e482638c65b8fbdf09fa.asciidoc b/docs/examples/guide/bcc75fc01b45e482638c65b8fbdf09fa.asciidoc new file mode 100644 index 0000000000..1847170105 --- /dev/null +++ b/docs/examples/guide/bcc75fc01b45e482638c65b8fbdf09fa.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.search( + index: 'books' +) +puts response +---- diff --git a/docs/examples/guide/bcdfaa4487747249699a86a0dcd22f5e.asciidoc b/docs/examples/guide/bcdfaa4487747249699a86a0dcd22f5e.asciidoc new file mode 100644 index 0000000000..764a69f690 --- /dev/null +++ b/docs/examples/guide/bcdfaa4487747249699a86a0dcd22f5e.asciidoc @@ -0,0 +1,35 @@ +[source, ruby] +---- +response = client.simulate.ingest( + body: { + docs: [ + { + _index: 'my-index', + _id: '123', + _source: { + foo: 'bar' + } + }, + { + _index: 'my-index', + _id: '456', + _source: { + foo: 'rab' + } + } + ], + pipeline_substitutions: { + "my-pipeline": { + processors: [ + { + uppercase: { + field: 'foo' + } + } + ] + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/bd298b11933605c641626750c981d70b.asciidoc b/docs/examples/guide/bd298b11933605c641626750c981d70b.asciidoc index 183f842042..4ed3cdee10 100644 --- a/docs/examples/guide/bd298b11933605c641626750c981d70b.asciidoc +++ b/docs/examples/guide/bd298b11933605c641626750c981d70b.asciidoc @@ -5,7 +5,7 @@ response = client.cluster.put_component_template( body: { template: { settings: { - "index.number_of_shards": 2 + 'index.number_of_shards' => 2 } } } @@ -17,7 +17,7 @@ response = client.cluster.put_component_template( body: { template: { settings: { - "index.number_of_replicas": 0 + 'index.number_of_replicas' => 0 }, mappings: { properties: { @@ -38,7 +38,7 @@ response = client.indices.simulate_template( ], template: { settings: { - "index.number_of_shards": 3 + 'index.number_of_shards' => 3 } }, composed_of: [ diff --git a/docs/examples/guide/bd2a387e8c21bf01a1039e81d7602921.asciidoc b/docs/examples/guide/bd2a387e8c21bf01a1039e81d7602921.asciidoc new file mode 100644 index 0000000000..473131f62d --- /dev/null +++ b/docs/examples/guide/bd2a387e8c21bf01a1039e81d7602921.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.put_script( + id: 'my-search-template', + body: { + script: { + lang: 'mustache', + source: { + query: { + multi_match: { + query: '{{query_string}}', + fields: '[{{#text_fields}}{{user_name}},{{/text_fields}}]' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/bd7330af2609bdd8aa10958f5e640b93.asciidoc b/docs/examples/guide/bd7330af2609bdd8aa10958f5e640b93.asciidoc index 13b52877d5..558b714bc6 100644 --- a/docs/examples/guide/bd7330af2609bdd8aa10958f5e640b93.asciidoc +++ b/docs/examples/guide/bd7330af2609bdd8aa10958f5e640b93.asciidoc @@ -7,7 +7,7 @@ response = client.index( body: { query: { match: { - "my_field.suffix": 'xyz' + 'my_field.suffix' => 'xyz' } } } diff --git a/docs/examples/guide/bd93b6f99ed785cf7520370a4cf6b834.asciidoc b/docs/examples/guide/bd93b6f99ed785cf7520370a4cf6b834.asciidoc deleted file mode 100644 index fd38aef22a..0000000000 --- a/docs/examples/guide/bd93b6f99ed785cf7520370a4cf6b834.asciidoc +++ /dev/null @@ -1,19 +0,0 @@ -[source, ruby] ----- -response = client.search( - index: 'cluster_one:my-index-000001', - body: { - query: { - match: { - "user.id": 'kimchy' - } - }, - _source: [ - 'user.id', - 'message', - 'http.response.status_code' - ] - } -) -puts response ----- diff --git a/docs/examples/guide/bdfb86cdfffb9d2ee6e3d399f00a57b0.asciidoc b/docs/examples/guide/bdfb86cdfffb9d2ee6e3d399f00a57b0.asciidoc new file mode 100644 index 0000000000..7f1807e9dc --- /dev/null +++ b/docs/examples/guide/bdfb86cdfffb9d2ee6e3d399f00a57b0.asciidoc @@ -0,0 +1,38 @@ +[source, ruby] +---- +response = client.search( + index: 'test*', + filter_path: 'aggregations', + body: { + aggregations: { + ip: { + terms: { + field: 'ip' + }, + aggregations: { + tm: { + top_metrics: { + metrics: { + field: 'm' + }, + sort: { + s: 'desc' + }, + size: 1 + } + }, + having_tm: { + bucket_selector: { + buckets_path: { + top_m: 'tm[m]' + }, + script: 'params.top_m < 1000' + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/be30ea12f605fd61acba689b68e00bbe.asciidoc b/docs/examples/guide/be30ea12f605fd61acba689b68e00bbe.asciidoc new file mode 100644 index 0000000000..4ceb3acb11 --- /dev/null +++ b/docs/examples/guide/be30ea12f605fd61acba689b68e00bbe.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.ingest.put_pipeline( + id: 'hugging_face_embeddings', + body: { + processors: [ + { + inference: { + model_id: 'hugging_face_embeddings', + input_output: { + input_field: 'content', + output_field: 'content_embedding' + } + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/beba2a9795c8a13653e1edf64eec4357.asciidoc b/docs/examples/guide/beba2a9795c8a13653e1edf64eec4357.asciidoc index 92894faa71..66ed47d74b 100644 --- a/docs/examples/guide/beba2a9795c8a13653e1edf64eec4357.asciidoc +++ b/docs/examples/guide/beba2a9795c8a13653e1edf64eec4357.asciidoc @@ -3,8 +3,8 @@ response = client.indices.put_settings( index: 'test', body: { - "index.routing.allocation.require.size": 'big', - "index.routing.allocation.require.rack": 'rack1' + 'index.routing.allocation.require.size' => 'big', + 'index.routing.allocation.require.rack' => 'rack1' } ) puts response diff --git a/docs/examples/guide/bf17440ac178d2ef5f5be643d033920b.asciidoc b/docs/examples/guide/bf17440ac178d2ef5f5be643d033920b.asciidoc new file mode 100644 index 0000000000..fce14b1e5c --- /dev/null +++ b/docs/examples/guide/bf17440ac178d2ef5f5be643d033920b.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.reindex( + wait_for_completion: false, + body: { + source: { + index: 'test-data', + size: 50 + }, + dest: { + index: 'my-index', + pipeline: 'elser-v2-test' + } + } +) +puts response +---- diff --git a/docs/examples/guide/c00c9412609832ebceb9e786dd9542df.asciidoc b/docs/examples/guide/c00c9412609832ebceb9e786dd9542df.asciidoc new file mode 100644 index 0000000000..9de66a6634 --- /dev/null +++ b/docs/examples/guide/c00c9412609832ebceb9e786dd9542df.asciidoc @@ -0,0 +1,11 @@ +[source, ruby] +---- +response = client.connector.update_name( + connector_id: 'my-connector', + body: { + name: 'Custom connector', + description: 'This is my customized connector' + } +) +puts response +---- diff --git a/docs/examples/guide/c03ce952de42eae4b522cedc9fd3d14a.asciidoc b/docs/examples/guide/c03ce952de42eae4b522cedc9fd3d14a.asciidoc new file mode 100644 index 0000000000..e01b21843c --- /dev/null +++ b/docs/examples/guide/c03ce952de42eae4b522cedc9fd3d14a.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'POLYGON ((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2))' + } +) +puts response +---- diff --git a/docs/examples/guide/c0c638e3d218b0ecbe5c4d77c964ae9e.asciidoc b/docs/examples/guide/c0c638e3d218b0ecbe5c4d77c964ae9e.asciidoc index 17f1c2f485..f5256a99aa 100644 --- a/docs/examples/guide/c0c638e3d218b0ecbe5c4d77c964ae9e.asciidoc +++ b/docs/examples/guide/c0c638e3d218b0ecbe5c4d77c964ae9e.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { term: { - "user.id": { + 'user.id' => { value: 'kimchy', boost: 1 } diff --git a/docs/examples/guide/c12d6e962f083c728f9397932f05202e.asciidoc b/docs/examples/guide/c12d6e962f083c728f9397932f05202e.asciidoc new file mode 100644 index 0000000000..af049b4a60 --- /dev/null +++ b/docs/examples/guide/c12d6e962f083c728f9397932f05202e.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.sync_job_list( + connector_id: 'connector-1' +) +puts response +---- diff --git a/docs/examples/guide/c147de68fd6da032ad4a3c1bf626f5d6.asciidoc b/docs/examples/guide/c147de68fd6da032ad4a3c1bf626f5d6.asciidoc index d546052bea..bec37a16f4 100644 --- a/docs/examples/guide/c147de68fd6da032ad4a3c1bf626f5d6.asciidoc +++ b/docs/examples/guide/c147de68fd6da032ad4a3c1bf626f5d6.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { diff --git a/docs/examples/guide/c21eb4bc30087188241cbba6b6b89999.asciidoc b/docs/examples/guide/c21eb4bc30087188241cbba6b6b89999.asciidoc new file mode 100644 index 0000000000..8d2f8d4065 --- /dev/null +++ b/docs/examples/guide/c21eb4bc30087188241cbba6b6b89999.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.connector.update_service_type( + connector_id: 'my-connector', + body: { + service_type: 'sharepoint_online' + } +) +puts response +---- diff --git a/docs/examples/guide/c23e32775340d7bc6f46820313014d8a.asciidoc b/docs/examples/guide/c23e32775340d7bc6f46820313014d8a.asciidoc new file mode 100644 index 0000000000..e805168775 --- /dev/null +++ b/docs/examples/guide/c23e32775340d7bc6f46820313014d8a.asciidoc @@ -0,0 +1,14 @@ +[source, ruby] +---- +response = client.index( + index: 'my_test_scores_2', + pipeline: 'my_test_scores_pipeline', + body: { + student: 'kimchy', + grad_year: '2099', + math_score: 1200, + verbal_score: 800 + } +) +puts response +---- diff --git a/docs/examples/guide/c5cc19e48549fbc5327a9d46874bbeee.asciidoc b/docs/examples/guide/c5cc19e48549fbc5327a9d46874bbeee.asciidoc new file mode 100644 index 0000000000..fa4724efbb --- /dev/null +++ b/docs/examples/guide/c5cc19e48549fbc5327a9d46874bbeee.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.search( + index: 'quantized-image-index', + body: { + knn: { + field: 'image-vector', + query_vector: [ + 0.1, + -2 + ], + k: 10, + num_candidates: 100 + }, + fields: [ + 'title' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/c639036b87d02fb864e27c4ca29ef833.asciidoc b/docs/examples/guide/c639036b87d02fb864e27c4ca29ef833.asciidoc index 70085a418a..c219c225be 100644 --- a/docs/examples/guide/c639036b87d02fb864e27c4ca29ef833.asciidoc +++ b/docs/examples/guide/c639036b87d02fb864e27c4ca29ef833.asciidoc @@ -10,7 +10,7 @@ response = client.search( } }, runtime_mappings: { - "tags.hash": { + 'tags.hash' => { type: 'long', script: "emit(doc['tags'].hashCode())" } diff --git a/docs/examples/guide/c654b09be981be12fc7be0ba33f8652b.asciidoc b/docs/examples/guide/c654b09be981be12fc7be0ba33f8652b.asciidoc new file mode 100644 index 0000000000..2dfe3a115a --- /dev/null +++ b/docs/examples/guide/c654b09be981be12fc7be0ba33f8652b.asciidoc @@ -0,0 +1,68 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'multilinestring', + coordinates: [ + [ + [ + 1002, + 200 + ], + [ + 1003, + 200 + ], + [ + 1003, + 300 + ], + [ + 1002, + 300 + ] + ], + [ + [ + 1000, + 100 + ], + [ + 1001, + 100 + ], + [ + 1001, + 100 + ], + [ + 1000, + 100 + ] + ], + [ + [ + 1000.2, + 100.2 + ], + [ + 1000.8, + 100.2 + ], + [ + 1000.8, + 100.8 + ], + [ + 1000.2, + 100.8 + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/c6b365c7da97d7e50f36820a7d36f548.asciidoc b/docs/examples/guide/c6b365c7da97d7e50f36820a7d36f548.asciidoc index cef43b446e..5e88cc78b4 100644 --- a/docs/examples/guide/c6b365c7da97d7e50f36820a7d36f548.asciidoc +++ b/docs/examples/guide/c6b365c7da97d7e50f36820a7d36f548.asciidoc @@ -3,7 +3,7 @@ response = client.indices.put_settings( index: 'my_index,my_other_index', body: { - "index.number_of_replicas": 1 + 'index.number_of_replicas' => 1 } ) puts response diff --git a/docs/examples/guide/c6b8713bd49661d69d6b868f5b991d17.asciidoc b/docs/examples/guide/c6b8713bd49661d69d6b868f5b991d17.asciidoc new file mode 100644 index 0000000000..251b5f7aef --- /dev/null +++ b/docs/examples/guide/c6b8713bd49661d69d6b868f5b991d17.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.index( + index: 'job-candidates', + id: 1, + refresh: true, + body: { + name: 'Jane Smith', + programming_languages: [ + 'c++', + 'java' + ], + required_matches: 2 + } +) +puts response +---- diff --git a/docs/examples/guide/c6d5e3b6ff9c665ec5344a4bfa7add80.asciidoc b/docs/examples/guide/c6d5e3b6ff9c665ec5344a4bfa7add80.asciidoc index dca0ac8dda..7ae0b33dbd 100644 --- a/docs/examples/guide/c6d5e3b6ff9c665ec5344a4bfa7add80.asciidoc +++ b/docs/examples/guide/c6d5e3b6ff9c665ec5344a4bfa7add80.asciidoc @@ -3,8 +3,8 @@ response = client.cluster.put_settings( body: { persistent: { - "transport.tracer.include": '*', - "transport.tracer.exclude": 'internal:coordination/fault_detection/*' + 'transport.tracer.include' => '*', + 'transport.tracer.exclude' => 'internal:coordination/fault_detection/*' } } ) diff --git a/docs/examples/guide/c8210f23c10d0642f24c1e43faa4deda.asciidoc b/docs/examples/guide/c8210f23c10d0642f24c1e43faa4deda.asciidoc index 92183050c9..b2bd798c45 100644 --- a/docs/examples/guide/c8210f23c10d0642f24c1e43faa4deda.asciidoc +++ b/docs/examples/guide/c8210f23c10d0642f24c1e43faa4deda.asciidoc @@ -29,7 +29,7 @@ response = client.cluster.put_component_template( body: { template: { settings: { - "index.lifecycle.name": 'my-lifecycle-policy' + 'index.lifecycle.name' => 'my-lifecycle-policy' } }, _meta: { diff --git a/docs/examples/guide/c8e2109b19d50467ab83a40006462e9f.asciidoc b/docs/examples/guide/c8e2109b19d50467ab83a40006462e9f.asciidoc new file mode 100644 index 0000000000..bca712d4d5 --- /dev/null +++ b/docs/examples/guide/c8e2109b19d50467ab83a40006462e9f.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.enrich.execute_policy( + name: 'my-policy', + wait_for_completion: false +) +puts response +---- diff --git a/docs/examples/guide/c93e63f3fb62f588d62ffbbefe73212e.asciidoc b/docs/examples/guide/c93e63f3fb62f588d62ffbbefe73212e.asciidoc deleted file mode 100644 index 121073c7ba..0000000000 --- a/docs/examples/guide/c93e63f3fb62f588d62ffbbefe73212e.asciidoc +++ /dev/null @@ -1,24 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'image-index', - body: { - mappings: { - properties: { - "image-vector": { - type: 'dense_vector', - dims: 3, - index: true, - similarity: 'l2_norm', - index_options: { - type: 'hnsw', - m: 32, - ef_construction: 100 - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/c9a6ab0a56bb0177f158277185f68302.asciidoc b/docs/examples/guide/c9a6ab0a56bb0177f158277185f68302.asciidoc new file mode 100644 index 0000000000..b740ab6108 --- /dev/null +++ b/docs/examples/guide/c9a6ab0a56bb0177f158277185f68302.asciidoc @@ -0,0 +1,57 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index-000001', + body: { + mappings: { + properties: { + metrics: { + type: 'object', + subobjects: false, + properties: { + time: { + type: 'long' + }, + 'time.min' => { + type: 'long' + }, + 'time.max' => { + type: 'long' + } + } + } + } + } + } +) +puts response + +response = client.index( + index: 'my-index-000001', + id: 'metric_1', + body: { + 'metrics.time' => 100, + 'metrics.time.min' => 10, + 'metrics.time.max' => 900 + } +) +puts response + +response = client.index( + index: 'my-index-000001', + id: 'metric_2', + body: { + metrics: { + time: 100, + 'time.min' => 10, + 'time.max' => 900 + } + } +) +puts response + +response = client.indices.get_mapping( + index: 'my-index-000001' +) +puts response +---- diff --git a/docs/examples/guide/c9afa715021f2e6450e72ac73271960c.asciidoc b/docs/examples/guide/c9afa715021f2e6450e72ac73271960c.asciidoc new file mode 100644 index 0000000000..28bfc03130 --- /dev/null +++ b/docs/examples/guide/c9afa715021f2e6450e72ac73271960c.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.index( + index: 'parent_example', + id: 1, + body: { + join: { + name: 'question' + }, + body: 'I have Windows 2003 server and i bought a new Windows 2008 server...', + title: 'Whats the best way to file transfer my site from server to a newer one?', + tags: [ + 'windows-server-2003', + 'windows-server-2008', + 'file-transfer' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/c9d9a1d751f20f6197c825cb4378fe9f.asciidoc b/docs/examples/guide/c9d9a1d751f20f6197c825cb4378fe9f.asciidoc index c3d3086e7e..9ce4d41e18 100644 --- a/docs/examples/guide/c9d9a1d751f20f6197c825cb4378fe9f.asciidoc +++ b/docs/examples/guide/c9d9a1d751f20f6197c825cb4378fe9f.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { terms: { - "user.id": [ + 'user.id' => [ 'kimchy', 'elkbee' ], diff --git a/docs/examples/guide/ca06db2aa4747910278f96315f7be94b.asciidoc b/docs/examples/guide/ca06db2aa4747910278f96315f7be94b.asciidoc index 57dbb4e978..2af4363f12 100644 --- a/docs/examples/guide/ca06db2aa4747910278f96315f7be94b.asciidoc +++ b/docs/examples/guide/ca06db2aa4747910278f96315f7be94b.asciidoc @@ -10,7 +10,7 @@ response = client.search( }, filter: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { top: 40.73, left: -74.1, bottom: 40.01, diff --git a/docs/examples/guide/ca08e511e5907d258081b10a1a9f0072.asciidoc b/docs/examples/guide/ca08e511e5907d258081b10a1a9f0072.asciidoc index 75e97033a2..f03c7172ea 100644 --- a/docs/examples/guide/ca08e511e5907d258081b10a1a9f0072.asciidoc +++ b/docs/examples/guide/ca08e511e5907d258081b10a1a9f0072.asciidoc @@ -17,10 +17,10 @@ response = client.indices.put_index_template( } }, settings: { - "sort.field": [ + 'sort.field' => [ '@timestamp' ], - "sort.order": [ + 'sort.order' => [ 'desc' ] } diff --git a/docs/examples/guide/cafed0e2c2b1d1574eb4a5ecd514a97a.asciidoc b/docs/examples/guide/cafed0e2c2b1d1574eb4a5ecd514a97a.asciidoc index b1e32fee6c..0558bde6e6 100644 --- a/docs/examples/guide/cafed0e2c2b1d1574eb4a5ecd514a97a.asciidoc +++ b/docs/examples/guide/cafed0e2c2b1d1574eb4a5ecd514a97a.asciidoc @@ -5,7 +5,7 @@ response = client.indices.split( target: 'split-my-index-000001', body: { settings: { - "index.number_of_shards": 2 + 'index.number_of_shards' => 2 } } ) diff --git a/docs/examples/guide/cb0c3223fd45148497df73adfba2e9ce.asciidoc b/docs/examples/guide/cb0c3223fd45148497df73adfba2e9ce.asciidoc index 035249c0ae..93e5d03d8b 100644 --- a/docs/examples/guide/cb0c3223fd45148497df73adfba2e9ce.asciidoc +++ b/docs/examples/guide/cb0c3223fd45148497df73adfba2e9ce.asciidoc @@ -6,7 +6,7 @@ response = client.reindex( index: 'my-index-000001', query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } }, diff --git a/docs/examples/guide/cbc2b5595890f87165aab1a741b1d22c.asciidoc b/docs/examples/guide/cbc2b5595890f87165aab1a741b1d22c.asciidoc new file mode 100644 index 0000000000..e318873277 --- /dev/null +++ b/docs/examples/guide/cbc2b5595890f87165aab1a741b1d22c.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.ingest.put_pipeline( + id: 'my-timestamp-pipeline', + body: { + description: 'Shifts the @timestamp to the last 15 minutes', + processors: [ + { + set: { + field: 'ingest_time', + value: '{{_ingest.timestamp}}' + } + }, + { + script: { + lang: 'painless', + source: "\n def delta = ChronoUnit.SECONDS.between(\n ZonedDateTime.parse(\"2022-06-21T15:49:00Z\"),\n ZonedDateTime.parse(ctx[\"ingest_time\"])\n );\n ctx[\"@timestamp\"] = ZonedDateTime.parse(ctx[\"@timestamp\"]).plus(delta,ChronoUnit.SECONDS).toString();\n " + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/cc28a3dafcd5056f2a3ec07f6fda5091.asciidoc b/docs/examples/guide/cc28a3dafcd5056f2a3ec07f6fda5091.asciidoc new file mode 100644 index 0000000000..430772d14d --- /dev/null +++ b/docs/examples/guide/cc28a3dafcd5056f2a3ec07f6fda5091.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index-000001', + body: { + runtime_mappings: { + day_of_week: { + type: 'keyword', + script: { + source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))" + } + } + }, + aggregations: { + day_of_week: { + terms: { + field: 'day_of_week' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/cc7f1c74ede6810e2c9db19256d6b653.asciidoc b/docs/examples/guide/cc7f1c74ede6810e2c9db19256d6b653.asciidoc index 18a0c7c26b..f34d61a238 100644 --- a/docs/examples/guide/cc7f1c74ede6810e2c9db19256d6b653.asciidoc +++ b/docs/examples/guide/cc7f1c74ede6810e2c9db19256d6b653.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { match: { - "http.response": '304' + 'http.response' => '304' } }, fields: [ diff --git a/docs/examples/guide/cd16538654e0f834ff19fe6cf329c398.asciidoc b/docs/examples/guide/cd16538654e0f834ff19fe6cf329c398.asciidoc new file mode 100644 index 0000000000..c385c2be7d --- /dev/null +++ b/docs/examples/guide/cd16538654e0f834ff19fe6cf329c398.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'hugging-face-embeddings', + body: { + mappings: { + properties: { + content_embedding: { + type: 'dense_vector', + dims: 768, + element_type: 'float' + }, + content: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/cdce7bc083dfb36e6f1d465a5c9d5049.asciidoc b/docs/examples/guide/cdce7bc083dfb36e6f1d465a5c9d5049.asciidoc new file mode 100644 index 0000000000..6e9f003a13 --- /dev/null +++ b/docs/examples/guide/cdce7bc083dfb36e6f1d465a5c9d5049.asciidoc @@ -0,0 +1,5 @@ +[source, ruby] +---- +response = client.connector.sync_job_list +puts response +---- diff --git a/docs/examples/guide/cdd7127681254f4d614cc075f9e6fbcf.asciidoc b/docs/examples/guide/cdd7127681254f4d614cc075f9e6fbcf.asciidoc index 31dec0f24d..bda041005b 100644 --- a/docs/examples/guide/cdd7127681254f4d614cc075f9e6fbcf.asciidoc +++ b/docs/examples/guide/cdd7127681254f4d614cc075f9e6fbcf.asciidoc @@ -5,7 +5,7 @@ response = client.delete_by_query( body: { query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, max_docs: 1 diff --git a/docs/examples/guide/cde19d110a58317610033ea3dcb0eb80.asciidoc b/docs/examples/guide/cde19d110a58317610033ea3dcb0eb80.asciidoc new file mode 100644 index 0000000000..876bde8b82 --- /dev/null +++ b/docs/examples/guide/cde19d110a58317610033ea3dcb0eb80.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.render_search_template( + body: { + source: "\n {\n \"query\": {\n \"match\": {\n {{#query_message}}\n {{#query_string}}\n \"message\": \"Hello {{#first_name_section}}{{first_name}}{{/first_name_section}} {{#last_name_section}}{{last_name}}{{/last_name_section}}\"\n {{/query_string}}\n {{/query_message}}\n }\n }\n }\n ", + params: { + query_message: { + query_string: { + first_name_section: { + first_name: 'John' + }, + last_name_section: { + last_name: 'kimchy' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/cdfd4fef983c1c0fe8d7417f67d01eae.asciidoc b/docs/examples/guide/cdfd4fef983c1c0fe8d7417f67d01eae.asciidoc index e40927b7a6..0d75f56638 100644 --- a/docs/examples/guide/cdfd4fef983c1c0fe8d7417f67d01eae.asciidoc +++ b/docs/examples/guide/cdfd4fef983c1c0fe8d7417f67d01eae.asciidoc @@ -2,7 +2,7 @@ ---- response = client.indices.put_settings( body: { - "index.number_of_replicas": 1 + 'index.number_of_replicas' => 1 } ) puts response diff --git a/docs/examples/guide/ce13afc0c976c5e1f424b58e0c97fd64.asciidoc b/docs/examples/guide/ce13afc0c976c5e1f424b58e0c97fd64.asciidoc new file mode 100644 index 0000000000..82556abd34 --- /dev/null +++ b/docs/examples/guide/ce13afc0c976c5e1f424b58e0c97fd64.asciidoc @@ -0,0 +1,14 @@ +[source, ruby] +---- +response = client.connector.put( + connector_id: 'my-connector', + body: { + index_name: 'search-google-drive', + name: 'My Connector', + description: 'My Connector to sync data to Elastic index from Google Drive', + service_type: 'google_drive', + language: 'english' + } +) +puts response +---- diff --git a/docs/examples/guide/ce247fc08371e1b30cb52195e521c076.asciidoc b/docs/examples/guide/ce247fc08371e1b30cb52195e521c076.asciidoc index a32269b6ad..c17bca3e37 100644 --- a/docs/examples/guide/ce247fc08371e1b30cb52195e521c076.asciidoc +++ b/docs/examples/guide/ce247fc08371e1b30cb52195e521c076.asciidoc @@ -10,7 +10,7 @@ response = client.search( }, filter: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { top_left: [ -74.1, 40.73 diff --git a/docs/examples/guide/ce899fcf55da72fc32e623d1ad88b301.asciidoc b/docs/examples/guide/ce899fcf55da72fc32e623d1ad88b301.asciidoc index d417e621e7..ec7f7a3277 100644 --- a/docs/examples/guide/ce899fcf55da72fc32e623d1ad88b301.asciidoc +++ b/docs/examples/guide/ce899fcf55da72fc32e623d1ad88b301.asciidoc @@ -6,7 +6,7 @@ response = client.cluster.put_component_template( template: { mappings: { properties: { - "host.ip": { + 'host.ip' => { type: 'ip' } } diff --git a/docs/examples/guide/cf23f18761df33f08bc6f6d1875496fd.asciidoc b/docs/examples/guide/cf23f18761df33f08bc6f6d1875496fd.asciidoc index 1c957c940e..b9b4ca57f2 100644 --- a/docs/examples/guide/cf23f18761df33f08bc6f6d1875496fd.asciidoc +++ b/docs/examples/guide/cf23f18761df33f08bc6f6d1875496fd.asciidoc @@ -4,7 +4,7 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { index: { - "routing.allocation.total_shards_per_node": 5 + 'routing.allocation.total_shards_per_node' => 5 } } ) diff --git a/docs/examples/guide/cf5dab4334783ca9b8942eab68fb7174.asciidoc b/docs/examples/guide/cf5dab4334783ca9b8942eab68fb7174.asciidoc index 19097edf50..32d9fb404e 100644 --- a/docs/examples/guide/cf5dab4334783ca9b8942eab68fb7174.asciidoc +++ b/docs/examples/guide/cf5dab4334783ca9b8942eab68fb7174.asciidoc @@ -21,7 +21,7 @@ response = client.search( filter: [ { term: { - "resellers.reseller": 'companyB' + 'resellers.reseller' => 'companyB' } } ] diff --git a/docs/examples/guide/d003ee256d24aa6000bd9dbf1d608dc5.asciidoc b/docs/examples/guide/d003ee256d24aa6000bd9dbf1d608dc5.asciidoc new file mode 100644 index 0000000000..6b7d70b4fb --- /dev/null +++ b/docs/examples/guide/d003ee256d24aa6000bd9dbf1d608dc5.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.ingest.put_pipeline( + id: 'elser-v2-test', + body: { + processors: [ + { + inference: { + model_id: '.elser_model_2', + input_output: [ + { + input_field: 'content', + output_field: 'content_embedding' + } + ] + } + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/d01d309b0257d6fbca6d0941adeb3256.asciidoc b/docs/examples/guide/d01d309b0257d6fbca6d0941adeb3256.asciidoc index 01291a575b..cc7e5bed9b 100644 --- a/docs/examples/guide/d01d309b0257d6fbca6d0941adeb3256.asciidoc +++ b/docs/examples/guide/d01d309b0257d6fbca6d0941adeb3256.asciidoc @@ -5,7 +5,7 @@ response = client.cluster.put_component_template( body: { template: { settings: { - "index.number_of_shards": 2 + 'index.number_of_shards' => 2 } } } @@ -17,7 +17,7 @@ response = client.cluster.put_component_template( body: { template: { settings: { - "index.number_of_replicas": 0 + 'index.number_of_replicas' => 0 }, mappings: { properties: { diff --git a/docs/examples/guide/d03139a851888db53f8b7affd85eb495.asciidoc b/docs/examples/guide/d03139a851888db53f8b7affd85eb495.asciidoc new file mode 100644 index 0000000000..b2689578e1 --- /dev/null +++ b/docs/examples/guide/d03139a851888db53f8b7affd85eb495.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.check_in( + connector_id: 'my-connector' +) +puts response +---- diff --git a/docs/examples/guide/d04f0c8c44e8b4fb55f2e7d9d05977e7.asciidoc b/docs/examples/guide/d04f0c8c44e8b4fb55f2e7d9d05977e7.asciidoc new file mode 100644 index 0000000000..ba6b1c7ee4 --- /dev/null +++ b/docs/examples/guide/d04f0c8c44e8b4fb55f2e7d9d05977e7.asciidoc @@ -0,0 +1,63 @@ +[source, ruby] +---- +response = client.bulk( + body: [ + { + index: { + _index: 'books' + } + }, + { + name: 'Revelation Space', + author: 'Alastair Reynolds', + release_date: '2000-03-15', + page_count: 585 + }, + { + index: { + _index: 'books' + } + }, + { + name: '1984', + author: 'George Orwell', + release_date: '1985-06-01', + page_count: 328 + }, + { + index: { + _index: 'books' + } + }, + { + name: 'Fahrenheit 451', + author: 'Ray Bradbury', + release_date: '1953-10-15', + page_count: 227 + }, + { + index: { + _index: 'books' + } + }, + { + name: 'Brave New World', + author: 'Aldous Huxley', + release_date: '1932-06-01', + page_count: 268 + }, + { + index: { + _index: 'books' + } + }, + { + name: 'The Handmaids Tale', + author: 'Margaret Atwood', + release_date: '1985-06-01', + page_count: 311 + } + ] +) +puts response +---- diff --git a/docs/examples/guide/d0546f047359b85a7e98207dc8de896a.asciidoc b/docs/examples/guide/d0546f047359b85a7e98207dc8de896a.asciidoc index 36ccdf84ed..9ff4eb92b0 100644 --- a/docs/examples/guide/d0546f047359b85a7e98207dc8de896a.asciidoc +++ b/docs/examples/guide/d0546f047359b85a7e98207dc8de896a.asciidoc @@ -4,7 +4,7 @@ response = client.indices.create( index: 'my-index-000001', body: { settings: { - "index.mapping.coerce": false + 'index.mapping.coerce' => false }, mappings: { properties: { diff --git a/docs/examples/guide/d05b2a37106fce0ebbd41e2fd6bd26c2.asciidoc b/docs/examples/guide/d05b2a37106fce0ebbd41e2fd6bd26c2.asciidoc index 77be78daea..87b32cf62b 100644 --- a/docs/examples/guide/d05b2a37106fce0ebbd41e2fd6bd26c2.asciidoc +++ b/docs/examples/guide/d05b2a37106fce0ebbd41e2fd6bd26c2.asciidoc @@ -19,7 +19,7 @@ response = client.index( id: 1, refresh: true, body: { - "network.name": 'net-1', + 'network.name' => 'net-1', latency_histo: { values: [ 0.1, @@ -45,7 +45,7 @@ response = client.index( id: 2, refresh: true, body: { - "network.name": 'net-2', + 'network.name' => 'net-2', latency_histo: { values: [ 0.1, diff --git a/docs/examples/guide/d13c7cdfc976e0c7b70737cd6a7becb8.asciidoc b/docs/examples/guide/d13c7cdfc976e0c7b70737cd6a7becb8.asciidoc index ce6ccb35c9..1e33001007 100644 --- a/docs/examples/guide/d13c7cdfc976e0c7b70737cd6a7becb8.asciidoc +++ b/docs/examples/guide/d13c7cdfc976e0c7b70737cd6a7becb8.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "price.adjusted": { + 'price.adjusted' => { type: 'double', script: { source: "emit(doc['price'].value * params.adjustment)", diff --git a/docs/examples/guide/d14fe5838fc02224f4b5ade2626d6026.asciidoc b/docs/examples/guide/d14fe5838fc02224f4b5ade2626d6026.asciidoc new file mode 100644 index 0000000000..2560f1c381 --- /dev/null +++ b/docs/examples/guide/d14fe5838fc02224f4b5ade2626d6026.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.ilm.explain_lifecycle( + index: 'my-index-000001', + human: true +) +puts response +---- diff --git a/docs/examples/guide/d29b00db13c625d4832e69635259db66.asciidoc b/docs/examples/guide/d29b00db13c625d4832e69635259db66.asciidoc deleted file mode 100644 index c6e932ab8e..0000000000 --- a/docs/examples/guide/d29b00db13c625d4832e69635259db66.asciidoc +++ /dev/null @@ -1,7 +0,0 @@ -[source, ruby] ----- -response = client.search( - index: 'sample-01*' -) -puts response ----- diff --git a/docs/examples/guide/d434219a4b2d26b22dfc0ce7969240c8.asciidoc b/docs/examples/guide/d434219a4b2d26b22dfc0ce7969240c8.asciidoc deleted file mode 100644 index 8554f0126d..0000000000 --- a/docs/examples/guide/d434219a4b2d26b22dfc0ce7969240c8.asciidoc +++ /dev/null @@ -1,29 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'test_index', - body: { - settings: { - index: { - analysis: { - analyzer: { - search_synonyms: { - tokenizer: 'whitespace', - filter: [ - 'graph_synonyms' - ] - } - }, - filter: { - graph_synonyms: { - type: 'synonym_graph', - synonyms_path: 'analysis/synonym.txt' - } - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/d49318764244113ad2ac4cc0f06d77ec.asciidoc b/docs/examples/guide/d49318764244113ad2ac4cc0f06d77ec.asciidoc new file mode 100644 index 0000000000..d9ba8e8dc9 --- /dev/null +++ b/docs/examples/guide/d49318764244113ad2ac4cc0f06d77ec.asciidoc @@ -0,0 +1,23 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'image-index', + body: { + mappings: { + properties: { + "image-vector": { + type: 'dense_vector', + dims: 3, + similarity: 'l2_norm', + index_options: { + type: 'hnsw', + m: 32, + ef_construction: 100 + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/d4fb482a51d67a1af48e429af6019a46.asciidoc b/docs/examples/guide/d4fb482a51d67a1af48e429af6019a46.asciidoc index 53575aee58..494d3b6379 100644 --- a/docs/examples/guide/d4fb482a51d67a1af48e429af6019a46.asciidoc +++ b/docs/examples/guide/d4fb482a51d67a1af48e429af6019a46.asciidoc @@ -5,11 +5,11 @@ response = client.indices.create( body: { settings: { index: { - "sort.field": [ + 'sort.field' => [ 'username', 'date' ], - "sort.order": [ + 'sort.order' => [ 'asc', 'desc' ] diff --git a/docs/examples/guide/d5d022fac900b3244c3d24b185bb19e0.asciidoc b/docs/examples/guide/d5d022fac900b3244c3d24b185bb19e0.asciidoc new file mode 100644 index 0000000000..def5c7a6a6 --- /dev/null +++ b/docs/examples/guide/d5d022fac900b3244c3d24b185bb19e0.asciidoc @@ -0,0 +1,30 @@ +[source, ruby] +---- +response = client.search( + index: 'my-image-index', + body: { + size: 10, + query: { + bool: { + must: { + knn: { + field: 'image-vector', + query_vector: [ + -5, + 9, + -12 + ], + num_candidates: 3 + } + }, + filter: { + term: { + "file-type": 'png' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/d64d509440afbed7cefd04b6898962eb.asciidoc b/docs/examples/guide/d64d509440afbed7cefd04b6898962eb.asciidoc index 34fc1e51ab..bb5de5d801 100644 --- a/docs/examples/guide/d64d509440afbed7cefd04b6898962eb.asciidoc +++ b/docs/examples/guide/d64d509440afbed7cefd04b6898962eb.asciidoc @@ -11,7 +11,7 @@ response = client.search( filter: { geo_distance: { distance: '200km', - "pin.location": { + 'pin.location' => { lat: 40, lon: -70 } diff --git a/docs/examples/guide/d66e2b4d1931bf88c72e74670156e43f.asciidoc b/docs/examples/guide/d66e2b4d1931bf88c72e74670156e43f.asciidoc index 1da82c4aae..d1654a1502 100644 --- a/docs/examples/guide/d66e2b4d1931bf88c72e74670156e43f.asciidoc +++ b/docs/examples/guide/d66e2b4d1931bf88c72e74670156e43f.asciidoc @@ -6,7 +6,7 @@ response = client.search( track_total_hits: 100, query: { match: { - "user.id": 'elkbee' + 'user.id' => 'elkbee' } } } diff --git a/docs/examples/guide/d690a6af462c70a783625a323e11c72c.asciidoc b/docs/examples/guide/d690a6af462c70a783625a323e11c72c.asciidoc index 33f926266d..6f092450de 100644 --- a/docs/examples/guide/d690a6af462c70a783625a323e11c72c.asciidoc +++ b/docs/examples/guide/d690a6af462c70a783625a323e11c72c.asciidoc @@ -6,7 +6,7 @@ response = client.indices.create( settings: { number_of_shards: 1, number_of_replicas: 1, - "index.lifecycle.name": 'my_policy' + 'index.lifecycle.name' => 'my_policy' } } ) diff --git a/docs/examples/guide/d6c3659339ef4f2d47425e09eccbf939.asciidoc b/docs/examples/guide/d6c3659339ef4f2d47425e09eccbf939.asciidoc deleted file mode 100644 index 5b41e27968..0000000000 --- a/docs/examples/guide/d6c3659339ef4f2d47425e09eccbf939.asciidoc +++ /dev/null @@ -1,19 +0,0 @@ -[source, ruby] ----- -response = client.cluster.put_component_template( - name: 'my-weather-sensor-settings', - body: { - template: { - settings: { - "index.lifecycle.name": 'my-lifecycle-policy', - "index.look_ahead_time": '3h', - "index.codec": 'best_compression' - } - }, - _meta: { - description: 'Index settings for weather sensor data' - } - } -) -puts response ----- diff --git a/docs/examples/guide/d70f55cd29cdb2dcd775ffa9e23ff393.asciidoc b/docs/examples/guide/d70f55cd29cdb2dcd775ffa9e23ff393.asciidoc index 34cbaf1a1f..6bc65c851e 100644 --- a/docs/examples/guide/d70f55cd29cdb2dcd775ffa9e23ff393.asciidoc +++ b/docs/examples/guide/d70f55cd29cdb2dcd775ffa9e23ff393.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "price.adjusted": { + 'price.adjusted' => { type: 'double', script: "\n double price = doc['price'].value;\n if (doc['promoted'].value) {\n price *= 0.8;\n }\n emit(price);\n " } diff --git a/docs/examples/guide/d7a55a7c491e97079e429483085f1d58.asciidoc b/docs/examples/guide/d7a55a7c491e97079e429483085f1d58.asciidoc new file mode 100644 index 0000000000..2531d6787d --- /dev/null +++ b/docs/examples/guide/d7a55a7c491e97079e429483085f1d58.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'dsl-data-stream-template', + body: { + index_patterns: [ + 'dsl-data-stream*' + ], + data_stream: {}, + priority: 500, + template: { + settings: { + 'index.lifecycle.name' => 'pre-dsl-ilm-policy' + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/d8310e5606c61e7a6e64a90838b1a830.asciidoc b/docs/examples/guide/d8310e5606c61e7a6e64a90838b1a830.asciidoc new file mode 100644 index 0000000000..f884f49b3a --- /dev/null +++ b/docs/examples/guide/d8310e5606c61e7a6e64a90838b1a830.asciidoc @@ -0,0 +1,43 @@ +[source, ruby] +---- +response = client.index( + index: 'parent_example', + id: 2, + routing: 1, + body: { + join: { + name: 'answer', + parent: '1' + }, + owner: { + location: 'Norfolk, United Kingdom', + display_name: 'Sam', + id: 48 + }, + body: "Unfortunately you're pretty much limited to FTP...", + creation_date: '2009-05-04T13:45:37.030' + } +) +puts response + +response = client.index( + index: 'parent_example', + id: 3, + routing: 1, + refresh: true, + body: { + join: { + name: 'answer', + parent: '1' + }, + owner: { + location: 'Norfolk, United Kingdom', + display_name: 'Troll', + id: 49 + }, + body: 'Use Linux...', + creation_date: '2009-05-05T13:45:37.030' + } +) +puts response +---- diff --git a/docs/examples/guide/d8ea6a1a1c546bf29f65f8c65439b156.asciidoc b/docs/examples/guide/d8ea6a1a1c546bf29f65f8c65439b156.asciidoc new file mode 100644 index 0000000000..35bb975b4f --- /dev/null +++ b/docs/examples/guide/d8ea6a1a1c546bf29f65f8c65439b156.asciidoc @@ -0,0 +1,21 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'byte-image-index', + body: { + mappings: { + properties: { + "byte-image-vector": { + type: 'dense_vector', + element_type: 'byte', + dims: 2 + }, + title: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/d93d52b6057a7aff3d0766ca44c505e0.asciidoc b/docs/examples/guide/d93d52b6057a7aff3d0766ca44c505e0.asciidoc new file mode 100644 index 0000000000..9885296749 --- /dev/null +++ b/docs/examples/guide/d93d52b6057a7aff3d0766ca44c505e0.asciidoc @@ -0,0 +1,34 @@ +[source, ruby] +---- +response = client.cluster.put_component_template( + name: 'my-aliases', + body: { + template: { + aliases: { + "my-alias": {} + } + } + } +) +puts response + +response = client.indices.put_index_template( + name: 'my-index-template', + body: { + index_patterns: [ + 'my-index-*' + ], + composed_of: [ + 'my-aliases', + 'my-mappings', + 'my-settings' + ], + template: { + aliases: { + "yet-another-alias": {} + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/d952ac7c73219d8cabc080679e035514.asciidoc b/docs/examples/guide/d952ac7c73219d8cabc080679e035514.asciidoc new file mode 100644 index 0000000000..adcc2c5c5f --- /dev/null +++ b/docs/examples/guide/d952ac7c73219d8cabc080679e035514.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + knn: { + field: 'my_embeddings.predicted_value', + k: 10, + num_candidates: 100, + query_vector_builder: { + text_embedding: { + model_id: 'sentence-transformers__msmarco-minilm-l-12-v3', + model_text: 'the query string' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/d979f934af0992fb8c8596beff80b638.asciidoc b/docs/examples/guide/d979f934af0992fb8c8596beff80b638.asciidoc index e55d8f876e..40a467c6f4 100644 --- a/docs/examples/guide/d979f934af0992fb8c8596beff80b638.asciidoc +++ b/docs/examples/guide/d979f934af0992fb8c8596beff80b638.asciidoc @@ -8,7 +8,7 @@ response = client.search( ], query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/d9fd6c552e904261fd52884595e28eff.asciidoc b/docs/examples/guide/d9fd6c552e904261fd52884595e28eff.asciidoc deleted file mode 100644 index 7a95aefe96..0000000000 --- a/docs/examples/guide/d9fd6c552e904261fd52884595e28eff.asciidoc +++ /dev/null @@ -1,26 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'test_index', - body: { - settings: { - index: { - analysis: { - filter: { - synonym: { - type: 'synonym_graph', - format: 'wordnet', - synonyms: [ - "s(100000001,1,'abstain',v,1,0).", - "s(100000001,2,'refrain',v,1,0).", - "s(100000001,3,'desist',v,1,0)." - ] - } - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/da3cecc36a7313385d32c7f52ccfb7e3.asciidoc b/docs/examples/guide/da3cecc36a7313385d32c7f52ccfb7e3.asciidoc index b109d0c582..e60211e765 100644 --- a/docs/examples/guide/da3cecc36a7313385d32c7f52ccfb7e3.asciidoc +++ b/docs/examples/guide/da3cecc36a7313385d32c7f52ccfb7e3.asciidoc @@ -5,7 +5,7 @@ response = client.search( size: 0, body: { runtime_mappings: { - "date.day_of_week": { + 'date.day_of_week' => { type: 'keyword', script: "emit(doc['date'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))" } diff --git a/docs/examples/guide/daae2e6acebc84e537764f4ba07f2e6e.asciidoc b/docs/examples/guide/daae2e6acebc84e537764f4ba07f2e6e.asciidoc index b543b2e8fa..24b505387e 100644 --- a/docs/examples/guide/daae2e6acebc84e537764f4ba07f2e6e.asciidoc +++ b/docs/examples/guide/daae2e6acebc84e537764f4ba07f2e6e.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.exclude._name": nil + 'cluster.routing.allocation.exclude._name' => nil } } ) diff --git a/docs/examples/guide/dad2d4add751fde5c39475ca709cc14b.asciidoc b/docs/examples/guide/dad2d4add751fde5c39475ca709cc14b.asciidoc index d737e103ad..334da4cdc6 100644 --- a/docs/examples/guide/dad2d4add751fde5c39475ca709cc14b.asciidoc +++ b/docs/examples/guide/dad2d4add751fde5c39475ca709cc14b.asciidoc @@ -3,7 +3,7 @@ response = client.indices.put_settings( index: 'test', body: { - "index.routing.allocation.include.size": 'big,medium' + 'index.routing.allocation.include.size' => 'big,medium' } ) puts response diff --git a/docs/examples/guide/dadb69a225778ecd6528924c0aa029bb.asciidoc b/docs/examples/guide/dadb69a225778ecd6528924c0aa029bb.asciidoc new file mode 100644 index 0000000000..de223a33ef --- /dev/null +++ b/docs/examples/guide/dadb69a225778ecd6528924c0aa029bb.asciidoc @@ -0,0 +1,29 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'image-index', + body: { + mappings: { + properties: { + "image-vector": { + type: 'dense_vector', + dims: 3, + similarity: 'l2_norm' + }, + "title-vector": { + type: 'dense_vector', + dims: 5, + similarity: 'l2_norm' + }, + title: { + type: 'text' + }, + "file-type": { + type: 'keyword' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/dbf93d02ab86a09929a21232b19709cc.asciidoc b/docs/examples/guide/dbf93d02ab86a09929a21232b19709cc.asciidoc new file mode 100644 index 0000000000..6b1ec1c2cb --- /dev/null +++ b/docs/examples/guide/dbf93d02ab86a09929a21232b19709cc.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.ml.stop_trained_model_deployment( + model_id: 'my_model_for_search' +) +puts response +---- diff --git a/docs/examples/guide/dc3b7603e7d688106acb804059af7834.asciidoc b/docs/examples/guide/dc3b7603e7d688106acb804059af7834.asciidoc index e661864ba6..4dd54b03c4 100644 --- a/docs/examples/guide/dc3b7603e7d688106acb804059af7834.asciidoc +++ b/docs/examples/guide/dc3b7603e7d688106acb804059af7834.asciidoc @@ -5,7 +5,7 @@ response = client.search( _source: false, query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/dd360e1cf42ad897e2ab9e785a45466f.asciidoc b/docs/examples/guide/dd360e1cf42ad897e2ab9e785a45466f.asciidoc deleted file mode 100644 index 506a2c936a..0000000000 --- a/docs/examples/guide/dd360e1cf42ad897e2ab9e785a45466f.asciidoc +++ /dev/null @@ -1,30 +0,0 @@ -[source, ruby] ----- -response = client.indices.put_index_template( - name: 'my-weather-sensor-index-template', - body: { - index_patterns: [ - 'metrics-weather_sensors-*' - ], - data_stream: {}, - template: { - settings: { - "index.mode": 'time_series', - "index.routing_path": [ - 'sensor_id', - 'location' - ] - } - }, - composed_of: [ - 'my-weather-sensor-mappings', - 'my-weather-sensor-settings' - ], - priority: 500, - _meta: { - description: 'Template for my weather sensor data' - } - } -) -puts response ----- diff --git a/docs/examples/guide/de139866a220124360e5e27d1a736ea4.asciidoc b/docs/examples/guide/de139866a220124360e5e27d1a736ea4.asciidoc index 2f51e4ec7b..20620e085a 100644 --- a/docs/examples/guide/de139866a220124360e5e27d1a736ea4.asciidoc +++ b/docs/examples/guide/de139866a220124360e5e27d1a736ea4.asciidoc @@ -9,14 +9,14 @@ response = client.search( }, sort: [ { - "offer.price": { + 'offer.price' => { mode: 'avg', order: 'asc', nested: { path: 'offer', filter: { term: { - "offer.color": 'blue' + 'offer.color' => 'blue' } } } diff --git a/docs/examples/guide/de876505acc75d371d1f6f484c449197.asciidoc b/docs/examples/guide/de876505acc75d371d1f6f484c449197.asciidoc index f903a15c84..3556e3f30a 100644 --- a/docs/examples/guide/de876505acc75d371d1f6f484c449197.asciidoc +++ b/docs/examples/guide/de876505acc75d371d1f6f484c449197.asciidoc @@ -4,7 +4,7 @@ response = client.indices.create( index: 'test', body: { settings: { - "index.write.wait_for_active_shards": '2' + 'index.write.wait_for_active_shards' => '2' } } ) diff --git a/docs/examples/guide/dea4ac54c63a10c62eccd7b7f6543b86.asciidoc b/docs/examples/guide/dea4ac54c63a10c62eccd7b7f6543b86.asciidoc new file mode 100644 index 0000000000..f2e1dfb22a --- /dev/null +++ b/docs/examples/guide/dea4ac54c63a10c62eccd7b7f6543b86.asciidoc @@ -0,0 +1,23 @@ +[source, ruby] +---- +response = client.index( + index: 'place', + id: 1, + body: { + suggest: { + input: [ + "timmy's", + 'starbucks', + 'dunkin donuts' + ], + contexts: { + place_type: [ + 'cafe', + 'food' + ] + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/dead0682932ea6ec33c1197017bcb209.asciidoc b/docs/examples/guide/dead0682932ea6ec33c1197017bcb209.asciidoc index 6531303512..7a005bd91f 100644 --- a/docs/examples/guide/dead0682932ea6ec33c1197017bcb209.asciidoc +++ b/docs/examples/guide/dead0682932ea6ec33c1197017bcb209.asciidoc @@ -10,7 +10,7 @@ response = client.search( }, filter: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { top_left: 'dr5r9ydj2y73', bottom_right: 'drj7teegpus6' } diff --git a/docs/examples/guide/df1336e768fb6fc1826a5afa30a57285.asciidoc b/docs/examples/guide/df1336e768fb6fc1826a5afa30a57285.asciidoc new file mode 100644 index 0000000000..35589a0a25 --- /dev/null +++ b/docs/examples/guide/df1336e768fb6fc1826a5afa30a57285.asciidoc @@ -0,0 +1,14 @@ +[source, ruby] +---- +response = client.index( + index: 'my-data-stream', + body: { + "@timestamp": '2099-03-08T11:06:07.000Z', + user: { + id: '8a4f500d' + }, + message: 'Login successful' + } +) +puts response +---- diff --git a/docs/examples/guide/df34c8ebaaa59a3ee0e3f28e2443bc30.asciidoc b/docs/examples/guide/df34c8ebaaa59a3ee0e3f28e2443bc30.asciidoc index 07ba02d610..d6d23c72a5 100644 --- a/docs/examples/guide/df34c8ebaaa59a3ee0e3f28e2443bc30.asciidoc +++ b/docs/examples/guide/df34c8ebaaa59a3ee0e3f28e2443bc30.asciidoc @@ -70,7 +70,7 @@ response = client.search( must_not: [ { term: { - "comments.author": 'nik9000' + 'comments.author' => 'nik9000' } } ] diff --git a/docs/examples/guide/df8271648f547673007ecd778341bfc9.asciidoc b/docs/examples/guide/df8271648f547673007ecd778341bfc9.asciidoc new file mode 100644 index 0000000000..430bbd5b72 --- /dev/null +++ b/docs/examples/guide/df8271648f547673007ecd778341bfc9.asciidoc @@ -0,0 +1,53 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'mv', + body: { + mappings: { + properties: { + b: { + type: 'keyword' + } + } + } + } +) +puts response + +response = client.bulk( + index: 'mv', + refresh: true, + body: [ + { + index: {} + }, + { + a: 1, + b: [ + 'foo', + 'foo', + 'bar' + ] + }, + { + index: {} + }, + { + a: 2, + b: [ + 'bar', + 'bar' + ] + } + ] +) +puts response + +response = client.esql.query( + body: { + query: 'FROM mv | LIMIT 2', + version: '2024.04.01' + } +) +puts response +---- diff --git a/docs/examples/guide/dfb20907cfc5ac520ea3b1dba5f00811.asciidoc b/docs/examples/guide/dfb20907cfc5ac520ea3b1dba5f00811.asciidoc index 398466cb62..8f789c07f9 100644 --- a/docs/examples/guide/dfb20907cfc5ac520ea3b1dba5f00811.asciidoc +++ b/docs/examples/guide/dfb20907cfc5ac520ea3b1dba5f00811.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { sort: [ { - "result.execution_time": 'desc' + 'result.execution_time' => 'desc' } ] } diff --git a/docs/examples/guide/dfdf82b8d99436582f150117695190b3.asciidoc b/docs/examples/guide/dfdf82b8d99436582f150117695190b3.asciidoc new file mode 100644 index 0000000000..d22bd4f8f9 --- /dev/null +++ b/docs/examples/guide/dfdf82b8d99436582f150117695190b3.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.index( + index: 'child_example', + id: 1, + body: { + join: { + name: 'question' + }, + body: 'I have Windows 2003 server and i bought a new Windows 2008 server...', + title: 'Whats the best way to file transfer my site from server to a newer one?', + tags: [ + 'windows-server-2003', + 'windows-server-2008', + 'file-transfer' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/e04c55476de6e785a066d3b43f66d20d.asciidoc b/docs/examples/guide/e04c55476de6e785a066d3b43f66d20d.asciidoc new file mode 100644 index 0000000000..bb2bfef424 --- /dev/null +++ b/docs/examples/guide/e04c55476de6e785a066d3b43f66d20d.asciidoc @@ -0,0 +1,31 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + query: { + bool: { + should: [ + { + text_expansion: { + content_embedding: { + model_text: 'How to avoid muscle soreness after running?', + model_id: '.elser_model_2', + boost: 1 + } + } + }, + { + query_string: { + query: 'toxins', + boost: 4 + } + } + ] + } + }, + min_score: 10 + } +) +puts response +---- diff --git a/docs/examples/guide/e12f2d2ddca387630e7855a6db952da2.asciidoc b/docs/examples/guide/e12f2d2ddca387630e7855a6db952da2.asciidoc index 8b5749d783..2147370c2b 100644 --- a/docs/examples/guide/e12f2d2ddca387630e7855a6db952da2.asciidoc +++ b/docs/examples/guide/e12f2d2ddca387630e7855a6db952da2.asciidoc @@ -4,7 +4,7 @@ response = client.search( index: 'sales', body: { runtime_mappings: { - "price.euros": { + 'price.euros' => { type: 'double', script: { source: "\n emit(doc['price'].value * params.conversion_rate)\n ", diff --git a/docs/examples/guide/e20037f66bf54bcac7d10f536f031f34.asciidoc b/docs/examples/guide/e20037f66bf54bcac7d10f536f031f34.asciidoc index 5d1dbb4af0..b811337269 100644 --- a/docs/examples/guide/e20037f66bf54bcac7d10f536f031f34.asciidoc +++ b/docs/examples/guide/e20037f66bf54bcac7d10f536f031f34.asciidoc @@ -3,7 +3,7 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { - "index.blocks.read_only_allow_delete": nil + 'index.blocks.read_only_allow_delete' => nil } ) puts response diff --git a/docs/examples/guide/e26c96978096ccc592849cca9db67ffc.asciidoc b/docs/examples/guide/e26c96978096ccc592849cca9db67ffc.asciidoc index b4834f26cd..4e09f775fd 100644 --- a/docs/examples/guide/e26c96978096ccc592849cca9db67ffc.asciidoc +++ b/docs/examples/guide/e26c96978096ccc592849cca9db67ffc.asciidoc @@ -3,7 +3,7 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { - "index.requests.cache.enable": true + 'index.requests.cache.enable' => true } ) puts response diff --git a/docs/examples/guide/e26e8bfa68aa4ab265b22304c38c3aef.asciidoc b/docs/examples/guide/e26e8bfa68aa4ab265b22304c38c3aef.asciidoc new file mode 100644 index 0000000000..50f5d6690c --- /dev/null +++ b/docs/examples/guide/e26e8bfa68aa4ab265b22304c38c3aef.asciidoc @@ -0,0 +1,89 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'sample_data', + body: { + mappings: { + properties: { + client_ip: { + type: 'ip' + }, + message: { + type: 'keyword' + } + } + } + } +) +puts response + +response = client.bulk( + index: 'sample_data', + body: [ + { + index: {} + }, + { + "@timestamp": '2023-10-23T12:15:03.360Z', + client_ip: '172.21.2.162', + message: 'Connected to 10.1.0.3', + event_duration: 3_450_233 + }, + { + index: {} + }, + { + "@timestamp": '2023-10-23T12:27:28.948Z', + client_ip: '172.21.2.113', + message: 'Connected to 10.1.0.2', + event_duration: 2_764_889 + }, + { + index: {} + }, + { + "@timestamp": '2023-10-23T13:33:34.937Z', + client_ip: '172.21.0.5', + message: 'Disconnected', + event_duration: 1_232_382 + }, + { + index: {} + }, + { + "@timestamp": '2023-10-23T13:51:54.732Z', + client_ip: '172.21.3.15', + message: 'Connection error', + event_duration: 725_448 + }, + { + index: {} + }, + { + "@timestamp": '2023-10-23T13:52:55.015Z', + client_ip: '172.21.3.15', + message: 'Connection error', + event_duration: 8_268_153 + }, + { + index: {} + }, + { + "@timestamp": '2023-10-23T13:53:55.832Z', + client_ip: '172.21.3.15', + message: 'Connection error', + event_duration: 5_033_755 + }, + { + index: {} + }, + { + "@timestamp": '2023-10-23T13:55:01.543Z', + client_ip: '172.21.3.15', + message: 'Connected to 10.1.0.1', + event_duration: 1_756_467 + } + ] +) +puts response +---- diff --git a/docs/examples/guide/e2a753029b450942a3228e3003a55a7d.asciidoc b/docs/examples/guide/e2a753029b450942a3228e3003a55a7d.asciidoc new file mode 100644 index 0000000000..7591a7ad90 --- /dev/null +++ b/docs/examples/guide/e2a753029b450942a3228e3003a55a7d.asciidoc @@ -0,0 +1,19 @@ +[source, ruby] +---- +response = client.indices.put_data_lifecycle( + name: 'my-weather-sensor-data-stream', + body: { + downsampling: [ + { + after: '1d', + fixed_interval: '10m' + }, + { + after: '7d', + fixed_interval: '1d' + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/e2b4867a9f72bda87ebaa3608d3fba4c.asciidoc b/docs/examples/guide/e2b4867a9f72bda87ebaa3608d3fba4c.asciidoc index d7e2a305e8..f384a25852 100644 --- a/docs/examples/guide/e2b4867a9f72bda87ebaa3608d3fba4c.asciidoc +++ b/docs/examples/guide/e2b4867a9f72bda87ebaa3608d3fba4c.asciidoc @@ -5,7 +5,7 @@ response = client.render_search_template( source: { query: { range: { - "user.effective.date": { + 'user.effective.date' => { gte: '{{date.min}}', lte: '{{date.max}}', format: "{{#join delimiter='||'}}date.formats{{/join delimiter='||'}}" diff --git a/docs/examples/guide/e2bcc8f4ed2b4de82729e7a5a7c8f634.asciidoc b/docs/examples/guide/e2bcc8f4ed2b4de82729e7a5a7c8f634.asciidoc new file mode 100644 index 0000000000..b7ffe68064 --- /dev/null +++ b/docs/examples/guide/e2bcc8f4ed2b4de82729e7a5a7c8f634.asciidoc @@ -0,0 +1,5 @@ +[source, ruby] +---- +response = client.synonyms.get_synonyms_sets +puts response +---- diff --git a/docs/examples/guide/e317a8380dfbc76c4e7f23d0997b3518.asciidoc b/docs/examples/guide/e317a8380dfbc76c4e7f23d0997b3518.asciidoc index e341b0699f..36a1537d7e 100644 --- a/docs/examples/guide/e317a8380dfbc76c4e7f23d0997b3518.asciidoc +++ b/docs/examples/guide/e317a8380dfbc76c4e7f23d0997b3518.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "action.destructive_requires_name": nil + 'action.destructive_requires_name' => nil } } ) diff --git a/docs/examples/guide/e324ea1547635180c31c1adf77870ba2.asciidoc b/docs/examples/guide/e324ea1547635180c31c1adf77870ba2.asciidoc new file mode 100644 index 0000000000..106e1b5a74 --- /dev/null +++ b/docs/examples/guide/e324ea1547635180c31c1adf77870ba2.asciidoc @@ -0,0 +1,42 @@ +[source, ruby] +---- +response = client.cluster.put_component_template( + name: 'destination_template', + body: { + template: { + settings: { + index: { + number_of_replicas: 2, + number_of_shards: 2, + mode: 'time_series', + routing_path: [ + 'metricset' + ] + } + }, + mappings: { + properties: { + "@timestamp": { + type: 'date' + }, + metricset: { + type: 'keyword', + time_series_dimension: true + }, + "k8s": { + properties: { + tx: { + type: 'long' + }, + rx: { + type: 'long' + } + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/e3b3a8ae12ab947ad3ba96eb228402ca.asciidoc b/docs/examples/guide/e3b3a8ae12ab947ad3ba96eb228402ca.asciidoc index 318a0c17b4..269fc6f98d 100644 --- a/docs/examples/guide/e3b3a8ae12ab947ad3ba96eb228402ca.asciidoc +++ b/docs/examples/guide/e3b3a8ae12ab947ad3ba96eb228402ca.asciidoc @@ -4,7 +4,7 @@ response = client.indices.create( index: 'my-index-000001', body: { settings: { - "index.store.preload": [ + 'index.store.preload' => [ 'nvd', 'dvd' ] diff --git a/docs/examples/guide/e3f2f6ee3e312b8a90634827ae954d70.asciidoc b/docs/examples/guide/e3f2f6ee3e312b8a90634827ae954d70.asciidoc new file mode 100644 index 0000000000..5433a1f0cb --- /dev/null +++ b/docs/examples/guide/e3f2f6ee3e312b8a90634827ae954d70.asciidoc @@ -0,0 +1,34 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'GeometryCollection', + geometries: [ + { + type: 'Point', + coordinates: [ + 100, + 0 + ] + }, + { + type: 'LineString', + coordinates: [ + [ + 101, + 0 + ], + [ + 102, + 1 + ] + ] + } + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/e46c83db1580e14be844079cd008f518.asciidoc b/docs/examples/guide/e46c83db1580e14be844079cd008f518.asciidoc index 05ba05553d..363ef500ed 100644 --- a/docs/examples/guide/e46c83db1580e14be844079cd008f518.asciidoc +++ b/docs/examples/guide/e46c83db1580e14be844079cd008f518.asciidoc @@ -4,7 +4,7 @@ response = client.indices.put_settings( index: 'my-index-000001', body: { index: { - "routing.allocation.enable": 'all' + 'routing.allocation.enable' => 'all' } } ) diff --git a/docs/examples/guide/e4d1f01c025fb797a1d87f372760eabf.asciidoc b/docs/examples/guide/e4d1f01c025fb797a1d87f372760eabf.asciidoc new file mode 100644 index 0000000000..143ab2ffcc --- /dev/null +++ b/docs/examples/guide/e4d1f01c025fb797a1d87f372760eabf.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.tasks.list( + human: true, + detailed: true +) +puts response +---- diff --git a/docs/examples/guide/e4de6035653e8202c43631f02d244661.asciidoc b/docs/examples/guide/e4de6035653e8202c43631f02d244661.asciidoc new file mode 100644 index 0000000000..1b553355f5 --- /dev/null +++ b/docs/examples/guide/e4de6035653e8202c43631f02d244661.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.search( + index: 'cluster_one:my-index-000001', + body: { + size: 1, + query: { + match: { + 'user.id' => 'kimchy' + } + }, + _source: [ + 'user.id', + 'message', + 'http.response.status_code' + ] + } +) +puts response +---- diff --git a/docs/examples/guide/e551ea38a2d8f8deac110b33304200cc.asciidoc b/docs/examples/guide/e551ea38a2d8f8deac110b33304200cc.asciidoc new file mode 100644 index 0000000000..33b81209a1 --- /dev/null +++ b/docs/examples/guide/e551ea38a2d8f8deac110b33304200cc.asciidoc @@ -0,0 +1,27 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + query: { + multi_match: { + fields: [ + 'title', + 'content' + ], + query: 'the quick brown fox' + } + }, + rescore: { + learning_to_rank: { + model_id: 'ltr-model', + params: { + query_text: 'the quick brown fox' + } + }, + window_size: 100 + } + } +) +puts response +---- diff --git a/docs/examples/guide/e58833449d01379df20ad06dc28144d8.asciidoc b/docs/examples/guide/e58833449d01379df20ad06dc28144d8.asciidoc index 014470ce4e..54247101db 100644 --- a/docs/examples/guide/e58833449d01379df20ad06dc28144d8.asciidoc +++ b/docs/examples/guide/e58833449d01379df20ad06dc28144d8.asciidoc @@ -6,7 +6,7 @@ response = client.update_by_query( body: { query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/e5901f48eb8a419b878fc2cb815d8691.asciidoc b/docs/examples/guide/e5901f48eb8a419b878fc2cb815d8691.asciidoc index a06dc93c02..f0edf74839 100644 --- a/docs/examples/guide/e5901f48eb8a419b878fc2cb815d8691.asciidoc +++ b/docs/examples/guide/e5901f48eb8a419b878fc2cb815d8691.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "indices.recovery.max_bytes_per_sec": '50mb' + 'indices.recovery.max_bytes_per_sec' => '50mb' } } ) diff --git a/docs/examples/guide/e5f8f83df37ab2296dc4bfed95d7aba7.asciidoc b/docs/examples/guide/e5f8f83df37ab2296dc4bfed95d7aba7.asciidoc index 0680ade6eb..a152187d74 100644 --- a/docs/examples/guide/e5f8f83df37ab2296dc4bfed95d7aba7.asciidoc +++ b/docs/examples/guide/e5f8f83df37ab2296dc4bfed95d7aba7.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.enable": 'all' + 'cluster.routing.allocation.enable' => 'all' } } ) diff --git a/docs/examples/guide/e608cd0c034f6c245ea87f425e09ce2f.asciidoc b/docs/examples/guide/e608cd0c034f6c245ea87f425e09ce2f.asciidoc index 0ed07fc4fd..3a0410df15 100644 --- a/docs/examples/guide/e608cd0c034f6c245ea87f425e09ce2f.asciidoc +++ b/docs/examples/guide/e608cd0c034f6c245ea87f425e09ce2f.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { span_term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/e6369e7cef82d881af593d5526bf79bd.asciidoc b/docs/examples/guide/e6369e7cef82d881af593d5526bf79bd.asciidoc index d36b6d2cd9..e4b2122a1c 100644 --- a/docs/examples/guide/e6369e7cef82d881af593d5526bf79bd.asciidoc +++ b/docs/examples/guide/e6369e7cef82d881af593d5526bf79bd.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { span_term: { - "user.id": { + 'user.id' => { value: 'kimchy', boost: 2 } diff --git a/docs/examples/guide/e642be44a62a89cf4afb2db28220c9a9.asciidoc b/docs/examples/guide/e642be44a62a89cf4afb2db28220c9a9.asciidoc index 0165a3d888..33cd07e9f1 100644 --- a/docs/examples/guide/e642be44a62a89cf4afb2db28220c9a9.asciidoc +++ b/docs/examples/guide/e642be44a62a89cf4afb2db28220c9a9.asciidoc @@ -3,8 +3,8 @@ response = client.cluster.put_settings( body: { persistent: { - "ingest.geoip.downloader.enabled": true, - "indices.lifecycle.history_index_enabled": true + 'ingest.geoip.downloader.enabled' => true, + 'indices.lifecycle.history_index_enabled' => true } } ) diff --git a/docs/examples/guide/e84e23232c7ecc8d6377ec2c16a60269.asciidoc b/docs/examples/guide/e84e23232c7ecc8d6377ec2c16a60269.asciidoc index b9822ec31a..d39c1ff733 100644 --- a/docs/examples/guide/e84e23232c7ecc8d6377ec2c16a60269.asciidoc +++ b/docs/examples/guide/e84e23232c7ecc8d6377ec2c16a60269.asciidoc @@ -8,7 +8,7 @@ response = client.indices.create( "alias_2": { filter: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, routing: 'shard-1' diff --git a/docs/examples/guide/e88a057a13e191e4d5faa22edf2ae8ed.asciidoc b/docs/examples/guide/e88a057a13e191e4d5faa22edf2ae8ed.asciidoc new file mode 100644 index 0000000000..131a7fe7c7 --- /dev/null +++ b/docs/examples/guide/e88a057a13e191e4d5faa22edf2ae8ed.asciidoc @@ -0,0 +1,8 @@ +[source, ruby] +---- +response = client.cluster.get_settings( + filter_path: '**.xpack.profiling.templates.enabled', + include_defaults: true +) +puts response +---- diff --git a/docs/examples/guide/e930a572e8ddfdecc13498c04007b9e3.asciidoc b/docs/examples/guide/e930a572e8ddfdecc13498c04007b9e3.asciidoc new file mode 100644 index 0000000000..74197fa382 --- /dev/null +++ b/docs/examples/guide/e930a572e8ddfdecc13498c04007b9e3.asciidoc @@ -0,0 +1,22 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'openai-embeddings', + body: { + mappings: { + properties: { + content_embedding: { + type: 'dense_vector', + dims: 1536, + element_type: 'float', + similarity: 'dot_product' + }, + content: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/e93ff228ab3e63738e1c83fdfb7424b9.asciidoc b/docs/examples/guide/e93ff228ab3e63738e1c83fdfb7424b9.asciidoc index f2ffb37a61..f023deb367 100644 --- a/docs/examples/guide/e93ff228ab3e63738e1c83fdfb7424b9.asciidoc +++ b/docs/examples/guide/e93ff228ab3e63738e1c83fdfb7424b9.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { match: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, highlight: { diff --git a/docs/examples/guide/e95e61988dc3073a007f7b7445dd233b.asciidoc b/docs/examples/guide/e95e61988dc3073a007f7b7445dd233b.asciidoc new file mode 100644 index 0000000000..3e18e16ab3 --- /dev/null +++ b/docs/examples/guide/e95e61988dc3073a007f7b7445dd233b.asciidoc @@ -0,0 +1,23 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'dsl-data-stream-template', + body: { + index_patterns: [ + 'dsl-data-stream*' + ], + data_stream: {}, + priority: 500, + template: { + settings: { + 'index.lifecycle.name' => 'pre-dsl-ilm-policy', + 'index.lifecycle.prefer_ilm' => false + }, + lifecycle: { + data_retention: '7d' + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/e9a0b450af6219772631703d602c7092.asciidoc b/docs/examples/guide/e9a0b450af6219772631703d602c7092.asciidoc new file mode 100644 index 0000000000..9e7fde1465 --- /dev/null +++ b/docs/examples/guide/e9a0b450af6219772631703d602c7092.asciidoc @@ -0,0 +1,40 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + query: { + text_expansion: { + 'ml.tokens' => { + model_id: '.elser_model_2', + model_text: 'How is the weather in Jamaica?', + pruning_config: { + tokens_freq_ratio_threshold: 5, + tokens_weight_threshold: 0.4, + only_score_pruned_tokens: false + } + } + } + }, + rescore: { + window_size: 100, + query: { + rescore_query: { + text_expansion: { + 'ml.tokens' => { + model_id: '.elser_model_2', + model_text: 'How is the weather in Jamaica?', + pruning_config: { + tokens_freq_ratio_threshold: 5, + tokens_weight_threshold: 0.4, + only_score_pruned_tokens: true + } + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/e9f9e184499a793828233e536fac0487.asciidoc b/docs/examples/guide/e9f9e184499a793828233e536fac0487.asciidoc index 784bccba50..42f4734bc8 100644 --- a/docs/examples/guide/e9f9e184499a793828233e536fac0487.asciidoc +++ b/docs/examples/guide/e9f9e184499a793828233e536fac0487.asciidoc @@ -6,7 +6,7 @@ response = client.delete_by_query( body: { query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/e9fe3b53b5b6e1ff9566b5237c0fa513.asciidoc b/docs/examples/guide/e9fe3b53b5b6e1ff9566b5237c0fa513.asciidoc new file mode 100644 index 0000000000..f23e07bfc5 --- /dev/null +++ b/docs/examples/guide/e9fe3b53b5b6e1ff9566b5237c0fa513.asciidoc @@ -0,0 +1,43 @@ +[source, ruby] +---- +response = client.index( + index: 'child_example', + id: 2, + routing: 1, + body: { + join: { + name: 'answer', + parent: '1' + }, + owner: { + location: 'Norfolk, United Kingdom', + display_name: 'Sam', + id: 48 + }, + body: "Unfortunately you're pretty much limited to FTP...", + creation_date: '2009-05-04T13:45:37.030' + } +) +puts response + +response = client.index( + index: 'child_example', + id: 3, + routing: 1, + refresh: true, + body: { + join: { + name: 'answer', + parent: '1' + }, + owner: { + location: 'Norfolk, United Kingdom', + display_name: 'Troll', + id: 49 + }, + body: 'Use Linux...', + creation_date: '2009-05-05T13:45:37.030' + } +) +puts response +---- diff --git a/docs/examples/guide/ea020ea32d5cd35e577c61a120f92451.asciidoc b/docs/examples/guide/ea020ea32d5cd35e577c61a120f92451.asciidoc new file mode 100644 index 0000000000..0272c02798 --- /dev/null +++ b/docs/examples/guide/ea020ea32d5cd35e577c61a120f92451.asciidoc @@ -0,0 +1,32 @@ +[source, ruby] +---- +response = client.bulk( + index: 'my-data-stream', + body: [ + { + create: {} + }, + { + "@timestamp": '2099-05-06T16:21:15.000Z', + message: '192.0.2.42 - - [06/May/2099:16:21:15 +0000] "GET /images/bg.jpg HTTP/1.0" 200 24736' + }, + { + create: {} + }, + { + "@timestamp": '2099-05-06T16:25:42.000Z', + message: '192.0.2.255 - - [06/May/2099:16:25:42 +0000] "GET /favicon.ico HTTP/1.0" 200 3638' + } + ] +) +puts response + +response = client.index( + index: 'my-data-stream', + body: { + "@timestamp": '2099-05-06T16:21:15.000Z', + message: '192.0.2.42 - - [06/May/2099:16:21:15 +0000] "GET /images/bg.jpg HTTP/1.0" 200 24736' + } +) +puts response +---- diff --git a/docs/examples/guide/ea0a5762f297928ea79948250a3624ed.asciidoc b/docs/examples/guide/ea0a5762f297928ea79948250a3624ed.asciidoc new file mode 100644 index 0000000000..e3214cc744 --- /dev/null +++ b/docs/examples/guide/ea0a5762f297928ea79948250a3624ed.asciidoc @@ -0,0 +1,53 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'mv', + body: { + mappings: { + properties: { + b: { + type: 'long' + } + } + } + } +) +puts response + +response = client.bulk( + index: 'mv', + refresh: true, + body: [ + { + index: {} + }, + { + a: 1, + b: [ + 2, + 2, + 1 + ] + }, + { + index: {} + }, + { + a: 2, + b: [ + 1, + 1 + ] + } + ] +) +puts response + +response = client.esql.query( + body: { + query: 'FROM mv | LIMIT 2', + version: '2024.04.01' + } +) +puts response +---- diff --git a/docs/examples/guide/ea5b4d2d87fd4e040afad18903c44869.asciidoc b/docs/examples/guide/ea5b4d2d87fd4e040afad18903c44869.asciidoc index f2a7b0aa61..539183aca3 100644 --- a/docs/examples/guide/ea5b4d2d87fd4e040afad18903c44869.asciidoc +++ b/docs/examples/guide/ea5b4d2d87fd4e040afad18903c44869.asciidoc @@ -10,7 +10,7 @@ response = client.search( }, filter: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { top_left: { lat: 40.73, lon: -74.1 diff --git a/docs/examples/guide/eada8af6588584ac88f1e5b15f4a5c2a.asciidoc b/docs/examples/guide/eada8af6588584ac88f1e5b15f4a5c2a.asciidoc index 58225bddb1..4676c691d0 100644 --- a/docs/examples/guide/eada8af6588584ac88f1e5b15f4a5c2a.asciidoc +++ b/docs/examples/guide/eada8af6588584ac88f1e5b15f4a5c2a.asciidoc @@ -4,7 +4,7 @@ response = client.index( index: 'metrics_index', id: 1, body: { - "network.name": 'net-1', + 'network.name' => 'net-1', latency_histo: { values: [ 0.1, @@ -29,7 +29,7 @@ response = client.index( index: 'metrics_index', id: 2, body: { - "network.name": 'net-2', + 'network.name' => 'net-2', latency_histo: { values: [ 0.1, diff --git a/docs/examples/guide/eae8931d01b3b878dd0c45214121e662.asciidoc b/docs/examples/guide/eae8931d01b3b878dd0c45214121e662.asciidoc index 59b9d4be99..f4205e60b5 100644 --- a/docs/examples/guide/eae8931d01b3b878dd0c45214121e662.asciidoc +++ b/docs/examples/guide/eae8931d01b3b878dd0c45214121e662.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { top_left: 'dr', bottom_right: 'dr' } diff --git a/docs/examples/guide/eaf6a846ded090fd6ac48269ad2b328b.asciidoc b/docs/examples/guide/eaf6a846ded090fd6ac48269ad2b328b.asciidoc index 9d9c63282c..3ad6059478 100644 --- a/docs/examples/guide/eaf6a846ded090fd6ac48269ad2b328b.asciidoc +++ b/docs/examples/guide/eaf6a846ded090fd6ac48269ad2b328b.asciidoc @@ -4,8 +4,8 @@ response = client.indices.create( index: 'my-index-000001', body: { settings: { - "index.lifecycle.name": 'my_policy', - "index.lifecycle.rollover_alias": 'my_data' + 'index.lifecycle.name' => 'my_policy', + 'index.lifecycle.rollover_alias' => 'my_data' }, aliases: { my_data: { diff --git a/docs/examples/guide/ec8f176ebf436d5719bdeca4a9ea8220.asciidoc b/docs/examples/guide/ec8f176ebf436d5719bdeca4a9ea8220.asciidoc index 9667d8df43..5879a26fe4 100644 --- a/docs/examples/guide/ec8f176ebf436d5719bdeca4a9ea8220.asciidoc +++ b/docs/examples/guide/ec8f176ebf436d5719bdeca4a9ea8220.asciidoc @@ -4,7 +4,7 @@ response = client.search( index: 'products', body: { runtime_mappings: { - "genre.length": { + 'genre.length' => { type: 'long', script: "emit(doc['genre'].value.length())" } diff --git a/docs/examples/guide/ecfd0d94dd14ef05dfa861f22544b388.asciidoc b/docs/examples/guide/ecfd0d94dd14ef05dfa861f22544b388.asciidoc new file mode 100644 index 0000000000..cb49956e46 --- /dev/null +++ b/docs/examples/guide/ecfd0d94dd14ef05dfa861f22544b388.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.connector.update_error( + connector_id: 'my-connector', + body: { + error: 'Houston, we have a problem!' + } +) +puts response +---- diff --git a/docs/examples/guide/ed27843eff311f3011b679e97e6fda50.asciidoc b/docs/examples/guide/ed27843eff311f3011b679e97e6fda50.asciidoc index a8d4cfeed9..d6a5dfbef3 100644 --- a/docs/examples/guide/ed27843eff311f3011b679e97e6fda50.asciidoc +++ b/docs/examples/guide/ed27843eff311f3011b679e97e6fda50.asciidoc @@ -6,7 +6,7 @@ response = client.snapshot.restore( body: { indices: 'my-index,logs-my_app-default', index_settings: { - "index.number_of_replicas": 1 + 'index.number_of_replicas' => 1 } } ) diff --git a/docs/examples/guide/ed5c3b45e8de912faba44507d827eb93.asciidoc b/docs/examples/guide/ed5c3b45e8de912faba44507d827eb93.asciidoc index 7d011217ed..9e142c5eed 100644 --- a/docs/examples/guide/ed5c3b45e8de912faba44507d827eb93.asciidoc +++ b/docs/examples/guide/ed5c3b45e8de912faba44507d827eb93.asciidoc @@ -5,7 +5,7 @@ response = client.search( sort: [ { _geo_distance: { - "pin.location": 'POINT (-70 40)', + 'pin.location' => 'POINT (-70 40)', order: 'asc', unit: 'km' } diff --git a/docs/examples/guide/ed688d86eeaa4d7969acb0f574eb917f.asciidoc b/docs/examples/guide/ed688d86eeaa4d7969acb0f574eb917f.asciidoc index f94c422b2f..54461f57f8 100644 --- a/docs/examples/guide/ed688d86eeaa4d7969acb0f574eb917f.asciidoc +++ b/docs/examples/guide/ed688d86eeaa4d7969acb0f574eb917f.asciidoc @@ -7,7 +7,7 @@ response = client.index( body: { query: { term: { - "my_field.prefix": 'abc' + 'my_field.prefix' => 'abc' } } } diff --git a/docs/examples/guide/edae616e1244babf6032aecc6aaaf836.asciidoc b/docs/examples/guide/edae616e1244babf6032aecc6aaaf836.asciidoc index 9ce770113e..5deea04c70 100644 --- a/docs/examples/guide/edae616e1244babf6032aecc6aaaf836.asciidoc +++ b/docs/examples/guide/edae616e1244babf6032aecc6aaaf836.asciidoc @@ -5,7 +5,7 @@ response = client.search( sort: [ { _geo_distance: { - "pin.location": { + 'pin.location' => { lat: 40, lon: -70 }, diff --git a/docs/examples/guide/ee0fd67acc807f1bddf5e9807c06e7eb.asciidoc b/docs/examples/guide/ee0fd67acc807f1bddf5e9807c06e7eb.asciidoc new file mode 100644 index 0000000000..45cfc002e9 --- /dev/null +++ b/docs/examples/guide/ee0fd67acc807f1bddf5e9807c06e7eb.asciidoc @@ -0,0 +1,94 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + query: { + weighted_tokens: { + query_expansion_field: { + tokens: { + "2161": 0.4679, + "2621": 0.307, + "2782": 0.1299, + "2851": 0.1056, + "3088": 0.3041, + "3376": 0.1038, + "3467": 0.4873, + "3684": 0.8958, + "4380": 0.334, + "4542": 0.4636, + "4633": 2.2805, + "4785": 1.2628, + "4860": 1.0655, + "5133": 1.0709, + "7139": 1.0016, + "7224": 0.2486, + "7387": 0.0985, + "7394": 0.0542, + "8915": 0.369, + "9156": 2.8947, + "10505": 0.2771, + "11464": 0.3996, + "13525": 0.0088, + "14178": 0.8161, + "16893": 0.1376, + "17851": 1.5348, + "19939": 0.6012 + }, + pruning_config: { + tokens_freq_ratio_threshold: 5, + tokens_weight_threshold: 0.4, + only_score_pruned_tokens: false + } + } + } + }, + rescore: { + window_size: 100, + query: { + rescore_query: { + weighted_tokens: { + query_expansion_field: { + tokens: { + "2161": 0.4679, + "2621": 0.307, + "2782": 0.1299, + "2851": 0.1056, + "3088": 0.3041, + "3376": 0.1038, + "3467": 0.4873, + "3684": 0.8958, + "4380": 0.334, + "4542": 0.4636, + "4633": 2.2805, + "4785": 1.2628, + "4860": 1.0655, + "5133": 1.0709, + "7139": 1.0016, + "7224": 0.2486, + "7387": 0.0985, + "7394": 0.0542, + "8915": 0.369, + "9156": 2.8947, + "10505": 0.2771, + "11464": 0.3996, + "13525": 0.0088, + "14178": 0.8161, + "16893": 0.1376, + "17851": 1.5348, + "19939": 0.6012 + }, + pruning_config: { + tokens_freq_ratio_threshold: 5, + tokens_weight_threshold: 0.4, + only_score_pruned_tokens: true + } + } + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/eec051555c8050d017d3fe38ea59e3a0.asciidoc b/docs/examples/guide/eec051555c8050d017d3fe38ea59e3a0.asciidoc index 949429f35a..af7b7ab1fd 100644 --- a/docs/examples/guide/eec051555c8050d017d3fe38ea59e3a0.asciidoc +++ b/docs/examples/guide/eec051555c8050d017d3fe38ea59e3a0.asciidoc @@ -7,7 +7,7 @@ response = client.search( body: { query: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } } } diff --git a/docs/examples/guide/ef779b87b3b0fb6e6bae9c8875e3a1cf.asciidoc b/docs/examples/guide/ef779b87b3b0fb6e6bae9c8875e3a1cf.asciidoc index 0726354399..9772ac2d70 100644 --- a/docs/examples/guide/ef779b87b3b0fb6e6bae9c8875e3a1cf.asciidoc +++ b/docs/examples/guide/ef779b87b3b0fb6e6bae9c8875e3a1cf.asciidoc @@ -5,7 +5,7 @@ response = client.search( size: 0, body: { runtime_mappings: { - "date.promoted_is_tomorrow": { + 'date.promoted_is_tomorrow' => { type: 'date', script: "\n long date = doc['date'].value.toInstant().toEpochMilli();\n if (doc['promoted'].value) {\n date += 86400;\n }\n emit(date);\n " } diff --git a/docs/examples/guide/eff8ecaed1ed084909c64450fc363a20.asciidoc b/docs/examples/guide/eff8ecaed1ed084909c64450fc363a20.asciidoc index 2fa0dd9338..c94a451c56 100644 --- a/docs/examples/guide/eff8ecaed1ed084909c64450fc363a20.asciidoc +++ b/docs/examples/guide/eff8ecaed1ed084909c64450fc363a20.asciidoc @@ -3,7 +3,7 @@ response = client.cluster.put_settings( body: { transient: { - "indices.recovery.max_bytes_per_sec": nil + 'indices.recovery.max_bytes_per_sec' => nil } } ) diff --git a/docs/examples/guide/f01d9bbab5b4535b9e067cde3f64ddbf.asciidoc b/docs/examples/guide/f01d9bbab5b4535b9e067cde3f64ddbf.asciidoc deleted file mode 100644 index 7142a063e6..0000000000 --- a/docs/examples/guide/f01d9bbab5b4535b9e067cde3f64ddbf.asciidoc +++ /dev/null @@ -1,13 +0,0 @@ -[source, ruby] ----- -response = client.cluster.allocation_explain( - filter_path: 'index,node_allocation_decisions.node_name,node_allocation_decisions.deciders.*', - body: { - index: 'my-index', - shard: 0, - primary: false, - current_node: 'my-node' - } -) -puts response ----- diff --git a/docs/examples/guide/f0bfc8d7ab4eb94ea5fdf2e087d8cf5b.asciidoc b/docs/examples/guide/f0bfc8d7ab4eb94ea5fdf2e087d8cf5b.asciidoc index fb8f3858ae..8f6f3a714e 100644 --- a/docs/examples/guide/f0bfc8d7ab4eb94ea5fdf2e087d8cf5b.asciidoc +++ b/docs/examples/guide/f0bfc8d7ab4eb94ea5fdf2e087d8cf5b.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { size: 0, runtime_mappings: { - "load_time.seconds": { + 'load_time.seconds' => { type: 'long', script: { source: "emit(doc['load_time'].value / params.timeUnit)", diff --git a/docs/examples/guide/f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc b/docs/examples/guide/f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc new file mode 100644 index 0000000000..b86bb8e691 --- /dev/null +++ b/docs/examples/guide/f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc @@ -0,0 +1,20 @@ +[source, ruby] +---- +response = client.inference.inference( + task_type: 'rerank', + inference_id: 'cohere_rerank', + body: { + input: [ + 'luke', + 'like', + 'leia', + 'chewy', + 'r2d2', + 'star', + 'wars' + ], + query: 'star wars main character' + } +) +puts response +---- diff --git a/docs/examples/guide/f1dc6f69453867ffafe86e998dd464d9.asciidoc b/docs/examples/guide/f1dc6f69453867ffafe86e998dd464d9.asciidoc index 2327c2afcc..bee9cbda7a 100644 --- a/docs/examples/guide/f1dc6f69453867ffafe86e998dd464d9.asciidoc +++ b/docs/examples/guide/f1dc6f69453867ffafe86e998dd464d9.asciidoc @@ -5,7 +5,7 @@ response = client.search( body: { query: { term: { - "file_path.tree_reversed": { + 'file_path.tree_reversed' => { value: 'my_photo1.jpg' } } diff --git a/docs/examples/guide/f29b8edba5eabb0b05a4f74d9ae6a816.asciidoc b/docs/examples/guide/f29b8edba5eabb0b05a4f74d9ae6a816.asciidoc deleted file mode 100644 index 038a8e7611..0000000000 --- a/docs/examples/guide/f29b8edba5eabb0b05a4f74d9ae6a816.asciidoc +++ /dev/null @@ -1,19 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'my-index-2', - body: { - mappings: { - properties: { - my_vector: { - type: 'dense_vector', - dims: 3, - index: true, - similarity: 'dot_product' - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/f2a5f77f929cc7b893b80f4bd5b1a192.asciidoc b/docs/examples/guide/f2a5f77f929cc7b893b80f4bd5b1a192.asciidoc new file mode 100644 index 0000000000..a4b6902fbe --- /dev/null +++ b/docs/examples/guide/f2a5f77f929cc7b893b80f4bd5b1a192.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.get( + connector_id: 'my-connector' +) +puts response +---- diff --git a/docs/examples/guide/f2da3937e5f0718527e6eb73aa261b1f.asciidoc b/docs/examples/guide/f2da3937e5f0718527e6eb73aa261b1f.asciidoc new file mode 100644 index 0000000000..89faf9ab29 --- /dev/null +++ b/docs/examples/guide/f2da3937e5f0718527e6eb73aa261b1f.asciidoc @@ -0,0 +1,53 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'mv', + body: { + mappings: { + properties: { + b: { + type: 'long' + } + } + } + } +) +puts response + +response = client.bulk( + index: 'mv', + refresh: true, + body: [ + { + index: {} + }, + { + a: 1, + b: [ + 2, + 2, + 1 + ] + }, + { + index: {} + }, + { + a: 2, + b: [ + 1, + 1 + ] + } + ] +) +puts response + +response = client.esql.query( + body: { + query: 'FROM mv | EVAL b=TO_STRING(b) | LIMIT 2', + version: '2024.04.01' + } +) +puts response +---- diff --git a/docs/examples/guide/f2f1cae094855a45fd8f73478bec8e70.asciidoc b/docs/examples/guide/f2f1cae094855a45fd8f73478bec8e70.asciidoc index ade2dc038c..89a0e615a0 100644 --- a/docs/examples/guide/f2f1cae094855a45fd8f73478bec8e70.asciidoc +++ b/docs/examples/guide/f2f1cae094855a45fd8f73478bec8e70.asciidoc @@ -5,7 +5,7 @@ response = client.indices.split( target: 'my_target_index', body: { settings: { - "index.number_of_shards": 5 + 'index.number_of_shards' => 5 }, aliases: { my_search_indices: {} diff --git a/docs/examples/guide/f3594de7ef39ab09b0bb12c1e76bfe6b.asciidoc b/docs/examples/guide/f3594de7ef39ab09b0bb12c1e76bfe6b.asciidoc index 930f69aee4..48e2320a07 100644 --- a/docs/examples/guide/f3594de7ef39ab09b0bb12c1e76bfe6b.asciidoc +++ b/docs/examples/guide/f3594de7ef39ab09b0bb12c1e76bfe6b.asciidoc @@ -5,8 +5,8 @@ response = client.indices.shrink( target: 'my_target_index', body: { settings: { - "index.routing.allocation.require._name": nil, - "index.blocks.write": nil + 'index.routing.allocation.require._name' => nil, + 'index.blocks.write' => nil } } ) diff --git a/docs/examples/guide/f38262ef72f73816ec35fa4c9c85760d.asciidoc b/docs/examples/guide/f38262ef72f73816ec35fa4c9c85760d.asciidoc new file mode 100644 index 0000000000..c219238128 --- /dev/null +++ b/docs/examples/guide/f38262ef72f73816ec35fa4c9c85760d.asciidoc @@ -0,0 +1,45 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'idx', + body: { + mappings: { + _source: { + mode: 'synthetic' + }, + properties: { + my_range: { + type: 'long_range' + } + } + } + } +) +puts response + +response = client.index( + index: 'idx', + id: 1, + body: { + my_range: [ + { + gte: 200, + lte: 300 + }, + { + gte: 1, + lte: 100 + }, + { + gte: 200, + lte: 300 + }, + { + gte: 200, + lte: 500 + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/f495f9c99916a05e3b28166d31955fad.asciidoc b/docs/examples/guide/f495f9c99916a05e3b28166d31955fad.asciidoc index 0131bd7c19..5be84ab8b9 100644 --- a/docs/examples/guide/f495f9c99916a05e3b28166d31955fad.asciidoc +++ b/docs/examples/guide/f495f9c99916a05e3b28166d31955fad.asciidoc @@ -7,7 +7,7 @@ response = client.search( terms: { field: 'genre', order: { - "playback_stats.max": 'desc' + 'playback_stats.max' => 'desc' } }, aggregations: { diff --git a/docs/examples/guide/f49ac80f0130cae8d0ea6f4472a149dd.asciidoc b/docs/examples/guide/f49ac80f0130cae8d0ea6f4472a149dd.asciidoc new file mode 100644 index 0000000000..003a91cb15 --- /dev/null +++ b/docs/examples/guide/f49ac80f0130cae8d0ea6f4472a149dd.asciidoc @@ -0,0 +1,25 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-image-index', + body: { + mappings: { + properties: { + "image-vector": { + type: 'dense_vector', + dims: 3, + index: true, + similarity: 'l2_norm' + }, + "file-type": { + type: 'keyword' + }, + title: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/f4ae3f3fbf07a7d39122ac5ac20b9c03.asciidoc b/docs/examples/guide/f4ae3f3fbf07a7d39122ac5ac20b9c03.asciidoc new file mode 100644 index 0000000000..86ec87cc05 --- /dev/null +++ b/docs/examples/guide/f4ae3f3fbf07a7d39122ac5ac20b9c03.asciidoc @@ -0,0 +1,25 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'quantized-image-index', + body: { + mappings: { + properties: { + "image-vector": { + type: 'dense_vector', + element_type: 'float', + dims: 2, + index: true, + index_options: { + type: 'int8_hnsw' + } + }, + title: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/f4dc1286d0a2f8d1fde64fbf12fd9f8d.asciidoc b/docs/examples/guide/f4dc1286d0a2f8d1fde64fbf12fd9f8d.asciidoc index 19ce104e1d..60df29c193 100644 --- a/docs/examples/guide/f4dc1286d0a2f8d1fde64fbf12fd9f8d.asciidoc +++ b/docs/examples/guide/f4dc1286d0a2f8d1fde64fbf12fd9f8d.asciidoc @@ -3,14 +3,14 @@ response = client.cluster.put_settings( body: { persistent: { - "cluster.routing.allocation.disk.watermark.low": nil, - "cluster.routing.allocation.disk.watermark.low.max_headroom": nil, - "cluster.routing.allocation.disk.watermark.high": nil, - "cluster.routing.allocation.disk.watermark.high.max_headroom": nil, - "cluster.routing.allocation.disk.watermark.flood_stage": nil, - "cluster.routing.allocation.disk.watermark.flood_stage.max_headroom": nil, - "cluster.routing.allocation.disk.watermark.flood_stage.frozen": nil, - "cluster.routing.allocation.disk.watermark.flood_stage.frozen.max_headroom": nil + 'cluster.routing.allocation.disk.watermark.low' => nil, + 'cluster.routing.allocation.disk.watermark.low.max_headroom' => nil, + 'cluster.routing.allocation.disk.watermark.high' => nil, + 'cluster.routing.allocation.disk.watermark.high.max_headroom' => nil, + 'cluster.routing.allocation.disk.watermark.flood_stage' => nil, + 'cluster.routing.allocation.disk.watermark.flood_stage.max_headroom' => nil, + 'cluster.routing.allocation.disk.watermark.flood_stage.frozen' => nil, + 'cluster.routing.allocation.disk.watermark.flood_stage.frozen.max_headroom' => nil } } ) diff --git a/docs/examples/guide/f4e38856cd6a7531e8fa8df4abe0e1c4.asciidoc b/docs/examples/guide/f4e38856cd6a7531e8fa8df4abe0e1c4.asciidoc new file mode 100644 index 0000000000..89ee8479d4 --- /dev/null +++ b/docs/examples/guide/f4e38856cd6a7531e8fa8df4abe0e1c4.asciidoc @@ -0,0 +1,17 @@ +[source, ruby] +---- +response = client.search( + index: 'my-index', + body: { + query: { + text_expansion: { + content_embedding: { + model_id: '.elser_model_2', + model_text: 'How to avoid muscle soreness after running?' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/f55cfbfc93d25941fa1d28866e050902.asciidoc b/docs/examples/guide/f55cfbfc93d25941fa1d28866e050902.asciidoc deleted file mode 100644 index 8b639aa9ad..0000000000 --- a/docs/examples/guide/f55cfbfc93d25941fa1d28866e050902.asciidoc +++ /dev/null @@ -1,153 +0,0 @@ -[source, ruby] ----- -response = client.indices.create( - index: 'sample-01', - body: { - settings: { - index: { - mode: 'time_series', - time_series: { - start_time: '2022-06-10T00:00:00Z', - end_time: '2022-06-30T23:59:59Z' - }, - routing_path: [ - 'kubernetes.namespace', - 'kubernetes.host', - 'kubernetes.node', - 'kubernetes.pod' - ], - number_of_replicas: 0, - number_of_shards: 2 - } - }, - mappings: { - properties: { - "@timestamp": { - type: 'date' - }, - kubernetes: { - properties: { - container: { - properties: { - cpu: { - properties: { - usage: { - properties: { - core: { - properties: { - ns: { - type: 'long' - } - } - }, - limit: { - properties: { - pct: { - type: 'float' - } - } - }, - nanocores: { - type: 'long', - time_series_metric: 'gauge' - }, - node: { - properties: { - pct: { - type: 'float' - } - } - } - } - } - } - }, - memory: { - properties: { - available: { - properties: { - bytes: { - type: 'long', - time_series_metric: 'gauge' - } - } - }, - majorpagefaults: { - type: 'long' - }, - pagefaults: { - type: 'long', - time_series_metric: 'gauge' - }, - rss: { - properties: { - bytes: { - type: 'long', - time_series_metric: 'gauge' - } - } - }, - usage: { - properties: { - bytes: { - type: 'long', - time_series_metric: 'gauge' - }, - limit: { - properties: { - pct: { - type: 'float' - } - } - }, - node: { - properties: { - pct: { - type: 'float' - } - } - } - } - }, - workingset: { - properties: { - bytes: { - type: 'long', - time_series_metric: 'gauge' - } - } - } - } - }, - name: { - type: 'keyword' - }, - start_time: { - type: 'date' - } - } - }, - host: { - type: 'keyword', - time_series_dimension: true - }, - namespace: { - type: 'keyword', - time_series_dimension: true - }, - node: { - type: 'keyword', - time_series_dimension: true - }, - pod: { - type: 'keyword', - time_series_dimension: true - } - } - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/f58969ac405db85f439c5940d014964b.asciidoc b/docs/examples/guide/f58969ac405db85f439c5940d014964b.asciidoc index d7c2e9884c..ee94af29bf 100644 --- a/docs/examples/guide/f58969ac405db85f439c5940d014964b.asciidoc +++ b/docs/examples/guide/f58969ac405db85f439c5940d014964b.asciidoc @@ -10,7 +10,7 @@ response = client.search( }, filter: { geo_bounding_box: { - "pin.location": { + 'pin.location' => { wkt: 'BBOX (-74.1, -71.12, 40.73, 40.01)' } } diff --git a/docs/examples/guide/f589cb2b789b4a16ed78183f2349a735.asciidoc b/docs/examples/guide/f589cb2b789b4a16ed78183f2349a735.asciidoc deleted file mode 100644 index f6e259cf0f..0000000000 --- a/docs/examples/guide/f589cb2b789b4a16ed78183f2349a735.asciidoc +++ /dev/null @@ -1,68 +0,0 @@ -[source, ruby] ----- -response = client.index( - index: 'metrics_index', - id: 1, - body: { - "network.name": 'net-1', - latency_histo: { - values: [ - 1, - 3, - 8, - 12, - 15 - ], - counts: [ - 3, - 7, - 23, - 12, - 6 - ] - } - } -) -puts response - -response = client.index( - index: 'metrics_index', - id: 2, - body: { - "network.name": 'net-2', - latency_histo: { - values: [ - 1, - 6, - 8, - 12, - 14 - ], - counts: [ - 8, - 17, - 8, - 7, - 6 - ] - } - } -) -puts response - -response = client.search( - index: 'metrics_index', - size: 0, - body: { - aggregations: { - latency_buckets: { - histogram: { - field: 'latency_histo', - interval: 5 - } - } - } - } -) -puts response ----- diff --git a/docs/examples/guide/f5cbbb60ca26867a5d2da625a68a6e65.asciidoc b/docs/examples/guide/f5cbbb60ca26867a5d2da625a68a6e65.asciidoc index e47ed136d9..c236b7b5b2 100644 --- a/docs/examples/guide/f5cbbb60ca26867a5d2da625a68a6e65.asciidoc +++ b/docs/examples/guide/f5cbbb60ca26867a5d2da625a68a6e65.asciidoc @@ -5,7 +5,7 @@ response = client.indices.create( body: { mappings: { properties: { - "total_quantity.sum": { + 'total_quantity.sum' => { type: 'double' }, total_quantity: { @@ -14,16 +14,16 @@ response = client.indices.create( taxless_total_price: { type: 'object' }, - "taxless_total_price.sum": { + 'taxless_total_price.sum' => { type: 'double' }, - "order_id.cardinality": { + 'order_id.cardinality' => { type: 'long' }, customer_id: { type: 'keyword' }, - "total_quantity.max": { + 'total_quantity.max' => { type: 'integer' }, order_id: { diff --git a/docs/examples/guide/f5eed3f2e3558a238487bc85305b7a71.asciidoc b/docs/examples/guide/f5eed3f2e3558a238487bc85305b7a71.asciidoc new file mode 100644 index 0000000000..df847e9ade --- /dev/null +++ b/docs/examples/guide/f5eed3f2e3558a238487bc85305b7a71.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'POLYGON ((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0))' + } +) +puts response +---- diff --git a/docs/examples/guide/f785b5d17eb59f8d2a353c2dee66eb5b.asciidoc b/docs/examples/guide/f785b5d17eb59f8d2a353c2dee66eb5b.asciidoc new file mode 100644 index 0000000000..f2e52a81c5 --- /dev/null +++ b/docs/examples/guide/f785b5d17eb59f8d2a353c2dee66eb5b.asciidoc @@ -0,0 +1,7 @@ +[source, ruby] +---- +response = client.connector.sync_job_get( + connector_sync_job_id: 'my-connector-sync-job' +) +puts response +---- diff --git a/docs/examples/guide/f7d3d367a3d8e8ff0eca426b6ea85252.asciidoc b/docs/examples/guide/f7d3d367a3d8e8ff0eca426b6ea85252.asciidoc new file mode 100644 index 0000000000..7d2efe648b --- /dev/null +++ b/docs/examples/guide/f7d3d367a3d8e8ff0eca426b6ea85252.asciidoc @@ -0,0 +1,15 @@ +[source, ruby] +---- +response = client.reindex( + body: { + source: { + index: 'k8s' + }, + dest: { + index: 'k9s', + op_type: 'create' + } + } +) +puts response +---- diff --git a/docs/examples/guide/f8a0010753b1ff563dc42d703902d2fa.asciidoc b/docs/examples/guide/f8a0010753b1ff563dc42d703902d2fa.asciidoc index 1f7a47ac05..dbb596c2ea 100644 --- a/docs/examples/guide/f8a0010753b1ff563dc42d703902d2fa.asciidoc +++ b/docs/examples/guide/f8a0010753b1ff563dc42d703902d2fa.asciidoc @@ -6,7 +6,7 @@ response = client.search( bool: { must: { term: { - "user.id": 'kimchy' + 'user.id' => 'kimchy' } }, filter: { diff --git a/docs/examples/guide/f98687271e1bec031cc34d05d8f4b60b.asciidoc b/docs/examples/guide/f98687271e1bec031cc34d05d8f4b60b.asciidoc index 19583a02a5..1582fcda8a 100644 --- a/docs/examples/guide/f98687271e1bec031cc34d05d8f4b60b.asciidoc +++ b/docs/examples/guide/f98687271e1bec031cc34d05d8f4b60b.asciidoc @@ -6,7 +6,7 @@ response = client.search( span_multi: { match: { prefix: { - "user.id": { + 'user.id' => { value: 'ki' } } diff --git a/docs/examples/guide/f9a315ea99bed0cf2f36be1d74eb3e4a.asciidoc b/docs/examples/guide/f9a315ea99bed0cf2f36be1d74eb3e4a.asciidoc new file mode 100644 index 0000000000..27b502a47b --- /dev/null +++ b/docs/examples/guide/f9a315ea99bed0cf2f36be1d74eb3e4a.asciidoc @@ -0,0 +1,10 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: 'MULTIPOLYGON (((102.0 2.0, 103.0 2.0, 103.0 3.0, 102.0 3.0, 102.0 2.0)), ((100.0 0.0, 101.0 0.0, 101.0 1.0, 100.0 1.0, 100.0 0.0), (100.2 0.2, 100.8 0.2, 100.8 0.8, 100.2 0.8, 100.2 0.2)))' + } +) +puts response +---- diff --git a/docs/examples/guide/f9cb2547ab04461a12bfd25a35be5f96.asciidoc b/docs/examples/guide/f9cb2547ab04461a12bfd25a35be5f96.asciidoc new file mode 100644 index 0000000000..d4f57568c3 --- /dev/null +++ b/docs/examples/guide/f9cb2547ab04461a12bfd25a35be5f96.asciidoc @@ -0,0 +1,37 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'idx', + body: { + mappings: { + _source: { + mode: 'synthetic' + }, + properties: { + my_range: { + type: 'date_range' + } + } + } + } +) +puts response + +response = client.index( + index: 'idx', + id: 1, + body: { + my_range: [ + { + gte: 1_504_224_000_000, + lte: 1_504_569_600_000 + }, + { + gte: '2017-09-01', + lte: '2017-09-10' + } + ] + } +) +puts response +---- diff --git a/docs/examples/guide/fb3505d976283fb7c7b9705a761e0dc2.asciidoc b/docs/examples/guide/fb3505d976283fb7c7b9705a761e0dc2.asciidoc new file mode 100644 index 0000000000..b34a9e90c6 --- /dev/null +++ b/docs/examples/guide/fb3505d976283fb7c7b9705a761e0dc2.asciidoc @@ -0,0 +1,37 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'polygon', + orientation: 'clockwise', + coordinates: [ + [ + [ + 1000, + 1000 + ], + [ + 1000, + 1001 + ], + [ + 1001, + 1001 + ], + [ + 1001, + 1000 + ], + [ + 1000, + 1000 + ] + ] + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/fbb38243221c8fb311660616e3add9ce.asciidoc b/docs/examples/guide/fbb38243221c8fb311660616e3add9ce.asciidoc index 3c44141223..5aacb82f9b 100644 --- a/docs/examples/guide/fbb38243221c8fb311660616e3add9ce.asciidoc +++ b/docs/examples/guide/fbb38243221c8fb311660616e3add9ce.asciidoc @@ -5,7 +5,7 @@ response = client.search( sort: [ { _geo_distance: { - "pin.location": [ + 'pin.location' => [ -70, 40 ], diff --git a/docs/examples/guide/fbc5ab85b908480bf944b55da0a43488.asciidoc b/docs/examples/guide/fbc5ab85b908480bf944b55da0a43488.asciidoc index 40ba63b33a..82a6ad3ed4 100644 --- a/docs/examples/guide/fbc5ab85b908480bf944b55da0a43488.asciidoc +++ b/docs/examples/guide/fbc5ab85b908480bf944b55da0a43488.asciidoc @@ -4,7 +4,7 @@ response = client.search( body: { query: { prefix: { - "user.id": { + 'user.id' => { value: 'ki' } } diff --git a/docs/examples/guide/fbdad6620eb645f5f1f02e3673604d01.asciidoc b/docs/examples/guide/fbdad6620eb645f5f1f02e3673604d01.asciidoc index 0aa76aa993..0e93f5ecf9 100644 --- a/docs/examples/guide/fbdad6620eb645f5f1f02e3673604d01.asciidoc +++ b/docs/examples/guide/fbdad6620eb645f5f1f02e3673604d01.asciidoc @@ -11,7 +11,7 @@ response = client.search( filter: { geo_distance: { distance: '12km', - "pin.location": 'drm3btev3e86' + 'pin.location' => 'drm3btev3e86' } } } diff --git a/docs/examples/guide/fc1907515f6a913884a9f86451e90ee8.asciidoc b/docs/examples/guide/fc1907515f6a913884a9f86451e90ee8.asciidoc new file mode 100644 index 0000000000..2d3789baf4 --- /dev/null +++ b/docs/examples/guide/fc1907515f6a913884a9f86451e90ee8.asciidoc @@ -0,0 +1,24 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index', + body: { + mappings: { + _source: { + excludes: [ + 'content_embedding' + ] + }, + properties: { + content_embedding: { + type: 'sparse_vector' + }, + content: { + type: 'text' + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/fc51fbc60b0e20aac83300a43ad90252.asciidoc b/docs/examples/guide/fc51fbc60b0e20aac83300a43ad90252.asciidoc new file mode 100644 index 0000000000..d06eb139cc --- /dev/null +++ b/docs/examples/guide/fc51fbc60b0e20aac83300a43ad90252.asciidoc @@ -0,0 +1,34 @@ +[source, ruby] +---- +response = client.index( + index: 'example', + body: { + location: { + type: 'geometrycollection', + geometries: [ + { + type: 'point', + coordinates: [ + 1000, + 100 + ] + }, + { + type: 'linestring', + coordinates: [ + [ + 1001, + 100 + ], + [ + 1002, + 100 + ] + ] + } + ] + } + } +) +puts response +---- diff --git a/docs/examples/guide/fdada036a875d7995d5d7aba9c06361e.asciidoc b/docs/examples/guide/fdada036a875d7995d5d7aba9c06361e.asciidoc new file mode 100644 index 0000000000..254c14a466 --- /dev/null +++ b/docs/examples/guide/fdada036a875d7995d5d7aba9c06361e.asciidoc @@ -0,0 +1,18 @@ +[source, ruby] +---- +response = client.indices.create( + index: 'my-index-2', + body: { + mappings: { + properties: { + my_vector: { + type: 'dense_vector', + dims: 3, + index: false + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/fe208d94ec93eabf3bd06139fa70701e.asciidoc b/docs/examples/guide/fe208d94ec93eabf3bd06139fa70701e.asciidoc new file mode 100644 index 0000000000..b55fd5df6b --- /dev/null +++ b/docs/examples/guide/fe208d94ec93eabf3bd06139fa70701e.asciidoc @@ -0,0 +1,45 @@ +[source, ruby] +---- +response = client.indices.put_index_template( + name: 'sensor-template', + body: { + index_patterns: [ + 'sensor-*' + ], + data_stream: {}, + template: { + lifecycle: { + downsampling: [ + { + after: '1d', + fixed_interval: '1h' + } + ] + }, + settings: { + 'index.mode' => 'time_series' + }, + mappings: { + properties: { + node: { + type: 'keyword', + time_series_dimension: true + }, + temperature: { + type: 'half_float', + time_series_metric: 'gauge' + }, + voltage: { + type: 'half_float', + time_series_metric: 'gauge' + }, + "@timestamp": { + type: 'date' + } + } + } + } + } +) +puts response +---- diff --git a/docs/examples/guide/ff05842419968a2141bde0371ac2f6f4.asciidoc b/docs/examples/guide/ff05842419968a2141bde0371ac2f6f4.asciidoc index db282b0b7f..ab78aab9e4 100644 --- a/docs/examples/guide/ff05842419968a2141bde0371ac2f6f4.asciidoc +++ b/docs/examples/guide/ff05842419968a2141bde0371ac2f6f4.asciidoc @@ -5,7 +5,7 @@ response = client.render_search_template( source: { query: { match: { - "user.group.emails": '{{#join}}emails{{/join}}' + 'user.group.emails' => '{{#join}}emails{{/join}}' } } }, diff --git a/docs/getting-started.asciidoc b/docs/getting-started.asciidoc deleted file mode 100644 index a4500847b4..0000000000 --- a/docs/getting-started.asciidoc +++ /dev/null @@ -1,141 +0,0 @@ -[[getting-started-ruby]] -== Getting started - -This page guides you through the installation process of the Ruby client, shows -you how to instantiate the client, and how to perform basic Elasticsearch -operations with it. - -[discrete] -=== Requirements - -A currently maintained version of Ruby (3.0+) or JRuby (9.3+). - -[discrete] -=== Installation - -To install the latest version of the client, run the following command: - -[source,shell] --------------------------- -gem install elasticsearch --------------------------- - -Refer to the <> page to learn more. - - -[discrete] -=== Connecting - -You can connect to the Elastic Cloud using an API key and the Elasticsearch -endpoint. - -[source,rb] ----- -client = Elasticsearch::Client.new( - cloud_id: '', - api_key: '' -) ----- - -Your Elasticsearch endpoint can be found on the **My deployment** page of your -deployment: - -image::images/es_endpoint.jpg[alt="Finding Elasticsearch endpoint",align="center"] - -You can generate an API key on the **Management** page under Security. - -image::images/create_api_key.png[alt="Create API key",align="center"] - -For other connection options, refer to the <> section. - - -[discrete] -=== Operations - -Time to use Elasticsearch! This section walks you through the basic, and most -important, operations of Elasticsearch. For more operations and more advanced -examples, refer to the <> page. - - -[discrete] -==== Creating an index - -This is how you create the `my_index` index: - -[source,rb] ----- -client.indices.create(index: 'my_index') ----- - - -[discrete] -==== Indexing documents - -This is a simple way of indexing a document: - -[source,rb] ----- -document = { name: 'elasticsearch-ruby' } -response = client.index(index: 'my_index', body: document) -# You can get the indexed document id with: -response['_id'] -=> "PlgIDYkBWS9Ngdx5IMy-" -id = response['_id'] ----- - - -[discrete] -==== Getting documents - -You can get documents by using the following code: - -[source,rb] ----- -client.get(index: 'my_index', id: id) ----- - - -[discrete] -==== Searching documents - -This is how you can create a single match query with the Ruby client: - -[source,rb] ----- -client.search(index: 'my_index', body: { query: { match_all: {} } }) ----- - - -[discrete] -==== Updating documents - -This is how you can update a document, for example to add a new field: - -[source,rb] ----- -client.update(index: 'my_index', id: id, body: { doc: { language: 'Ruby' } }) ----- - - -[discrete] -==== Deleting documents - -[source,rb] ----- -client.delete(index: 'my_index', id: id) ----- - - -[discrete] -==== Deleting an index - -[source,rb] ----- -client.indices.delete(index: 'my_index') ----- - - -[discrete] -== Further reading - -* Use <> for a more confortable experience with the APIs. \ No newline at end of file diff --git a/docs/helpers.asciidoc b/docs/helpers.asciidoc deleted file mode 100644 index 9509cd8989..0000000000 --- a/docs/helpers.asciidoc +++ /dev/null @@ -1,162 +0,0 @@ -[[Helpers]] -== Client Helpers - -The {es} Ruby client includes some useful helpers for a more comfortable experience with some APIs. - -[discrete] -=== Bulk Helper - -The Bulk API in Elasticsearch allows you to perform multiple indexing or deletion operations through a single API call, resulting in reduced overhead and improved indexing speed. The actions are specified in the request body using a newline delimited JSON (NDJSON) structure. In the Elasticsearch Ruby client, the `bulk` method supports several data structures as a parameter. You can use the Bulk API in an idiomatic way without concerns about payload formatting. Refer to <> for more information. - - -The BulkHelper provides a better developer experience when using the Bulk API. At its simplest, you can send it a collection of hashes in an array, and it will bulk ingest them into {es}. - -To use the BulkHelper, require it in your code: - -[source,ruby] ----- -require 'elasticsearch/helpers/bulk_helper' ----- - -Instantiate a BulkHelper with a client, and an index: -[source,ruby] ----- -client = Elasticsearch::Client.new -bulk_helper = Elasticsearch::Helpers::BulkHelper.new(client, index) ----- - -This helper works on the index you pass in during initialization, but you can change the index at any time in your code: - -[source,ruby] ----- -bulk_helper.index = 'new_index' ----- - -If you want to index a collection of documents, use the `ingest` method: - -[source,ruby] ----- -documents = [ - { name: 'document1', date: '2024-05-16' }, - { name: 'document2', date: '2023-12-19' }, - { name: 'document3', date: '2024-07-07' } -] -bulk_helper.ingest(documents) ----- - -If you're ingesting a large set of data and want to separate the documents into smaller pieces before sending them to {es}, use the `slice` parameter. - -[source,ruby] ----- -bulk_helper.ingest(documents, { slice: 2 }) ----- - -This way the data will be sent in two different bulk requests. - -You can also include the parameters you would send to the Bulk API either in the query parameters or in the request body. The method signature is `ingest(docs, params = {}, body = {}, &block)`. Additionally, the method can be called with a block, that will provide access to the response object received from calling the Bulk API and the documents sent in the request: - -[source,ruby] ----- -helper.ingest(documents) { |_, docs| puts "Ingested #{docs.count} documents" } ----- - -You can update and delete documents with the BulkHelper too. To delete a set of documents, you can send an array of document ids: - -[source,ruby] ----- -ids = ['shm0I4gB6LpJd9ljO9mY', 'sxm0I4gB6LpJd9ljO9mY', 'tBm0I4gB6LpJd9ljO9mY', 'tRm0I4gB6LpJd9ljO9mY', 'thm0I4gB6LpJd9ljO9mY', 'txm0I4gB6LpJd9ljO9mY', 'uBm0I4gB6LpJd9ljO9mY', 'uRm0I4gB6LpJd9ljO9mY', 'uhm0I4gB6LpJd9ljO9mY', 'uxm0I4gB6LpJd9ljO9mY'] -helper.delete(ids) ----- - -To update documents, you can send the array of documents with their respective ids: -[source,ruby] ----- -documents = [ - {name: 'updated name 1', id: 'AxkFJYgB6LpJd9ljOtr7'}, - {name: 'updated name 2', id: 'BBkFJYgB6LpJd9ljOtr7'} -] -helper.update(documents) ----- - -[discrete] -==== Ingest a JSON file - -`BulkHelper` also provides a helper to ingest data straight from a JSON file. By giving a file path as an input, the helper will parse and ingest the documents in the file: - -[source,ruby] ----- -file_path = './data.json' -helper.ingest_json(file_path) ----- - -In cases where the array of data you want to ingest is not necessarily in the root of the JSON file, you can provide the keys to access the data, for example given the following JSON file: - -[source,json] ----- -{ - "field": "value", - "status": 200, - "data": { - "items": [ - { - "name": "Item 1", - (...) - }, - { - (...) - ] - } -} ----- - -The following is an example of the Ruby code to ingest the documents in the JSON above: - -[source,ruby] ----- -bulk_helper.ingest_json(file_path, { keys: ['data', 'items'] }) ----- - -[discrete] -=== Scroll Helper - -This helper provides an easy way to get results from a Scroll. - -To use the ScrollHelper, require it in your code: - -[source,ruby] ----- -require 'elasticsearch/helpers/scroll_helper' ----- - -Instantiate a ScrollHelper with a client, an index, and a body (with the scroll API parameters) which will be used in every following scroll request: - -[source,ruby] ----- -client = Elasticsearch::Client.new -scroll_helper = Elasticsearch::Helpers::ScrollHelper.new(client, index, body) ----- - -There are two ways to get the results from a scroll using the helper. - -1. You can iterate over a scroll using the methods in `Enumerable` such as `each` and `map`: -+ --- -[source,ruby] ----- -scroll_helper.each do |item| - puts item -end ----- --- -2. You can fetch results by page, with the `results` function: -+ --- -[source,ruby] ----- -my_documents = [] -while !(documents = scroll_helper.results).empty? - my_documents << documents -end -scroll_helper.clear ----- --- diff --git a/docs/index-custom-title-page.html b/docs/index-custom-title-page.html index e50a0351b4..e1f913c13e 100644 --- a/docs/index-custom-title-page.html +++ b/docs/index-custom-title-page.html @@ -153,7 +153,7 @@

- +

diff --git a/docs/index.asciidoc b/docs/index.asciidoc deleted file mode 100644 index 48a3fa171c..0000000000 --- a/docs/index.asciidoc +++ /dev/null @@ -1,29 +0,0 @@ -= Elasticsearch Ruby Client - -:doctype: book - -include::{asciidoc-dir}/../../shared/attributes.asciidoc[] - -include::overview.asciidoc[] - -include::getting-started.asciidoc[] - -include::installation.asciidoc[] - -include::connecting.asciidoc[] - -include::config.asciidoc[] - -include::basic-config.asciidoc[] - -include::advanced-config.asciidoc[] - -include::integrations.asciidoc[] - -include::examples.asciidoc[] - -include::troubleshooting.asciidoc[] - -include::helpers.asciidoc[] - -include::release_notes/index.asciidoc[] diff --git a/docs/installation.asciidoc b/docs/installation.asciidoc deleted file mode 100644 index dd3c2d2ac8..0000000000 --- a/docs/installation.asciidoc +++ /dev/null @@ -1,43 +0,0 @@ -[[ruby-install]] -== Installation - -Install the Rubygem for the latest {es} version by using the following command: - -[source,sh] ------------------------------------- -gem install elasticsearch ------------------------------------- - - -Or add the `elasticsearch` Ruby gem to your Gemfile: - -[source,ruby] ------------------------------------- -gem 'elasticsearch' ------------------------------------- - - - -You can install the Ruby gem for a specific {es} version by using the following -command: - -[source,sh] ------------------------------------- -gem install elasticsearch -v 7.0.0 ------------------------------------- - - -Or you can add a specific version of {es} to your Gemfile: - -[source,ruby] ------------------------------------- -gem 'elasticsearch', '~> 7.0' ------------------------------------- - - -[discrete] -=== {es} and Ruby Version Compatibility - -The {es} client is compatible with currently maintained Ruby versions. We follow Ruby’s own maintenance policy and officially support all currently maintained versions per https://www.ruby-lang.org/en/downloads/branches/[Ruby Maintenance Branches]. - -Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of {es}. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made. diff --git a/docs/integrations.asciidoc b/docs/integrations.asciidoc deleted file mode 100644 index 8b81ff5042..0000000000 --- a/docs/integrations.asciidoc +++ /dev/null @@ -1,27 +0,0 @@ -[[integrations]] -== Integrations - -The Rubygems listed on this page make it easier to operate with {es} by using -the Ruby client. - -* <> -* <> -* <> -* <> -* <> -* <> -* <> - -include::transport.asciidoc[] - -include::api.asciidoc[] - -include::ecs.asciidoc[] - -include::model.asciidoc[] - -include::rails.asciidoc[] - -include::persistence.asciidoc[] - -include::dsl.asciidoc[] diff --git a/docs/model.asciidoc b/docs/model.asciidoc deleted file mode 100644 index 8f4da31f7c..0000000000 --- a/docs/model.asciidoc +++ /dev/null @@ -1,72 +0,0 @@ -[[activemodel_activerecord]] -=== ActiveModel / ActiveRecord - -The `elasticsearch-model` http://rubygems.org/gems/elasticsearch-model[Rubygem] -provides integration with Ruby domain objects ("models"), commonly found for -example, in Ruby on Rails applications. - -It uses the `elasticsearch` Rubygem as the client communicating with the {es} -cluster. - - -[discrete] -==== Features - -* ActiveModel integration with adapters for ActiveRecord and Mongoid -* Enumerable-based wrapper for search results -* ActiveRecord::Relation-based wrapper for returning search results as records -* Convenience model methods such as `search`, `mapping`, `import`, etc -* Support for Kaminari and WillPaginate pagination -* Extension implemented via proxy object to shield model namespace from collisions -* Convenience methods for (re)creating the index, setting up mappings, indexing documents, ... - - -[discrete] -==== Usage - -Add the library to your Gemfile: - -[source,ruby] ------------------------------------- -gem 'elasticsearch-rails' ------------------------------------- - -Include the extension module in your model class: - -[source,ruby] ------------------------------------- -class Article < ActiveRecord::Base - include Elasticsearch::Model -end ------------------------------------- - -Import some data and perform a search: - -[source,ruby] ------------------------------------- -Article.import - -response = Article.search 'fox dog' -response.took -# => 3 ------------------------------------- - -It is possible to either return results as model instances, or decorated -documents from {es}, with the `records` and `results` methods, respectively: - -[source,ruby] ------------------------------------- -response.records.first -# Article Load (0.4ms) SELECT "articles".* FROM "articles" WHERE ... -=> #
- -response.results.first._score -# => 0.02250402 - -response.results.first._source.title -# => "Quick brown fox" ------------------------------------- - -Consult the -https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model[documentation] -for more information. diff --git a/docs/overview.asciidoc b/docs/overview.asciidoc deleted file mode 100644 index 108094e23b..0000000000 --- a/docs/overview.asciidoc +++ /dev/null @@ -1,38 +0,0 @@ -[[ruby_client]] -== Overview - -The `elasticsearch` http://rubygems.org/gems/elasticsearch[Rubygem] provides a low-level client for communicating with an {es} cluster, fully compatible with other official clients. - -More documentation is hosted in https://github.com/elastic/elasticsearch-ruby[Github] and http://rubydoc.info/gems/elasticsearch[RubyDoc]. - -Refer to the <> page for a step-by-step quick start with -the Ruby client. - -[discrete] -=== Features - -* Pluggable logging and tracing -* Pluggable connection selection strategies (round-robin, random, custom) -* Pluggable transport implementation, customizable and extendable -* Pluggable serializer implementation -* Request retries and dead connections handling -* Node reloading (based on cluster state) on errors or on demand -* Modular API implementation -* 100% REST API coverage - - -[discrete] -[[transport-api]] -=== Transport and API - -The `elasticsearch` gem combines two separate Rubygems: - -* https://github.com/elastic/elastic-transport-ruby/[`elastic-transport`] - provides an HTTP Ruby client for connecting to the {es} cluster. Refer to the documentation: <> - -* https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-api[`elasticsearch-api`] - provides a Ruby API for the {es} RESTful API. - -Please consult their respective documentation for configuration options and technical details. - -Notably, the documentation and comprehensive examples for all the API methods are contained in the source, and available online at http://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Actions[Rubydoc]. - -Keep in mind, that for optimal performance, you should use an HTTP library which supports persistent ("keep-alive") HTTP connections. diff --git a/docs/persistence.asciidoc b/docs/persistence.asciidoc deleted file mode 100644 index 8567a723cf..0000000000 --- a/docs/persistence.asciidoc +++ /dev/null @@ -1,116 +0,0 @@ -[[persistence]] -=== Persistence - -The `elasticsearch-persistence` -http://rubygems.org/gems/elasticsearch-persistence[Rubygem] provides persistence -layer for Ruby domain objects. - -It supports the repository design patterns. Versions before 6.0 also supported -the _active record_ design pattern. - - -[discrete] -==== Repository - -The `Elasticsearch::Persistence::Repository` module provides an implementation -of the repository pattern and allows to save, delete, find and search objects -stored in {es}, as well as configure mappings and settings for the index. - - -[discrete] -===== Features - -* Access to the {es} client -* Setting the index name, document type, and object class for deserialization -* Composing mappings and settings for the index -* Creating, deleting or refreshing the index -* Finding or searching for documents -* Providing access both to domain objects and hits for search results -* Providing access to the {es} response for search results -* Defining the methods for serialization and deserialization - - -[discrete] -===== Usage - -Let's have a simple plain old Ruby object (PORO): - -[source,ruby] ------------------------------------- -class Note - attr_reader :attributes - - def initialize(attributes={}) - @attributes = attributes - end - - def to_hash - @attributes - end -end ------------------------------------- - -Create a default, "dumb" repository, as a first step: - -[source,ruby] ------------------------------------- -require 'elasticsearch/persistence' -class MyRepository; include Elasticsearch::Persistence::Repository; end -repository = MyRepository.new ------------------------------------- - -Save a `Note` instance into the repository: - -[source,ruby] ------------------------------------- -note = Note.new id: 1, text: 'Test' - -repository.save(note) -# PUT http://localhost:9200/repository/_doc/1 [status:201, request:0.210s, query:n/a] -# > {"id":1,"text":"Test"} -# < {"_index":"repository","_type":"note","_id":"1","_version":1,"created":true} ------------------------------------- - -Find it: - -[source,ruby] ------------------------------------- -n = repository.find(1) -# GET http://localhost:9200/repository/_doc/1 [status:200, request:0.003s, query:n/a] -# < {"_index":"repository","_type":"note","_id":"1","_version":2,"found":true, "_source" : {"id":1,"text":"Test"}} -=> 1, "text"=>"Test"}> ------------------------------------- - -Search for it: - -[source,ruby] ------------------------------------- -repository.search(query: { match: { text: 'test' } }).first -# GET http://localhost:9200/repository/_search [status:200, request:0.005s, query:0.002s] -# > {"query":{"match":{"text":"test"}}} -# < {"took":2, ... "hits":{"total":1, ... "hits":[{ ... "_source" : {"id":1,"text":"Test"}}]}} -=> 1, "text"=>"Test"}> ------------------------------------- - -Delete it: - -[source,ruby] ------------------------------------- -repository.delete(note) -# DELETE http://localhost:9200/repository/_doc/1 [status:200, request:0.014s, query:n/a] -# < {"found":true,"_index":"repository","_type":"note","_id":"1","_version":3} -=> {"found"=>true, "_index"=>"repository", "_type"=>"note", "_id"=>"1", "_version"=>2} ------------------------------------- - -The repository module provides a number of features and facilities to configure -and customize the behaviour, as well as support for extending your own, custom -repository class. - -Please refer to the -https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence#the-repository-pattern[documentation] -for more information. - -Also, check out the -https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence#example-application[example application] -which demonstrates the usage patterns of the _repository_ approach to -persistence. diff --git a/docs/rails.asciidoc b/docs/rails.asciidoc deleted file mode 100644 index d1c84e1b86..0000000000 --- a/docs/rails.asciidoc +++ /dev/null @@ -1,24 +0,0 @@ -[[ruby_on_rails]] -=== Ruby On Rails - -The `elasticsearch-rails` http://rubygems.org/gems/elasticsearch-rails[Rubygem] -provides features suitable for Ruby on Rails applications. - - -[discrete] -==== Features - -* Rake tasks for importing data from application models -* Integration with Rails' instrumentation framework -* Templates for generating example Rails application - - -[discrete] -==== Example applications - -You can generate a fully working example Ruby on Rails application with -templates provides. - -Please refer to the -https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails[documentation] -for more information. diff --git a/docs/reference/Helpers.md b/docs/reference/Helpers.md new file mode 100644 index 0000000000..67c7be3393 --- /dev/null +++ b/docs/reference/Helpers.md @@ -0,0 +1,151 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/Helpers.html +--- + +# Bulk and Scroll helpers [Helpers] + +The {{es}} Ruby client includes Bulk and Scroll helpers for working with results more efficiently. + + +## Bulk helper [_bulk_helper] + +The Bulk API in Elasticsearch allows you to perform multiple indexing or deletion operations through a single API call, resulting in reduced overhead and improved indexing speed. The actions are specified in the request body using a newline delimited JSON (NDJSON) structure. In the Elasticsearch Ruby client, the `bulk` method supports several data structures as a parameter. You can use the Bulk API in an idiomatic way without concerns about payload formatting. Refer to [Bulk requests](/reference/examples.md#ex-bulk) for more information. + +The BulkHelper provides a better developer experience when using the Bulk API. At its simplest, you can send it a collection of hashes in an array, and it will bulk ingest them into {{es}}. + +To use the BulkHelper, require it in your code: + +```ruby +require 'elasticsearch/helpers/bulk_helper' +``` + +Instantiate a BulkHelper with a client, and an index: + +```ruby +client = Elasticsearch::Client.new +bulk_helper = Elasticsearch::Helpers::BulkHelper.new(client, index) +``` + +This helper works on the index you pass in during initialization, but you can change the index at any time in your code: + +```ruby +bulk_helper.index = 'new_index' +``` + +If you want to index a collection of documents, use the `ingest` method: + +```ruby +documents = [ + { name: 'document1', date: '2024-05-16' }, + { name: 'document2', date: '2023-12-19' }, + { name: 'document3', date: '2024-07-07' } +] +bulk_helper.ingest(documents) +``` + +If you’re ingesting a large set of data and want to separate the documents into smaller pieces before sending them to {{es}}, use the `slice` parameter. + +```ruby +bulk_helper.ingest(documents, { slice: 2 }) +``` + +This way the data will be sent in two different bulk requests. + +You can also include the parameters you would send to the Bulk API either in the query parameters or in the request body. The method signature is `ingest(docs, params = {}, body = {}, &block)`. Additionally, the method can be called with a block, that will provide access to the response object received from calling the Bulk API and the documents sent in the request: + +```ruby +helper.ingest(documents) { |_, docs| puts "Ingested #{docs.count} documents" } +``` + +You can update and delete documents with the BulkHelper too. To delete a set of documents, you can send an array of document ids: + +```ruby +ids = ['shm0I4gB6LpJd9ljO9mY', 'sxm0I4gB6LpJd9ljO9mY', 'tBm0I4gB6LpJd9ljO9mY', 'tRm0I4gB6LpJd9ljO9mY', 'thm0I4gB6LpJd9ljO9mY', 'txm0I4gB6LpJd9ljO9mY', 'uBm0I4gB6LpJd9ljO9mY', 'uRm0I4gB6LpJd9ljO9mY', 'uhm0I4gB6LpJd9ljO9mY', 'uxm0I4gB6LpJd9ljO9mY'] +helper.delete(ids) +``` + +To update documents, you can send the array of documents with their respective ids: + +```ruby +documents = [ + {name: 'updated name 1', id: 'AxkFJYgB6LpJd9ljOtr7'}, + {name: 'updated name 2', id: 'BBkFJYgB6LpJd9ljOtr7'} +] +helper.update(documents) +``` + + +### Ingest a JSON file [_ingest_a_json_file] + +`BulkHelper` also provides a helper to ingest data straight from a JSON file. By giving a file path as an input, the helper will parse and ingest the documents in the file: + +```ruby +file_path = './data.json' +helper.ingest_json(file_path) +``` + +In cases where the array of data you want to ingest is not necessarily in the root of the JSON file, you can provide the keys to access the data, for example given the following JSON file: + +```json +{ + "field": "value", + "status": 200, + "data": { + "items": [ + { + "name": "Item 1", + (...) + }, + { + (...) + ] + } +} +``` + +The following is an example of the Ruby code to ingest the documents in the JSON above: + +```ruby +bulk_helper.ingest_json(file_path, { keys: ['data', 'items'] }) +``` + + +## Scroll helper [_scroll_helper] + +This helper provides an easy way to get results from a Scroll. + +To use the ScrollHelper, require it in your code: + +```ruby +require 'elasticsearch/helpers/scroll_helper' +``` + +Instantiate a ScrollHelper with a client, an index, and a body (with the scroll API parameters) which will be used in every following scroll request: + +```ruby +client = Elasticsearch::Client.new +scroll_helper = Elasticsearch::Helpers::ScrollHelper.new(client, index, body) +``` + +There are two ways to get the results from a scroll using the helper. + +1. You can iterate over a scroll using the methods in `Enumerable` such as `each` and `map`: + + ```ruby + scroll_helper.each do |item| + puts item + end + ``` + +2. You can fetch results by page, with the `results` function: + + ```ruby + my_documents = [] + while !(documents = scroll_helper.results).empty? + my_documents << documents + end + scroll_helper.clear + ``` + + diff --git a/docs/reference/activemodel_activerecord.md b/docs/reference/activemodel_activerecord.md new file mode 100644 index 0000000000..8a143def32 --- /dev/null +++ b/docs/reference/activemodel_activerecord.md @@ -0,0 +1,65 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/activemodel_activerecord.html +--- + +# ActiveModel / ActiveRecord [activemodel_activerecord] + +The `elasticsearch-model` [Rubygem](http://rubygems.org/gems/elasticsearch-model) provides integration with Ruby domain objects ("models"), commonly found for example, in Ruby on Rails applications. + +It uses the `elasticsearch` Rubygem as the client communicating with the {{es}} cluster. + + +## Features [_features_2] + +* ActiveModel integration with adapters for ActiveRecord and Mongoid +* Enumerable-based wrapper for search results +* ActiveRecord::Relation-based wrapper for returning search results as records +* Convenience model methods such as `search`, `mapping`, `import`, etc +* Support for Kaminari and WillPaginate pagination +* Extension implemented via proxy object to shield model namespace from collisions +* Convenience methods for (re)creating the index, setting up mappings, indexing documents, …​ + + +## Usage [_usage] + +Add the library to your Gemfile: + +```ruby +gem 'elasticsearch-rails' +``` + +Include the extension module in your model class: + +```ruby +class Article < ActiveRecord::Base + include Elasticsearch::Model +end +``` + +Import some data and perform a search: + +```ruby +Article.import + +response = Article.search 'fox dog' +response.took +# => 3 +``` + +It is possible to either return results as model instances, or decorated documents from {{es}}, with the `records` and `results` methods, respectively: + +```ruby +response.records.first +# Article Load (0.4ms) SELECT "articles".* FROM "articles" WHERE ... +=> #
+ +response.results.first._score +# => 0.02250402 + +response.results.first._source.title +# => "Quick brown fox" +``` + +Consult the [documentation](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model) for more information. + diff --git a/docs/reference/advanced-config.md b/docs/reference/advanced-config.md new file mode 100644 index 0000000000..c045a91d4b --- /dev/null +++ b/docs/reference/advanced-config.md @@ -0,0 +1,298 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/advanced-config.html +--- + +# Advanced configuration [advanced-config] + +The client supports many configurations options for setting up and managing connections, configuring logging, customizing the transport library, and so on. + + +## Setting hosts [setting-hosts] + +To connect to a specific {{es}} host: + +```ruby +Elasticsearch::Client.new(host: 'search.myserver.com') +``` + +To connect to a host with specific port: + +```ruby +Elasticsearch::Client.new(host: 'myhost:8080') +``` + +To connect to multiple hosts: + +```ruby +Elasticsearch::Client.new(hosts: ['myhost1', 'myhost2']) +``` + +Instead of strings, you can pass host information as an array of Hashes: + +```ruby +Elasticsearch::Client.new(hosts: [ { host: 'myhost1', port: 8080 }, { host: 'myhost2', port: 8080 } ]) +``` + +::::{note} +When specifying multiple hosts, you might want to enable the `retry_on_failure` or `retry_on_status` options to perform a failed request on another node (refer to [Retrying on Failures](#retry-failures)). +:::: + + +Common URL parts – scheme, HTTP authentication credentials, URL prefixes, and so on – are handled automatically: + +```ruby +Elasticsearch::Client.new(url: 'https://username:password@api.server.org:4430/search') +``` + +You can pass multiple URLs separated by a comma: + +```ruby +Elasticsearch::Client.new(urls: 'http://localhost:9200,http://localhost:9201') +``` + +Another way to configure URLs is to export the `ELASTICSEARCH_URL` variable. + +The client is automatically going to use a round-robin algorithm across the hosts (unless you select or implement a different [Connection Selector](#connection-selector)). + + +## Default port [default-port] + +The default port is `9200`. Specify a port for your host(s) if they differ from this default. + +If you are using Elastic Cloud, the default port is port `9243`. You must supply your username and password separately, and optionally a port. Refer to [Elastic Cloud](/reference/connecting.md#auth-ec). + + +## Logging [logging] + +To log requests and responses to standard output with the default logger (an instance of Ruby’s `::Logger` class), set the log argument to true: + +```ruby +Elasticsearch::Client.new(log: true) +``` + +You can also use [`ecs-logging`](https://github.com/elastic/ecs-logging-ruby) which is a set of libraries that enables you to transform your application logs to structured logs that comply with the [Elastic Common Schema](ecs://reference/index.md). See [Elastic Common Schema (ECS)](/reference/ecs.md). + +To trace requests and responses in the Curl format, set the `trace` argument: + +```ruby +Elasticsearch::Client.new(trace: true) +``` + +You can customize the default logger or tracer: + +```ruby +client.transport.logger.formatter = proc { |s, d, p, m| "#{s}: #{m}\n" } +client.transport.logger.level = Logger::INFO +``` + +Or, you can use a custom `::Logger` instance: + +```ruby +Elasticsearch::Client.new(logger: Logger.new(STDERR)) +``` + +You can pass the client any conforming logger implementation: + +```ruby +require 'logging' # https://github.com/TwP/logging/ + +log = Logging.logger['elasticsearch'] +log.add_appenders Logging.appenders.stdout +log.level = :info + +client = Elasticsearch::Client.new(logger: log) +``` + + +## APM integration [apm-integration] + +This client integrates seamlessly with Elastic APM via the Elastic APM Agent. It automatically captures client requests if you are using the agent on your code. If you’re using `elastic-apm` v3.8.0 or up, you can set `capture_elasticsearch_queries` to `true` in `config/elastic_apm.yml` to also capture the body from requests in {{es}}. Refer to [this example](https://github.com/elastic/elasticsearch-ruby/tree/main/docs/examples/apm). + + +## Custom HTTP Headers [custom-http-headers] + +You can set a custom HTTP header on the client’s initializer: + +```ruby +client = Elasticsearch::Client.new( + transport_options: { + headers: + {user_agent: "My App"} + } +) +``` + +You can also pass in `headers` as a parameter to any of the API Endpoints to set custom headers for the request: + +```ruby +client.search(index: 'myindex', q: 'title:test', headers: {user_agent: "My App"}) +``` + + +## Identifying running tasks with X-Opaque-Id [x-opaque-id] + +The X-Opaque-Id header allows to track certain calls, or associate certain tasks with the client that started them (refer to [the documentation](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-tasks)). To use this feature, you need to set an id for `opaque_id` on the client on each request. Example: + +```ruby +client = Elasticsearch::Client.new +client.search(index: 'myindex', q: 'title:test', opaque_id: '123456') +``` + +The search request includes the following HTTP Header: + +```ruby +X-Opaque-Id: 123456 +``` + +You can also set a prefix for X-Opaque-Id when initializing the client. This is prepended to the id you set before each request if you’re using X-Opaque-Id. Example: + +```ruby +client = Elasticsearch::Client.new(opaque_id_prefix: 'eu-west1_') +client.search(index: 'myindex', q: 'title:test', opaque_id: '123456') +``` + +The request includes the following HTTP Header: + +```ruby +X-Opaque-Id: eu-west1_123456 +``` + + +## Setting Timeouts [setting-timeouts] + +For many operations in {{es}}, the default timeouts of HTTP libraries are too low. To increase the timeout, you can use the `request_timeout` parameter: + +```ruby +Elasticsearch::Client.new(request_timeout: 5*60) +``` + +You can also use the `transport_options` argument documented below. + + +## Randomizing Hosts [randomizing-hosts] + +If you pass multiple hosts to the client, it rotates across them in a round-robin fashion by default. When the same client would be running in multiple processes (for example, in a Ruby web server such as Thin), it might keep connecting to the same nodes "at once". To prevent this, you can randomize the hosts collection on initialization and reloading: + +```ruby +Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], randomize_hosts: true) +``` + + +## Retrying on Failures [retry-failures] + +When the client is initialized with multiple hosts, it makes sense to retry a failed request on a different host: + +```ruby +Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: true) +``` + +By default, the client does not retry the request. You can specify how many times to retry before it raises an exception by passing a number to `retry_on_failure`: + +```ruby + Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: 5) +``` + +You can also use `retry_on_status` to retry when specific status codes are returned: + +```ruby +Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_status: [502, 503]) +``` + +These two parameters can also be used together: + +```ruby +Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_status: [502, 503], retry_on_failure: 10) +``` + +You can also set a `delay_on_retry` value in milliseconds. This will add a delay to wait between retries: + +```ruby + Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: 5, delay_on_retry: 1000) +``` + + +## Reloading Hosts [reload-hosts] + +{{es}} dynamically discovers new nodes in the cluster by default. You can leverage this in the client, and periodically check for new nodes to spread the load. + +To retrieve and use the information from the [Nodes Info API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-info) on every 10,000th request: + +```ruby +Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], reload_connections: true) +``` + +You can pass a specific number of requests after which reloading should be performed: + +```ruby +Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], reload_connections: 1_000) +``` + +To reload connections on failures, use: + +```ruby +Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], reload_on_failure: true) +``` + +The reloading timeouts if not finished under 1 second by default. To change the setting: + +```ruby +Elasticsearch::Client.new(hosts: ['localhost:9200', 'localhost:9201'], sniffer_timeout: 3) +``` + +::::{note} +When using reloading hosts ("sniffing") together with authentication, pass the scheme, user and password with the host info – or, for more clarity, in the `http` options: +:::: + + +```ruby +Elasticsearch::Client.new( + host: 'localhost:9200', + http: { scheme: 'https', user: 'U', password: 'P' }, + reload_connections: true, + reload_on_failure: true +) +``` + + +## Connection Selector [connection-selector] + +By default, the client rotates the connections in a round-robin fashion, using the `Elastic::Transport::Transport::Connections::Selector::RoundRobin` strategy. + +You can implement your own strategy to customize the behaviour. For example, let’s have a "rack aware" strategy, which prefers the nodes with a specific attribute. The strategy uses the other nodes, only when these are unavailable: + +```ruby +class RackIdSelector + include Elastic::Transport::Transport::Connections::Selector::Base + + def select(options={}) + connections.select do |c| + # Try selecting the nodes with a `rack_id:x1` attribute first + c.host[:attributes] && c.host[:attributes][:rack_id] == 'x1' + end.sample || connections.to_a.sample + end +end + +Elasticsearch::Client.new hosts: ['x1.search.org', 'x2.search.org'], selector_class: RackIdSelector +``` + + +## Serializer Implementations [serializer-implementations] + +By default, the [MultiJSON](https://rubygems.org/gems/multi_json) library is used as the serializer implementation, and it picks up the "right" adapter based on gems available. + +The serialization component is pluggable, though, so you can write your own by including the `Elastic::Transport::Transport::Serializer::Base` module, implementing the required contract, and passing it to the client as the `serializer_class` or `serializer` parameter. + + +## Exception Handling [exception-handling] + +The library defines a [number of exception classes](https://github.com/elastic/elastic-transport-ruby/blob/main/lib/elastic/transport/transport/errors.rb) for various client and server errors, as well as unsuccessful HTTP responses, making it possible to rescue specific exceptions with desired granularity. + +The highest-level exception is `Elastic::Transport::Transport::Error` and is raised for any generic client or server errors. + +`Elastic::Transport::Transport::ServerError` is raised for server errors only. + +As an example for response-specific errors, a 404 response status raises an `Elastic::Transport::Transport::Errors::NotFound` exception. + +Finally, `Elastic::Transport::Transport::SnifferTimeoutError` is raised when connection reloading ("sniffing") times out. + diff --git a/docs/reference/api.md b/docs/reference/api.md new file mode 100644 index 0000000000..261413b45c --- /dev/null +++ b/docs/reference/api.md @@ -0,0 +1,210 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/api.html +--- + +# Elasticsearch API [api] + +The `elasticsearch-api` library provides a Ruby implementation of the [Elasticsearch](https://www.elastic.co/elastic-stack/) REST API. + + +## Installation [api-install] + +Install the package from [Rubygems](https://rubygems.org): + +```bash +gem install elasticsearch-api +``` + +To use an unreleased version, either add it to your `Gemfile` for [Bundler](https://bundler.io/): + +```bash +gem 'elasticsearch-api', git: 'git://github.com/elasticsearch/elasticsearch-ruby.git' +``` + +or install it from a source code checkout: + +```bash +git clone https://github.com/elasticsearch/elasticsearch-ruby.git +cd elasticsearch-ruby/elasticsearch-api +bundle install +rake install +``` + + +## Example usage [api-example-usage] + +The library is designed as a group of standalone Ruby modules, which can be mixed into a class providing connection to Elasticsearch — an Elasticsearch client. + + +### Usage with the `elasticsearch` gem [_usage_with_the_elasticsearch_gem] + +**When you use the client from the [`elasticsearch-ruby`](https://github.com/elasticsearch/elasticsearch-ruby) client, the library modules have been already included**, so you just call the API methods. + +The response will be an `Elasticsearch::API::Response` object which wraps an `Elasticsearch::Transport::Transport::Response` object. It provides `body`, `status` and `headers` methods, but you can treat is as a hash and access the keys directly. + +```rb +require 'elasticsearch' + +client = Elasticsearch::Client.new + +>response = client.index(index: 'myindex', id: 1, body: { title: 'Test' }) +=> #"myindex", + "_id"=>"1", + "_version"=>2, + "result"=>"updated", + "_shards"=>{"total"=>1, "successful"=>1, "failed"=>0}, + "_seq_no"=>1, + "_primary_term"=>1}, + @headers= + {"x-elastic-product"=>"Elasticsearch", + "content-type"=>"application/json", + "content-encoding"=>"gzip", + "content-length"=>"130"}, + @status=200>> + +> response['result'] +=> "updated" + +client.search(index: 'myindex', body: { query: { match: { title: 'test' } } }) +# => => #223, + "timed_out"=>false, + "_shards"=>{"total"=>2, "successful"=>2, "skipped"=>0, "failed"=>0}, + "hits"=> + {"total"=>{"value"=>1, "relation"=>"eq"}, + "max_score"=>0.2876821, + "hits"=>[{"_index"=>"myindex", "_id"=>"1", "_score"=>0.2876821, "_source"=>{"title"=>"Test"}}]}}, + @headers= + {"x-elastic-product"=>"Elasticsearch", + "content-type"=>"application/json", + "content-encoding"=>"gzip", + "content-length"=>"188"}, + @status=200>> +``` + +Full documentation and examples are included as RDoc annotations in the source code and available online at [http://rubydoc.info/gems/elasticsearch-api](http://rubydoc.info/gems/elasticsearch-api). + + +### Usage with a custom client [_usage_with_a_custom_client] + +When you want to mix the library with your own client, it must conform to the following *contract*: + +* It responds to a `perform_request(method, path, params, body, headers)` method, +* the method returns an object with `status`, `body` and `headers` methods. + +A simple client could look like this (*with a dependency on `active_support` to parse the query params*): + +```rb +require 'multi_json' +require 'faraday' +require 'elasticsearch/api' + +class MySimpleClient + include Elasticsearch::API + + CONNECTION = ::Faraday::Connection.new(url: 'http://localhost:9200') + + def perform_request(method, path, params, body, headers = nil) + puts "--> #{method.upcase} #{path} #{params} #{body} #{headers}" + + CONNECTION.run_request \ + method.downcase.to_sym, + path_with_params(path, params), + ( body ? MultiJson.dump(body): nil ), + {'Content-Type' => 'application/json'} + end + + private + + def path_with_params(path, params) + return path if params.blank? + + case params + when String + "#{path}?#{params}" + when Hash + "#{path}?#{URI.encode_www_form(params)}" + else + raise ArgumentError, "Cannot parse params: '#{params}'" + end + end +end + +client = MySimpleClient.new + +p client.cluster.health +# --> GET _cluster/health {} +# => "{"cluster_name":"elasticsearch" ... }" + +p client.index(index: 'myindex', id: 'custom', body: { title: "Indexing from my client" }) +# --> PUT myindex/mytype/custom {} {:title=>"Indexing from my client"} +# => "{"ok":true, ... }" +``` + + +### Using JSON Builders [_using_json_builders] + +Instead of passing the `:body` argument as a Ruby *Hash*, you can pass it as a *String*, potentially taking advantage of JSON builders such as [JBuilder](https://github.com/rails/jbuilder) or [Jsonify](https://github.com/bsiggelkow/jsonify): + +```rb +require 'jbuilder' + +query = Jbuilder.encode do |json| + json.query do + json.match do + json.title do + json.query 'test 1' + json.operator 'and' + end + end + end +end + +client.search(index: 'myindex', body: query) + +# 2013-06-25 09:56:05 +0200: GET http://localhost:9200/myindex/_search [status:200, request:0.015s, query:0.011s] +# 2013-06-25 09:56:05 +0200: > {"query":{"match":{"title":{"query":"test 1","operator":"and"}}}} +# ... +# => {"took"=>21, ..., "hits"=>{"total"=>1, "hits"=>[{ "_source"=>{"title"=>"Test 1", ...}}]}} +``` + + +### Using Hash Wrappers [_using_hash_wrappers] + +For a more comfortable access to response properties, you may wrap it in one of the *Hash* "object access" wrappers, such as [`Hashie::Mash`](https://github.com/intridea/hashie): + +```rb +require 'hashie' + +response = client.search( + index: 'myindex', + body: { + query: { match: { title: 'test' } }, + aggregations: { tags: { terms: { field: 'tags' } } } + } +) + +mash = Hashie::Mash.new(response) + +mash.hits.hits.first._source.title +# => 'Test' +``` + + +### Using a Custom JSON Serializer [_using_a_custom_json_serializer] + +The library uses the [MultiJson](https://rubygems.org/gems/multi_json/) gem by default but allows you to set a custom JSON library, provided it uses the standard `load/dump` interface: + +```rb +Elasticsearch::API.settings[:serializer] = JrJackson::Json +Elasticsearch::API.serializer.dump({foo: 'bar'}) +# => {"foo":"bar"} +``` diff --git a/docs/reference/basic-config.md b/docs/reference/basic-config.md new file mode 100644 index 0000000000..f7bd47df7a --- /dev/null +++ b/docs/reference/basic-config.md @@ -0,0 +1,37 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/basic-config.html +--- + +# Basic configuration [basic-config] + +The table below contains the most important initialization parameters that you can use. + +| | | | +| --- | --- | --- | +| **Parameter** | **Data type** | **Description** | +| `adapter` | Symbol | A specific adapter for Faraday (for example, `:patron`). | +| `api_key` | String, Hash | For API key Authentication. Either the base64 encoding of `id` and `api_key` joined by a colon as a string, or a hash with the `id` and `api_key` values. | +| `compression` | Boolean | Whether to compress requests. Gzip compression is used. Defaults to `false`. Responses are automatically inflated if they are compressed. If a custom transport object is used, it must handle the request compression and response inflation. | +| `enable_meta_header` | Boolean | Whether to enable sending the meta data header to Cloud. Defaults to `true`. | +| `hosts` | String, Array | Single host passed as a string or hash, or multiple hosts passed as an array; `host` or `url` keys are also valid. | +| `log` | Boolean | Whether to use the default logger. Disabled by default. | +| `logger` | Object | An instance of a Logger-compatible object. | +| `opaque_id_prefix` | String | Sets a prefix for X-Opaque-Id when initializing the client. This is prepended to the id you set before each request if you’re using X-Opaque-Id. | +| `opentelemetry_tracer_provider` | `OpenTelemetry::Trace::TracerProvider` | An explicit TracerProvider to use instead of the global one with OpenTelemetry. This enables better dependency injection and simplifies testing. | +| `randomize_hosts` | Boolean | Whether to shuffle connections on initialization and reload. Defaults to `false`. | +| `reload_connections` | Boolean, Number | Whether to reload connections after X requests. Defaults to `false`. | +| `reload_on_failure` | Boolean | Whether to reload connections after failure. Defaults to `false`. | +| `request_timeout` | Integer | The request timeout to be passed to transport in options. | +| `resurrect_after` | Integer | Specifies after how many seconds a dead connection should be tried again. | +| `retry_on_failure` | Boolean, Number | Whether to retry X times when request fails before raising and exception. Defaults to `false`. | +| `retry_on_status` | Array, Number | Specifies which status code needs to be returned to retry. | +| `selector` | Constant | An instance of selector strategy implemented with {Elastic::Transport::Transport::Connections::Selector::Base}. | +| `send_get_body_as` | String | Specifies the HTTP method to use for GET requests with a body. Defaults to `GET`. | +| `serializer_class` | Constant | Specifies a serializer class to use. It is initialized by the transport and passed the transport instance. | +| `sniffer_timeout` | Integer | Specifies the timeout for reloading connections in seconds. Defaults to `1`. | +| `trace` | Boolean | Whether to use the default tracer. Disabled by default. | +| `tracer` | Object | Specifies an instance of a Logger-compatible object. | +| `transport` | Object | Specifies a transport instance. | +| `transport_class` | Constant | Specifies a transport class to use. It is initialized by the client and passed hosts and all arguments. | +| `transport_options` | Hash | Specifies the options to be passed to the `Faraday::Connection` constructor. | diff --git a/docs/reference/client-helpers.md b/docs/reference/client-helpers.md new file mode 100644 index 0000000000..72220c37b7 --- /dev/null +++ b/docs/reference/client-helpers.md @@ -0,0 +1,14 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/client-helpers.html +--- + +# Client helpers [client-helpers] + +The Ruby client includes the following helpers: + +* [Bulk and Scroll helpers](/reference/Helpers.md) +* [ES|QL](/reference/esql.md) + + + diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md new file mode 100644 index 0000000000..fdebc05c75 --- /dev/null +++ b/docs/reference/configuration.md @@ -0,0 +1,14 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ruby-config.html +--- + +# Configuration [ruby-config] + +This page contains information about how to configure the Ruby client tailored to your needs. Almost every aspect of the client is configurable. However, in most cases you only need to set a couple of parameters. + +* [Basic configuration](/reference/basic-config.md) +* [Advanced configuration](/reference/advanced-config.md) + + + diff --git a/docs/reference/connecting.md b/docs/reference/connecting.md new file mode 100644 index 0000000000..27bd224a2e --- /dev/null +++ b/docs/reference/connecting.md @@ -0,0 +1,311 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/connecting.html +--- + +# Connecting [connecting] + +This page contains the information you need to connect and use the Client with {{es}}. + +## Authentication [client-auth] + +This document contains code snippets to show you how to connect to various {{es}} providers. + + +### Elastic Cloud [auth-ec] + +If you are using [Elastic Cloud](https://www.elastic.co/cloud), the client offers an easy way to connect to it. You need the Cloud ID that you can find in the cloud console, then your username and password. + +![Cloud ID](images/cloud_id.png) + +Once you have collected the Cloud ID you can use the client to connect to your Elastic Cloud instance, as follows: + +```ruby +require 'elasticsearch' + +client = Elasticsearch::Client.new( + cloud_id: '' + user: '', + password: '', +) +``` + +You can also connect to the Cloud by using API Key authentication. You can generate an `API key` in the `Management` page under the section `Security`. + +![API key](images/cloud_api_key.png) + +When you click on `Create API key` you can choose a name and set the other options (eg. restrict privileges, expire after time, etc). + +![Choose an API name](images/api_key_name.png) + +After this step you will get the `API key` in the API keys page. + +![API key](images/cloud_api_key.png) + +**IMPORTANT**: you need to copy and store the `API key` in a secure place, since you will not be able to view it again in Elastic Cloud. + +Once you have collected the `Cloud ID` and the `API key` you can use the client to connect to your Elastic Cloud instance, as follows: + +```ruby +client = Elasticsearch::Client.new( + cloud_id: '', + api_key: '' +) +``` + +If you create the API Key through the dev console or the REST API, you may get instead a pair of `id` and `APIKey` values. The client also accepts a Hash for the `api_key` parameter, so you can pass in these values and it will encode the API Key internally: + +```ruby +client = Elasticsearch::Client.new( + cloud_id: '', + api_key: {id: '', api_key: ''} +) +``` + + +## Connecting to a self-managed cluster [connect-self-managed] + +{{es}} 8.0 offers security by default, that means authentication and TLS are enabled. + +To connect to the {{es}} cluster you’ll need to configure the Ruby {{es}} client to use HTTPS with the generated CA certificate in order to make requests successfully. + +If you’re just getting started with {{es}} we recommend reading the documentation on configuring and starting {{es}} to ensure your cluster is running as expected. + +When you start {{es}} for the first time you’ll see a distinct block like the one below in the output from {{es}} (you may have to scroll up if it’s been a while): + +```sh +---------------------------------------------------------------- +-> Elasticsearch security features have been automatically configured! +-> Authentication is enabled and cluster connections are encrypted. + +-> Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`): + lhQpLELkjkrawaBoaz0Q + +-> HTTP CA certificate SHA-256 fingerprint: + a52dd93511e8c6045e21f16654b77c9ee0f34aea26d9f40320b531c474676228 +... +---------------------------------------------------------------- +``` + +Note down the `elastic` user password and HTTP CA fingerprint for the next sections. In the examples below they will be stored in the variables `ELASTIC_PASSWORD` and `CERT_FINGERPRINT` respectively. + +Depending on the circumstances there are two options for verifying the HTTPS connection, either verifying with the CA certificate itself or via the HTTP CA certificate fingerprint. + + +### Verifying HTTPS with CA certificates [ca-certificates] + +The generated root CA certificate can be found in the `certs` directory in your {{es}} config location (`$ES_CONF_PATH/certs/http_ca.crt`). If you’re running {{es}} in Docker there is [additional documentation for retrieving the CA certificate](docs-content://deploy-manage/deploy/self-managed/install-elasticsearch-with-docker.md). + +Once you have the `http_ca.crt` file somewhere accessible pass the path to the client via `ca_certs`: + +```ruby +client = Elasticsearch::Client.new( + host: "https://elastic:#{ELASTIC_PASSWORD}@localhost:9200", + transport_options: { ssl: { ca_path: CERT_DIR } } +) +``` + + +### Verifying HTTPS with certificate fingerprints [ca-fingerprint] + +This method of verifying the HTTPS connection takes advantage of the certificate fingerprint value noted down earlier. Take this SHA256 fingerprint value and pass it to the Ruby {{es}} client via `ca_fingerprint`: + +```ruby +# Colons and uppercase/lowercase don't matter when using +# the 'ca_fingerprint' parameter +CERT_FINGERPRINT = '64F2593F...' + +# Password for the 'elastic' user generated by Elasticsearch +ELASTIC_PASSWORD = "" + +client = Elasticsearch::Client.new( + host: "https://elastic:#{ELASTIC_PASSWORD}@localhost:9200", + transport_options: { ssl: { verify: false } }, + ca_fingerprint: CERT_FINGERPRINT +) +``` + +The verification will be run once per connection. + +The certificate fingerprint can be calculated using `openssl x509` with the certificate file: + +```sh +openssl x509 -fingerprint -sha256 -noout -in /path/to/http_ca.crt +``` + +If you don’t have access to the generated CA file from {{es}} you can use the following script to output the root CA fingerprint of the {{es}} instance with `openssl s_client`: + +```sh +# Replace the values of 'localhost' and '9200' to the +# corresponding host and port values for the cluster. +openssl s_client -connect localhost:9200 -servername localhost -showcerts /dev/null \ + | openssl x509 -fingerprint -sha256 -noout -in /dev/stdin +``` + +The output of `openssl x509` will look something like this: + +```sh +SHA256 Fingerprint=A5:2D:D9:35:11:E8:C6:04:5E:21:F1:66:54:B7:7C:9E:E0:F3:4A:EA:26:D9:F4:03:20:B5:31:C4:74:67:62:28 +``` + + +### API Key authentication [auth-api-key] + +You can also use [ApiKey](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key) authentication. + +::::{note} +If you provide both basic authentication credentials and the ApiKey configuration, the ApiKey takes precedence. +:::: + + +```ruby +Elasticsearch::Client.new( + host: host, + transport_options: transport_options, + api_key: credentials +) +``` + +Where credentials is either the base64 encoding of `id` and `api_key` joined by a colon or a hash with the `id` and `api_key`: + +```ruby +Elasticsearch::Client.new( + host: host, + transport_options: transport_options, + api_key: {id: 'my_id', api_key: 'my_api_key'} +) +``` + + +### Basic authentication [auth-basic] + +You can pass the authentication credentials, scheme and port in the host configuration hash: + +```ruby +client = Elasticsearch::Client.new( + hosts: + [ + { + host: 'my-protected-host', + port: '443', + user: 'USERNAME', + password: 'PASSWORD', + scheme: 'https' + } + ] +) +``` + +Or use the common URL format: + +```ruby +client = Elasticsearch::Client.new(url: 'https://username:password@localhost:9200') +``` + +To pass a custom certificate for SSL peer verification to Faraday-based clients, use the `transport_options` option: + +```ruby +Elasticsearch::Client.new( + url: 'https://username:password@localhost:9200', + transport_options: { + ssl: { ca_file: '/path/to/http_ca.crt' } + } +) +``` + + +## Usage [client-usage] + +The following snippet shows an example of using the Ruby client: + +```ruby +require 'elasticsearch' + +client = Elasticsearch::Client.new log: true + +client.cluster.health + +client.index(index: 'my-index', id: 1, body: { title: 'Test' }) + +client.indices.refresh(index: 'my-index') + +client.search(index: 'my-index', body: { query: { match: { title: 'test' } } }) +``` + + +## Using the Client in a Function-as-a-Service Environment [client-faas] + +This section illustrates the best practices for leveraging the {{es}} client in a Function-as-a-Service (FaaS) environment. The most influential optimization is to initialize the client outside of the function, the global scope. This practice does not only improve performance but also enables background functionality as – for example – sniffing. The following examples provide a skeleton for the best practices. + + +### GCP Cloud Functions [_gcp_cloud_functions] + +```ruby +require 'functions_framework' +require 'elasticsearch' + +client = Elasticsearch::Client.new( + cloud_id: "elasic-cloud-id", + user: "elastic", + password: "password", + log: true +) + +FunctionsFramework.http "hello_world" do |request| + client.search( + index: 'stack-overflow', + body: { + query: { + match: { + title: { + query: 'phone application' + } + } + } + } + ) +end +``` + + +### AWS Lambda [_aws_lambda] + +```ruby +require 'elasticsearch' + +def client + @client ||= Elasticsearch::Client.new( + cloud_id: "elastic-cloud-id", + user: "elastic", + password: "password", + log: true + ) +end + +def lambda_handler(event:, context:) + client.search( + index: 'stack-overflow', + body: { + query: { + match: { + title: { + query: 'phone application' + } + } + } + } + ) +end +``` + +Resources used to assess these recommendations: + +* [GCP Cloud Functions: Tips & Tricks](https://cloud.google.com/functions/docs/bestpractices/tips#use_global_variables_to_reuse_objects_in_future_invocations) +* [Best practices for working with AWS Lambda functions](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html) + + +## Enabling the Compatibility Mode [client-comp] + +The Elasticsearch server version 8.0 is introducing a new compatibility mode that allows you a smoother upgrade experience from 7 to 8. In a nutshell, you can use the latest 7.x Elasticsearch client with an 8.x Elasticsearch server, giving more room to coordinate the upgrade of your codebase to the next major version. + +If you want to leverage this functionality, please make sure that you are using the latest 7.x client and set the environment variable `ELASTIC_CLIENT_APIVERSIONING` to `true`. The client is handling the rest internally. For every 8.0 and beyond client, you’re all set! The compatibility mode is enabled by default. diff --git a/docs/reference/dsl.md b/docs/reference/dsl.md new file mode 100644 index 0000000000..ae46890b8c --- /dev/null +++ b/docs/reference/dsl.md @@ -0,0 +1,11 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/dsl.html +--- + +# Elasticsearch DSL [dsl] + +The [elasticsearch-dsl](https://github.com/elastic/elasticsearch-dsl-ruby) gem provides a Ruby API for the [Elasticsearch Query DSL](https://www.elasticsearch.com/guide/en/elasticsearch/reference/current/query-dsl.html). The library allows to programmatically build complex search definitions for {{es}} in Ruby, which are translated to Hashes, and ultimately, JSON, the language of {{es}}. + +See [the README](https://github.com/elastic/elasticsearch-dsl-ruby#elasticsearchdsl) for more information. + diff --git a/docs/reference/ecs.md b/docs/reference/ecs.md new file mode 100644 index 0000000000..6fb1fc365f --- /dev/null +++ b/docs/reference/ecs.md @@ -0,0 +1,37 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ecs.html +--- + +# Elastic Common Schema (ECS) [ecs] + +The [Elastic Common Schema (ECS)][Elastic Common Schema (ECS)](ecs://reference/index.md)) is an open source format that defines a common set of fields to be used when storing event data like logs in Elasticsearch. + +You can use the library [ecs-logging](https://github.com/elastic/ecs-logging-ruby) which is a set of libraries that enables you to transform your application logs to structured logs that comply with the ECS format. + +Add this line to your application’s Gemfile: + +```ruby +gem 'ecs-logging' +``` + +Then execute `bundle install`. Or install from the command line yourself: + +```ruby +$ gem install ecs-logging +``` + +Then configure the client to use the logger: + +```ruby +require 'ecs_logging/logger' +require 'elasticsearch' + +logger = EcsLogging::Logger.new($stdout) +client = Elasticsearch::Client.new(logger: logger) +> client.info +{"@timestamp":"2022-07-12T05:31:18.590Z","log.level":"INFO","message":"GET http://localhost:9200/ [status:200, request:0.009s, query:n/a]","ecs.version":"1.4.0"}... +``` + +See [ECS Logging Ruby Reference](ecs-logging-ruby://reference/index.md) for more information on how to configure the logger. + diff --git a/docs/reference/esql.md b/docs/reference/esql.md new file mode 100644 index 0000000000..6fea4bcdd9 --- /dev/null +++ b/docs/reference/esql.md @@ -0,0 +1,110 @@ +--- +navigation_title: "ES|QL" +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/esql.html +--- + +# ES|QL in the Ruby client [esql] + + +This page helps you understand and use [ES|QL](docs-content://explore-analyze/query-filter/languages/esql.md) in the Ruby client. + +There are two ways to use ES|QL in the Ruby client: + +* Use the Elasticsearch [ES|QL API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) directly: This is the most flexible approach, but it’s also the most complex because you must handle results in their raw form. You can choose the precise format of results, such as JSON, CSV, or text. +* Use the Ruby ES|QL helper: The helper maps the raw response to an object that’s more readily usable by your application. + + +## ES|QL API [esql-how-to] + +The [ES|QL query API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) allows you to specify how results should be returned. You can choose a [response format](docs-content://explore-analyze/query-filter/languages/esql-rest.md#esql-rest-format) such as CSV, text, or JSON, then fine-tune it with parameters like column separators and locale. + +By default, the `query` API returns a Hash response with `columns` and `values`: + +$$$esql-query$$$ + +```ruby +query = <[ + {"name"=>"@timestamp", "type"=>"date"}, + {"name"=>"client.ip", "type"=>"ip"}, + {"name"=>"event.duration", "type"=>"long"}, + {"name"=>"message", "type"=>"keyword"}, + {"name"=>"duration_ms", "type"=>"double"} +], +"values"=>[ + ["2023-10-23T12:15:03.360Z", "172.21.2.162", 3450233, "Connected to 10.1.0.3", 3.5], + ["2023-10-23T12:27:28.948Z", "172.21.2.113", 2764889, "Connected to 10.1.0.2", 2.8], + ["2023-10-23T13:33:34.937Z", "172.21.0.5", 1232382, "Disconnected", 1.2], + ["2023-10-23T13:51:54.732Z", "172.21.3.15", 725448, "Connection error", 0.7], + ["2023-10-23T13:52:55.015Z", "172.21.3.15", 8268153, "Connection error", 8.3], + ["2023-10-23T13:53:55.832Z", "172.21.3.15", 5033755, "Connection error", 5.0], + ["2023-10-23T13:55:01.543Z", "172.21.3.15", 1756467, "Connected to 10.1.0.1", 1.8] +]} +``` + + +## ES|QL helper [esql-helper] + +The ES|QL helper in the Ruby client provides an object response from the ES|QL query API, instead of the default JSON value. + +To use the ES|QL helper, require it in your code: + +```ruby +require 'elasticsearch/helpers/esql_helper' +``` + +The helper returns an array of hashes with the columns as keys and the respective values. Using the [preceding example](#esql-query), the helper returns the following: + +```ruby +response = Elasticsearch::Helpers::ESQLHelper.query(client, query) + +puts response + +{"duration_ms"=>3.5, "message"=>"Connected to 10.1.0.3", "event.duration"=>3450233, "client.ip"=>"172.21.2.162", "@timestamp"=>"2023-10-23T12:15:03.360Z"} +{"duration_ms"=>2.8, "message"=>"Connected to 10.1.0.2", "event.duration"=>2764889, "client.ip"=>"172.21.2.113", "@timestamp"=>"2023-10-23T12:27:28.948Z"} +{"duration_ms"=>1.2, "message"=>"Disconnected", "event.duration"=>1232382, "client.ip"=>"172.21.0.5", "@timestamp"=>"2023-10-23T13:33:34.937Z"} +{"duration_ms"=>0.7, "message"=>"Connection error", "event.duration"=>725448, "client.ip"=>"172.21.3.15", "@timestamp"=>"2023-10-23T13:51:54.732Z"} +{"duration_ms"=>8.3, "message"=>"Connection error", "event.duration"=>8268153, "client.ip"=>"172.21.3.15", "@timestamp"=>"2023-10-23T13:52:55.015Z"} +``` + +Additionally, you can transform the data in the response by passing in a Hash of `column => Proc` values. You could use this for example to convert *@timestamp* into a DateTime object. Pass in a Hash to `query` as a `parser` defining a `Proc` for each value you’d like to parse: + +```ruby +require 'elasticsearch/helpers/esql_helper' + +parser = { + '@timestamp' => Proc.new { |t| DateTime.parse(t) } +} +response = Elasticsearch::Helpers::ESQLHelper.query(client, query, parser: parser) +response.first['@timestamp'] +# +``` + +You can pass in as many Procs as there are columns in the response. For example: + +```ruby +parser = { + '@timestamp' => Proc.new { |t| DateTime.parse(t) }, + 'client.ip' => Proc.new { |i| IPAddr.new(i) }, + 'event.duration' => Proc.new { |d| d.to_s } +} + +response = Elasticsearch::Helpers::ESQLHelper.query(client, query, parser: parser) + +puts response + +{"duration_ms"=>3.5, "message"=>"Connected to 10.1.0.3", "event.duration"=>"3450233", "client.ip"=>#, "@timestamp"=>#} +{"duration_ms"=>2.8, "message"=>"Connected to 10.1.0.2", "event.duration"=>"2764889", "client.ip"=>#, "@timestamp"=>#} +{"duration_ms"=>1.2, "message"=>"Disconnected", "event.duration"=>"1232382", "client.ip"=>#, "@timestamp"=>#} +{"duration_ms"=>0.7, "message"=>"Connection error", "event.duration"=>"725448", "client.ip"=>#, "@timestamp"=>#} +{"duration_ms"=>8.3, "message"=>"Connection error", "event.duration"=>"8268153", "client.ip"=>#, "@timestamp"=>#} +``` + diff --git a/docs/reference/examples.md b/docs/reference/examples.md new file mode 100644 index 0000000000..75e850cfbc --- /dev/null +++ b/docs/reference/examples.md @@ -0,0 +1,206 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/examples.html +--- + +# Examples [examples] + +Below you can find examples of how to use the most frequently called APIs with the Ruby client. + +* [Indexing a document](#ex-index) +* [Getting a document](#ex-get) +* [Updating a document](#ex-update) +* [Deleting a document](#ex-delete) +* [Bulk requests](#ex-bulk) +* [Searching for a document](#ex-search) +* [Multi search](#ex-multisearch) +* [Scrolling](#ex-scroll) +* [Reindexing](#ex-reindex) + + +## Indexing a document [ex-index] + +Let’s index a document with the following fields: `name`, `author`, `release_date`, and `page_count`: + +```ruby +body = { + name: "The Hitchhiker's Guide to the Galaxy", + author: "Douglas Adams", + release_date: "1979-10-12", + page_count: 180 +} + +client.index(index: 'books', body: body) +``` + + +## Getting a document [ex-get] + +You can get a document by ID: + +```ruby +id = 'l7LRjXgB2_ry9btNEv_V' +client.get(index: 'books', id: id) +``` + + +## Updating a document [ex-update] + +Assume you have the following document: + +```ruby +book = {"name": "Foundation", "author": "Isaac Asimov", "release_date": "1951-06-01", "page_count": 224} +``` + +You can update the document by using the following script: + +```ruby +response = client.index(index: 'books', body: book) +id = response['_id'] +client.update(index: 'books', id: id, body: { doc: { page_count: 225 } }) +``` + + +## Deleting a document [ex-delete] + +You can delete a document by ID: + +```ruby +id = 'l7LRjXgB2_ry9btNEv_V' +client.delete(index: 'books', id: id) +``` + + +## Bulk requests [ex-bulk] + +The `bulk` operation of the client supports various different formats of the payload: array of strings, header/data pairs, or the combined format where data is passed along with the header in a single item in a custom `:data` key. + +Index several documents in one request: + +```ruby +body = [ + { index: { _index: 'books', _id: '42' } }, + { name: "The Hitchhiker's Guide to the Galaxy", author: 'Douglas Adams', release_date: '1979-10-12', page_count: 180 }, + { index: { _index: 'books', _id: '43' } }, + { name: 'Snow Crash', author: 'Neal Stephenson', release_date: '1992-06-01', page_count: 470 }, + { index: { _index: 'books', _id: '44' } }, + { name: 'Starship Troopers', author: 'Robert A. Heinlein', release_date: '1959-12-01', page_count: 335 } +] +client.bulk(body: body) +``` + +Delete several documents: + +```ruby +body = [ + { delete: { _index: 'books', _id: '42' } }, + { delete: { _index: 'books', _id: '43' } }, +] +client.bulk(body: body) +``` + +As mentioned, you can perform several operations in a single request with the combined format passing data in the `:data` option: + +```ruby +body = [ + { index: { _index: 'books', _id: 45, data: { name: '1984', author: 'George Orwell', release_date: '1985-06-01', page_count: 328 } } }, + { update: { _index: 'books', _id: 43, data: { doc: { page_count: 471 } } } }, + { delete: { _index: 'books', _id: 44 } } +] +client.bulk(body: body) +``` + + +## Searching for a document [ex-search] + +This example uses the same data that is used in the [Find structure API documentation](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-text-structure-find-structure). + +First, bulk index it: + +```ruby +body = [ + { index: { _index: 'books', data: { name: 'Leviathan Wakes', author: 'James S.A. Corey', release_date: '2011-06-02', page_count: 561 } } }, + { index: { _index: 'books', data: { name: 'Hyperion', author: 'Dan Simmons', release_date: '1989-05-26', page_count: 482 } } }, + { index: { _index: 'books', data: { name: 'Dune', author: 'Frank Herbert', release_date: '1965-06-01', page_count: 604 } } }, + { index: { _index: 'books', data: { name: 'Dune Messiah', author: 'Frank Herbert', release_date: '1969-10-15', page_count: 331 } } }, + { index: { _index: 'books', data: { name: 'Children of Dune', author: 'Frank Herbert', release_date: '1976-04-21', page_count: 408 } } }, + { index: { _index: 'books', data: { name: 'God Emperor of Dune', author: 'Frank Herbert', release_date: '1981-05-28', page_count: 454 } } }, + { index: { _index: 'books', data: { name: 'Consider Phlebas', author: 'Iain M. Banks', release_date: '1987-04-23', page_count: 471 } } }, + { index: { _index: 'books', data: { name: 'Pandora\'s Star', author: 'Peter F. Hamilton', release_date: '2004-03-02', page_count: 768 } } }, + { index: { _index: 'books', data: { name: 'Revelation Space', author: 'Alastair Reynolds', release_date: '2000-03-15', page_count: 585 } } }, + { index: { _index: 'books', data: { name: 'A Fire Upon the Deep', author: 'Vernor Vinge', release_date: '1992-06-01', page_count: 613 } } }, + { index: { _index: 'books', data: { name: 'Ender\'s Game', author: 'Orson Scott Card', release_date: '1985-06-01', page_count: 324 } } }, + { index: { _index: 'books', data: { name: '1984', author: 'George Orwell', release_date: '1985-06-01', page_count: 328 } } }, + { index: { _index: 'books', data: { name: 'Fahrenheit 451', author: 'Ray Bradbury', release_date: '1953-10-15', page_count: 227 } } }, + { index: { _index: 'books', data: { name: 'Brave New World', author: 'Aldous Huxley', release_date: '1932-06-01', page_count: 268 } } }, + { index: { _index: 'books', data: { name: 'Foundation', author: 'Isaac Asimov', release_date: '1951-06-01', page_count: 224 } } }, + { index: { _index: 'books', data: { name: 'The Giver', author: 'Lois Lowry', release_date: '1993-04-26', page_count: 208 } } }, + { index: { _index: 'books', data: { name: 'Slaughterhouse-Five', author: 'Kurt Vonnegut', release_date: '1969-06-01', page_count: 275 } } }, + { index: { _index: 'books', data: { name: 'The Hitchhiker\'s Guide to the Galaxy', author: 'Douglas Adams', release_date: '1979-10-12', page_count: 180 } } }, + { index: { _index: 'books', data: { name: 'Snow Crash', author: 'Neal Stephenson', release_date: '1992-06-01', page_count: 470 } } }, + { index: { _index: 'books', data: { name: 'Neuromancer', author: 'William Gibson', release_date: '1984-07-01', page_count: 271 } } }, + { index: { _index: 'books', data: { name: 'The Handmaid\'s Tale', author: 'Margaret Atwood', release_date: '1985-06-01', page_count: 311 } } }, + { index: { _index: 'books', data: { name: 'Starship Troopers', author: 'Robert A. Heinlein', release_date: '1959-12-01', page_count: 335 } } }, + { index: { _index: 'books', data: { name: 'The Left Hand of Darkness', author: 'Ursula K. Le Guin', release_date: '1969-06-01', page_count: 304 } } }, + { index: { _index: 'books', data: { name: 'The Moon is a Harsh Mistress', author: 'Robert A. Heinlein', release_date: '1966-04-01', page_count: 288 } } } +] +client.bulk(body: body) +``` + +The `field` parameter is a common parameter, so it can be passed in directly in the following way: + +```ruby +client.search(index: 'books', q: 'dune') +``` + +You can do the same by using body request parameters: + +```ruby +client.search(index: 'books', q: 'dune', body: { fields: [{ field: 'name' }] }) +response = client.search(index: 'books', body: { size: 15 }) +response['hits']['hits'].count # => 15 +``` + + +## Multi search [ex-multisearch] + +The following example shows how to perform a multisearch API call on `books` index: + +```ruby +body = [ + {}, + {query: {range: {page_count: {gte: 100}}}}, + {}, + {query: {range: {page_count: {lte: 100}}}} +] +client.msearch(index:'books', body: body) +``` + + +## Scrolling [ex-scroll] + +Submit a search API request that includes an argument for the scroll query parameter, save the search ID, then print out the book names you found: + +```ruby +# Search request with a scroll argument: +response = client.search(index: 'books', scroll: '10m') + +# Save the scroll id: +scroll_id = response['_scroll_id'] + +# Print out the names of all the books we find: +while response['hits']['hits'].size.positive? + response = client.scroll(scroll: '5m', body: { scroll_id: scroll_id }) + puts(response['hits']['hits'].map { |r| r['_source']['name'] }) +end +``` + + +## Reindexing [ex-reindex] + +The following example shows how to reindex the `books` index into a new index called `books-reindexed`: + +```ruby +client.reindex(body: {source: { index: 'books'}, dest: {index: 'books-reindexed' } }) +``` + diff --git a/docs/reference/getting-started.md b/docs/reference/getting-started.md new file mode 100644 index 0000000000..55b6e9cb25 --- /dev/null +++ b/docs/reference/getting-started.md @@ -0,0 +1,121 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/getting-started-ruby.html + - https://www.elastic.co/guide/en/serverless/current/elasticsearch-ruby-client-getting-started.html +--- + +# Getting started [getting-started-ruby] + +This page guides you through the installation process of the Ruby client, shows you how to instantiate the client, and how to perform basic Elasticsearch operations with it. + + +### Requirements [_requirements] + +A currently maintained version of Ruby (3.0+) or JRuby (9.3+). + + +### Installation [_installation] + +To install the latest version of the client, run the following command: + +```shell +gem install elasticsearch +``` + +Refer to the [*Installation*](/reference/installation.md) page to learn more. + + +### Connecting [_connecting] + +You can connect to the Elastic Cloud using an API key and the Elasticsearch endpoint. + +```rb +client = Elasticsearch::Client.new( + cloud_id: '', + api_key: '' +) +``` + +Your Elasticsearch endpoint can be found on the **My deployment** page of your deployment: + +![Finding Elasticsearch endpoint](images/es_endpoint.jpg) + +You can generate an API key on the **Management** page under Security. + +![Create API key](images/create_api_key.png) + +For other connection options, refer to the [*Connecting*](/reference/connecting.md) section. + + +### Operations [_operations] + +Time to use Elasticsearch! This section walks you through the basic, and most important, operations of Elasticsearch. For more operations and more advanced examples, refer to the [*Examples*](/reference/examples.md) page. + + +#### Creating an index [_creating_an_index] + +This is how you create the `my_index` index: + +```rb +client.indices.create(index: 'my_index') +``` + + +#### Indexing documents [_indexing_documents] + +This is a simple way of indexing a document: + +```rb +document = { name: 'elasticsearch-ruby' } +response = client.index(index: 'my_index', body: document) +# You can get the indexed document id with: +response['_id'] +=> "PlgIDYkBWS9Ngdx5IMy-" +id = response['_id'] +``` + + +#### Getting documents [_getting_documents] + +You can get documents by using the following code: + +```rb +client.get(index: 'my_index', id: id) +``` + + +#### Searching documents [_searching_documents] + +This is how you can create a single match query with the Ruby client: + +```rb +client.search(index: 'my_index', body: { query: { match_all: {} } }) +``` + + +#### Updating documents [_updating_documents] + +This is how you can update a document, for example to add a new field: + +```rb +client.update(index: 'my_index', id: id, body: { doc: { language: 'Ruby' } }) +``` + + +#### Deleting documents [_deleting_documents] + +```rb +client.delete(index: 'my_index', id: id) +``` + + +#### Deleting an index [_deleting_an_index] + +```rb +client.indices.delete(index: 'my_index') +``` + + +## Further reading [_further_reading] + +* Use [Bulk and Scroll helpers](/reference/Helpers.md) for a more confortable experience with the APIs. diff --git a/docs/images/api_key_name.png b/docs/reference/images/api_key_name.png similarity index 100% rename from docs/images/api_key_name.png rename to docs/reference/images/api_key_name.png diff --git a/docs/images/cloud_api_key.png b/docs/reference/images/cloud_api_key.png similarity index 100% rename from docs/images/cloud_api_key.png rename to docs/reference/images/cloud_api_key.png diff --git a/docs/images/cloud_id.png b/docs/reference/images/cloud_id.png similarity index 100% rename from docs/images/cloud_id.png rename to docs/reference/images/cloud_id.png diff --git a/docs/images/create_api_key.png b/docs/reference/images/create_api_key.png similarity index 100% rename from docs/images/create_api_key.png rename to docs/reference/images/create_api_key.png diff --git a/docs/images/es_endpoint.jpg b/docs/reference/images/es_endpoint.jpg similarity index 100% rename from docs/images/es_endpoint.jpg rename to docs/reference/images/es_endpoint.jpg diff --git a/docs/reference/images/otel-waterfall-retry.png b/docs/reference/images/otel-waterfall-retry.png new file mode 100644 index 0000000000..5a64515df1 Binary files /dev/null and b/docs/reference/images/otel-waterfall-retry.png differ diff --git a/docs/reference/images/otel-waterfall-with-http.png b/docs/reference/images/otel-waterfall-with-http.png new file mode 100644 index 0000000000..7be0b080ad Binary files /dev/null and b/docs/reference/images/otel-waterfall-with-http.png differ diff --git a/docs/reference/images/otel-waterfall-without-http.png b/docs/reference/images/otel-waterfall-without-http.png new file mode 100644 index 0000000000..d3b04cc6eb Binary files /dev/null and b/docs/reference/images/otel-waterfall-without-http.png differ diff --git a/docs/reference/index.md b/docs/reference/index.md new file mode 100644 index 0000000000..09472e1c68 --- /dev/null +++ b/docs/reference/index.md @@ -0,0 +1,40 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ruby_client.html +--- + +# Ruby [ruby_client] + +The `elasticsearch` [Rubygem](http://rubygems.org/gems/elasticsearch) provides a low-level client for communicating with an {{es}} cluster, fully compatible with other official clients. + +More documentation is hosted in [Github](https://github.com/elastic/elasticsearch-ruby) and [RubyDoc](http://rubydoc.info/gems/elasticsearch). + +Refer to the [*Getting started*](/reference/getting-started.md) page for a step-by-step quick start with the Ruby client. + + +## Features [_features] + +* Pluggable logging and tracing +* Pluggable connection selection strategies (round-robin, random, custom) +* Pluggable transport implementation, customizable and extendable +* Pluggable serializer implementation +* Request retries and dead connections handling +* Node reloading (based on cluster state) on errors or on demand +* Modular API implementation +* 100% REST API coverage + + +## Transport and API [transport-api] + +The `elasticsearch` gem combines two separate Rubygems: + +* [`elastic-transport`](https://github.com/elastic/elastic-transport-ruby/) - provides an HTTP Ruby client for connecting to the {{es}} cluster. Refer to the documentation: [Transport](/reference/transport.md) +* [`elasticsearch-api`](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-api) - provides a Ruby API for the {{es}} RESTful API. + +Please consult their respective documentation for configuration options and technical details. + +Notably, the documentation and comprehensive examples for all the API methods are contained in the source, and available online at [Rubydoc](http://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Actions). + +Keep in mind, that for optimal performance, you should use an HTTP library which supports persistent ("keep-alive") HTTP connections. + diff --git a/docs/reference/installation.md b/docs/reference/installation.md new file mode 100644 index 0000000000..73048cfa0d --- /dev/null +++ b/docs/reference/installation.md @@ -0,0 +1,44 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ruby-install.html +--- + +# Installation [ruby-install] + +Install the Rubygem for the latest {{es}} version by using the following command: + +```sh +gem install elasticsearch +``` + +Or add the `elasticsearch` Ruby gem to your Gemfile: + +```ruby +gem 'elasticsearch' +``` + +You can install the Ruby gem for a specific {{es}} version by using the following command: + +```sh +gem install elasticsearch -v 7.0.0 +``` + +Or you can add a specific version of {{es}} to your Gemfile: + +```ruby +gem 'elasticsearch', '~> 7.0' +``` + + +## {{es}} and Ruby version compatibility [_es_and_ruby_version_compatibility] + +The {{es}} client is compatible with currently maintained Ruby versions. We follow Ruby’s own maintenance policy and officially support all currently maintained versions per [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/). + +Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of {{es}} without breaking. It does not mean that the client automatically supports new features of newer {{es}} versions; it is only possible after a release of a new client version. For example, a 8.12 client version won’t automatically support the new features of the 8.13 version of {{es}}, the 8.13 client version is required for that. {{es}} language clients are only backwards compatible with default distributions and without guarantees made. + +| Gem Version | | {{es}} Version | Supported | +| --- | --- | --- | --- | +| 7.x | → | 7.x | 7.17 | +| 8.x | → | 8.x | 8.x | +| main | → | main | | + diff --git a/docs/reference/integrations.md b/docs/reference/integrations.md new file mode 100644 index 0000000000..2b54bab453 --- /dev/null +++ b/docs/reference/integrations.md @@ -0,0 +1,26 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/integrations.html +--- + +# Integrations [integrations] + +The Rubygems listed on this page make it easier to operate with {{es}} by using the Ruby client. + +* [Transport](/reference/transport.md) +* [Elasticsearch API](/reference/api.md) +* [Using OpenTelemetry](/reference/opentelemetry.md) +* [Elastic Common Schema (ECS)](/reference/ecs.md) +* [ActiveModel / ActiveRecord](/reference/activemodel_activerecord.md) +* [Ruby On Rails](/reference/ruby_on_rails.md) +* [Persistence](/reference/persistence.md) +* [Elasticsearch DSL](/reference/dsl.md) + + + + + + + + + diff --git a/docs/reference/opentelemetry.md b/docs/reference/opentelemetry.md new file mode 100644 index 0000000000..9ab636dd63 --- /dev/null +++ b/docs/reference/opentelemetry.md @@ -0,0 +1,91 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/opentelemetry.html +--- + +# Using OpenTelemetry [opentelemetry] + +You can use [OpenTelemetry](https://opentelemetry.io/) to monitor the performance and behavior of your {{es}} requests through the Ruby Client. The Ruby Client comes with built-in OpenTelemetry instrumentation that emits [distributed tracing spans](docs-content://solutions/observability/apm/traces-ui.md) by default. With that, applications [instrumented with OpenTelemetry](https://opentelemetry.io/docs/instrumentation/ruby/manual/) or using the [OpenTelemetry Ruby SDK](https://opentelemetry.io/docs/instrumentation/ruby/automatic/) are inherently enriched with additional spans that contain insightful information about the execution of the {{es}} requests. + +The native instrumentation in the Ruby Client follows the [OpenTelemetry Semantic Conventions for {{es}}](https://opentelemetry.io/docs/specs/semconv/database/elasticsearch/). In particular, the instrumentation in the client covers the logical layer of {{es}} requests. A single span per request is created that is processed by the service through the Ruby Client. The following image shows a trace that records the handling of two different {{es}} requests: a `ping` request and a `search` request. + +% TO DO: Use `:class: screenshot` +![Distributed trace with Elasticsearch spans](images/otel-waterfall-without-http.png) + +Usually, OpenTelemetry auto-instrumentation modules come with instrumentation support for HTTP-level communication. In this case, in addition to the logical {{es}} client requests, spans will be captured for the physical HTTP requests emitted by the client. The following image shows a trace with both, {{es}} spans (in blue) and the corresponding HTTP-level spans (in red): + +% TO DO: Use `:class: screenshot` +![Distributed trace with Elasticsearch spans](images/otel-waterfall-with-http.png) + +Advanced Ruby Client behavior such as nodes round-robin and request retries are revealed through the combination of logical {{es}} spans and the physical HTTP spans. The following example shows a `search` request in a scenario with two nodes: + +% TO DO: Use `:class: screenshot` +![Distributed trace with Elasticsearch spans](images/otel-waterfall-retry.png) + +The first node is unavailable and results in an HTTP error, while the retry to the second node succeeds. Both HTTP requests are subsumed by the logical {{es}} request span (in blue). + + +## Setup the OpenTelemetry instrumentation [_setup_the_opentelemetry_instrumentation] + +When using the [OpenTelemetry Ruby SDK manually](https://opentelemetry.io/docs/instrumentation/ruby/manual) or using the [OpenTelemetry Ruby Auto-Instrumentations](https://opentelemetry.io/docs/instrumentation/ruby/automatic/), the Ruby Client’s OpenTelemetry instrumentation is enabled by default and uses the global OpenTelemetry SDK with the global tracer provider. You can provide a tracer provider via the Ruby Client configuration option `opentelemetry_tracer_provider` when instantiating the client. This is sometimes useful for testing or other specific use cases. + +```ruby +client = Elasticsearch::Client.new( + cloud_id: '', + api_key: '', + opentelemetry_tracer_provider: tracer_provider +) +``` + + +## Configuring the OpenTelemetry instrumentation [_configuring_the_opentelemetry_instrumentation] + +You can configure the OpenTelemetry instrumentation through Environment Variables. The following configuration options are available. + + +### Enable / Disable the OpenTelemetry instrumentation [opentelemetry-config-enable] + +With this configuration option you can enable (default) or disable the built-in OpenTelemetry instrumentation. + +**Default:** `true` + +| | | +| --- | --- | +| Environment Variable | `OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_ENABLED` | + + +### Capture search request bodies [_capture_search_request_bodies] + +Per default, the built-in OpenTelemetry instrumentation does not capture request bodies due to data privacy considerations. You can use this option to enable capturing of search queries from the request bodies of {{es}} search requests in case you wish to gather this information regardless. The options are to capture the raw search query, sanitize the query with a default list of sensitive keys, or not capture it at all. + +**Default:** `omit` + +**Valid Options:** `omit`, `sanitize`, `raw` + +| | | +| --- | --- | +| Environment Variable | `OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY` | + + +### Sanitize the {{es}} search request body [_sanitize_the_es_search_request_body] + +You can configure the list of keys whose values are redacted when the search query is captured. Values must be comma-separated. Note in v8.3.0 and v8.3.1, the environment variable `OTEL_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY` was available but is now deprecated in favor of the environment variable including `RUBY`. + +**Default:** `nil` + +| | | +| --- | --- | +| Environment Variable | `OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_SEARCH_QUERY_SANITIZE_KEYS` | + +Example: + +```bash +OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_SEARCH_QUERY_SANITIZE_KEYS='sensitive-key,other-sensitive-key' +``` + + +## Overhead [_overhead] + +The OpenTelemetry instrumentation (as any other monitoring approach) may come with a slight overhead on CPU, memory, and/or latency. The overhead may only occur when the instrumentation is enabled (default) and an OpenTelemetry SDK is active in the target application. When the instrumentation is disabled or no OpenTelemetry SDK is active within the target application, monitoring overhead is not expected when using the client. + +Even in cases where the instrumentation is enabled and is actively used (by an OpenTelemetry SDK), the overhead is minimal and negligible in the vast majority of cases. In edge cases where there is a noticeable overhead, the [instrumentation can be explicitly disabled](#opentelemetry-config-enable) to eliminate any potential impact on performance. diff --git a/docs/reference/persistence.md b/docs/reference/persistence.md new file mode 100644 index 0000000000..2bb497a96b --- /dev/null +++ b/docs/reference/persistence.md @@ -0,0 +1,100 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/persistence.html +--- + +# Persistence [persistence] + +The `elasticsearch-persistence` [Rubygem](http://rubygems.org/gems/elasticsearch-persistence) provides persistence layer for Ruby domain objects. + +It supports the repository design patterns. Versions before 6.0 also supported the *active record* design pattern. + + +## Repository [_repository] + +The `Elasticsearch::Persistence::Repository` module provides an implementation of the repository pattern and allows to save, delete, find and search objects stored in {{es}}, as well as configure mappings and settings for the index. + + +### Features [_features_4] + +* Access to the {{es}} client +* Setting the index name, document type, and object class for deserialization +* Composing mappings and settings for the index +* Creating, deleting or refreshing the index +* Finding or searching for documents +* Providing access both to domain objects and hits for search results +* Providing access to the {{es}} response for search results +* Defining the methods for serialization and deserialization + + +### Usage [_usage_2] + +Let’s have a simple plain old Ruby object (PORO): + +```ruby +class Note + attr_reader :attributes + + def initialize(attributes={}) + @attributes = attributes + end + + def to_hash + @attributes + end +end +``` + +Create a default, "dumb" repository, as a first step: + +```ruby +require 'elasticsearch/persistence' +class MyRepository; include Elasticsearch::Persistence::Repository; end +repository = MyRepository.new +``` + +Save a `Note` instance into the repository: + +```ruby +note = Note.new id: 1, text: 'Test' + +repository.save(note) +# PUT http://localhost:9200/repository/_doc/1 [status:201, request:0.210s, query:n/a] +# > {"id":1,"text":"Test"} +# < {"_index":"repository","_type":"note","_id":"1","_version":1,"created":true} +``` + +Find it: + +```ruby +n = repository.find(1) +# GET http://localhost:9200/repository/_doc/1 [status:200, request:0.003s, query:n/a] +# < {"_index":"repository","_type":"note","_id":"1","_version":2,"found":true, "_source" : {"id":1,"text":"Test"}} +=> 1, "text"=>"Test"}> +``` + +Search for it: + +```ruby +repository.search(query: { match: { text: 'test' } }).first +# GET http://localhost:9200/repository/_search [status:200, request:0.005s, query:0.002s] +# > {"query":{"match":{"text":"test"}}} +# < {"took":2, ... "hits":{"total":1, ... "hits":[{ ... "_source" : {"id":1,"text":"Test"}}]}} +=> 1, "text"=>"Test"}> +``` + +Delete it: + +```ruby +repository.delete(note) +# DELETE http://localhost:9200/repository/_doc/1 [status:200, request:0.014s, query:n/a] +# < {"found":true,"_index":"repository","_type":"note","_id":"1","_version":3} +=> {"found"=>true, "_index"=>"repository", "_type"=>"note", "_id"=>"1", "_version"=>2} +``` + +The repository module provides a number of features and facilities to configure and customize the behaviour, as well as support for extending your own, custom repository class. + +Please refer to the [documentation](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence#the-repository-pattern) for more information. + +Also, check out the [example application](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence#example-application) which demonstrates the usage patterns of the *repository* approach to persistence. + diff --git a/docs/reference/ruby_on_rails.md b/docs/reference/ruby_on_rails.md new file mode 100644 index 0000000000..500fcbb762 --- /dev/null +++ b/docs/reference/ruby_on_rails.md @@ -0,0 +1,23 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ruby_on_rails.html +--- + +# Ruby On Rails [ruby_on_rails] + +The `elasticsearch-rails` [Rubygem](http://rubygems.org/gems/elasticsearch-rails) provides features suitable for Ruby on Rails applications. + + +## Features [_features_3] + +* Rake tasks for importing data from application models +* Integration with Rails' instrumentation framework +* Templates for generating example Rails application + + +## Example applications [_example_applications] + +You can generate a fully working example Ruby on Rails application with templates provides. + +Please refer to the [documentation](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails) for more information. + diff --git a/docs/reference/toc.yml b/docs/reference/toc.yml new file mode 100644 index 0000000000..203353a878 --- /dev/null +++ b/docs/reference/toc.yml @@ -0,0 +1,25 @@ +toc: + - file: index.md + - file: getting-started.md + - file: installation.md + - file: connecting.md + - file: configuration.md + children: + - file: basic-config.md + - file: advanced-config.md + - file: integrations.md + children: + - file: transport.md + - file: api.md + - file: opentelemetry.md + - file: ecs.md + - file: activemodel_activerecord.md + - file: ruby_on_rails.md + - file: persistence.md + - file: dsl.md + - file: examples.md + - file: client-helpers.md + children: + - file: Helpers.md + - file: esql.md + - file: troubleshoot.md \ No newline at end of file diff --git a/docs/reference/transport.md b/docs/reference/transport.md new file mode 100644 index 0000000000..a4d8721267 --- /dev/null +++ b/docs/reference/transport.md @@ -0,0 +1,271 @@ +--- +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/transport.html +--- + +# Transport [transport] + +The `elastic-transport` library provides a low-level Ruby client for connecting to an {{es}} cluster. It powers the [Elasticsearch Ruby](/reference/index.md) client. + +When available, it handles connecting to multiple nodes in the cluster, rotating across connections, logging and tracing requests and responses, maintaining failed connections, discovering nodes in the cluster, and provides an abstraction for data serialization and transport. + +It does not handle calling the {{es}} APIs. + +This library uses [Faraday](https://github.com/lostisland/faraday) by default as the HTTP transport implementation. We test it with Faraday versions 1.x and 2.x. + +For optimal performance, use a HTTP library which supports persistent ("keep-alive") connections, such as [patron](https://github.com/toland/patron) or [Typhoeus](https://github.com/typhoeus/typhoeus). Require the library (`require 'patron'`) in your code for Faraday 1.x or the adapter (`require 'faraday/patron'`) for Faraday 2.x, and it will be automatically used. + +Currently these libraries are supported: + +* [Patron](https://github.com/toland/patron) +* [Typhoeus](https://github.com/typhoeus/typhoeus) +* [HTTPClient](https://rubygems.org/gems/httpclient) +* [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent) +* [Excon](https://github.com/excon/faraday-excon) +* [Async::HTTP](https://github.com/socketry/async-http-faraday) + +::::{note} +If using [Typhoeus](https://github.com/typhoeus/typhoeus), v1.4.0 or up is needed, since older versions are not compatible with Faraday 1.0. +:::: + + +You can customize Faraday and implement your own HTTP transport. For detailed information, see the example configurations and more information [below](#transport-implementations). + +Features overview: + +* Pluggable logging and tracing +* Pluggable connection selection strategies (round-robin, random, custom) +* Pluggable transport implementation, customizable and extendable +* Pluggable serializer implementation +* Request retries and dead connections handling +* Node reloading (based on cluster state) on errors or on demand + +Refer to [Advanced Configuration](/reference/advanced-config.md) to read about more configuration options. + + +## Installation [transport-install] + +Install the package from [Rubygems](https://rubygems.org/): + +```bash +gem install elastic-transport +``` + +To use an unreleased version, either add it to your `Gemfile` for [Bundler](http://gembundler.com/): + +```bash +gem 'elastic-transport', git: 'git@github.com:elastic/elastic-transport-ruby.git' +``` + +or install it from a source code checkout: + +```bash +git clone https://github.com/elastic/elastic-transport-ruby.git +cd elastic-transport +bundle install +rake install +``` + + +## Example usage [transport-example-usage] + +In the simplest form, connect to {{es}} running on [http://localhost:9200](http://localhost:9200) without any configuration: + +```rb +require 'elastic/transport' + +client = Elastic::Transport::Client.new +response = client.perform_request('GET', '_cluster/health') +# => # +``` + +Documentation is included as RDoc annotations in the source code and available online at [RubyDoc](http://rubydoc.info/gems/elastic-transport). + + +## Transport implementations [transport-implementations] + +By default, the client uses the [Faraday](https://rubygems.org/gems/faraday) HTTP library as a transport implementation. + +The Client auto-detects and uses an *adapter* for *Faraday* based on gems loaded in your code, preferring HTTP clients with support for persistent connections. Faraday 2 changed the way adapters are used ([read more here](https://github.com/lostisland/faraday/blob/main/UPGRADING.md#adapters-have-moved)). If you’re using Faraday 1.x, you can require the HTTP library. To use the [*Patron*](https://github.com/toland/patron) HTTP, for example, require it: + +To use the [Patron](https://github.com/toland/patron) HTTP, for example, require it: + +```rb +require 'patron' +``` + +If you’re using Faraday 2.x, you need to add the corresponding adapter gem to your Gemfile and require it after you require `faraday`: + +```rb +# Gemfile +gem 'faraday-patron' + +# Code +require 'faraday' +require 'faraday/patron' +``` + +Then, create a new client, and the Patron gem will be used as the "driver": + +```rb +client = Elastic::Transport::Client.new + +client.transport.connections.first.connection.builder.adapter +# => Faraday::Adapter::Patron + +10.times do + client.nodes.stats(metric: 'http')['nodes'].values.each do |n| + puts "#{n['name']} : #{n['http']['total_opened']}" + end +end + +# => Stiletoo : 24 +# => Stiletoo : 24 +# => Stiletoo : 24 +# => ... +``` + +To use a specific adapter for Faraday, pass it as the `adapter` argument: + +```rb +client = Elastic::Client.new(adapter: :net_http_persistent) + +client.transport.connections.first.connection.builder.handlers +# => [Faraday::Adapter::NetHttpPersistent] +``` + +If you see this error: + +```rb +Faraday::Error: :net_http_persistent is not registered on Faraday::Adapter +``` + +When you’re using Faraday 2, you need to require the adapter before instantiating the client: + +```rb +> client = Elasticsearch::Client.new(adapter: :net_http_persistent) +Faraday::Error: :net_http_persistent is not registered on Faraday::Adapter +> require 'faraday/net_http_persistent' +=> true +> client = Elasticsearch::Client.new(adapter: :net_http_persistent) +=> # 'yaml' }, + ssl: { verify: false } + } +) +``` + +To configure the Faraday instance directly, use a block: + +```rb +require 'patron' + +client = Elastic::Client.new(host: 'localhost', port: '9200') do |f| + f.response :logger + f.adapter :patron +end +``` + +You can use any standard Faraday middleware and plugins in the configuration block. + +You can also initialize the transport class yourself, and pass it to the client constructor as the `transport` argument. The Elasticsearch client accepts `:transport` parameter when initializing a client. So you can pass in a transport you’ve initialized with the following options: + +```rb +require 'patron' + +transport_configuration = lambda do |f| + f.response :logger + f.adapter :patron +end + +transport = Elastic::Transport::Transport::HTTP::Faraday.new( + hosts: [ { host: 'localhost', port: '9200' } ], + &transport_configuration +) + +# Pass the transport to the client +# +client = Elastic::Client.new(transport: transport) +``` + +Instead of passing the transport to the constructor, you can inject it at run time: + +```rb +# Set up the transport +# +faraday_configuration = lambda do |f| + f.instance_variable_set :@ssl, { verify: false } + f.adapter :excon +end + +faraday_client = Elastic::Transport::Transport::HTTP::Faraday.new( + hosts: [ + { + host: 'my-protected-host', + port: '443', + user: 'USERNAME', + password: 'PASSWORD', + scheme: 'https' + } + ], + &faraday_configuration +) + +# Create a default client +# +client = Elastic::Client.new + +# Inject the transport to the client +# +client.transport = faraday_client +``` + +You can also use a bundled [Curb](https://rubygems.org/gems/curb) based transport implementation: + +```rb +require 'curb' +require 'elastic/transport/transport/http/curb' + +client = Elastic::Client.new(transport_class: Elastic::Transport::Transport::HTTP::Curb) + +client.transport.connections.first.connection +# => # +``` + +It’s possible to customize the Curb instance by passing a block to the constructor as well (in this case, as an inline block): + +```rb +transport = Elastic::Transport::Transport::HTTP::Curb.new( + hosts: [ { host: 'localhost', port: '9200' } ], + & lambda { |c| c.verbose = true } +) + +client = Elastic::Client.new(transport: transport) +``` + +You can write your own transport implementation by including the {Elastic::Transport::Transport::Base} module, implementing the required contract, and passing it to the client as the `transport_class` parameter – or by injecting it directly. + + +## Transport architecture [transport-architecture] + +* `Elastic::Transport::Client` is composed of `Elastic::Transport::Transport`. +* `Elastic::Transport::Transport` is composed of `Elastic::Transport::Transport::Connections`, and an instance of logger, tracer, serializer and sniffer. +* Logger and tracer can be any object conforming to Ruby logging interface, for example, an instance of [`Logger`](https://ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html), [log4r](https://rubygems.org/gems/log4r), [logging](https://github.com/TwP/logging/), and so on. +* The `Elastic::Transport::Transport::Serializer::Base` implementations handle converting data for {{es}} (for example, to JSON). You can implement your own serializer. +* `Elastic::Transport::Transport::Sniffer` allows to discover nodes in the cluster and use them as connections. +* `Elastic::Transport::Transport::Connections::Collection` is composed of `Elastic::Transport::Transport::Connections::Connection` instances and a selector instance. +* `Elastic::Transport::Transport::Connections::Connection` contains the connection attributes such as hostname and port, as well as the concrete persistent "session" connected to a specific node. +* The `Elastic::Transport::Transport::Connections::Selector::Base` implementations allow to choose connections from the pool, for example, in a round-robin or random fashion. You can implement your own selector strategy. +* The `Elastic::Transport::Transport::Response` object wraps the Elasticsearch JSON response. It provides `body`, `status`, and `headers` methods but you can treat it as a hash and access the keys directly. + diff --git a/docs/reference/troubleshoot.md b/docs/reference/troubleshoot.md new file mode 100644 index 0000000000..87bc4bfd12 --- /dev/null +++ b/docs/reference/troubleshoot.md @@ -0,0 +1,74 @@ +--- +navigation_title: Troubleshoot +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/troubleshooting.html +--- + +# Troubleshoot: {{es}} Ruby client [troubleshooting] + +Use the information in this section to troubleshoot common problems and find answers for frequently asked questions. + + +## Logging [ruby-ts-logging] + +The client provides several options for logging that can help when things go wrong. Check out the extensive documentation on [Logging](advanced-config.md#logging). + +If you are having trouble sending a request to {{es}} with the client, we suggest enabling `tracing` on the client and testing the cURL command that appears in your terminal: + +```rb +client = Elasticsearch::Client.new(trace: true) +client.info +curl -X GET -H 'x-elastic-client-meta: es=8.9.0,rb=3.2.2,t=8.2.1,fd=2.7.4,nh=0.3.2, User-Agent: elastic-t +ransport-ruby/8.2.1 (RUBY_VERSION: 3.2.2; linux x86_64; Faraday v2.7.4), Content-Type: application/json' 'http://localhost:9200//?pretty' +``` + +Testing the cURL command can help find out if there’s a connection issue or if the issue is in the client code. + + +## Troubleshooting connection issues [ruby-ts-connection] + +When working with multiple hosts, you might want to enable the `retry_on_failure` or `retry_on_status` options to perform a failed request on another node (refer to [Retrying on Failures](advanced-config.md#retry-failures)). + +For optimal performance, use a HTTP library which supports persistent ("keep-alive") connections, such as [patron](https://github.com/toland/patron) or [Typhoeus](https://github.com/typhoeus/typhoeus). Require the library (`require 'patron'`) in your code for Faraday 1.x or the adapter (`require 'faraday/patron'`) for Faraday 2.x, and it will be automatically used. + + +## Adapter is not registered on Faraday [ruby-ts-adapter] + +If you see a message like: + +``` +:adapter is not registered on Faraday::Adapter (Faraday::Error) +``` + +Then you might need to include the adapter library in your Gemfile and require it. You might get this error when migrating from Faraday v1 to Faraday v2. The main change when using Faraday v2 is all adapters, except for the default `net_http` one, have been moved out into separate gems. This means if you’re not using the default adapter and you migrate to Faraday v2, you’ll need to add the adapter gems to your Gemfile. + +These are the gems required for the different adapters with Faraday 2, instead of the libraries on which they were based: + +```ruby +# HTTPCLient +gem 'faraday-httpclient' + +# NetHTTPPersistent +gem 'faraday-net_http_persistent' + +# Patron +gem 'faraday-patron' + +# Typhoeus +gem 'faraday-typhoeus' +``` + +Migrating to Faraday 2 solves the issue as long as the adapter is included (unless you’re using the default one `net-http`). Alternatively, you can lock the version of Faraday in your project to 1.x: `gem 'faraday', '~> 1'` + +::::{important} +Migrating to Faraday v2 requires at least Ruby `2.6`. Faraday v1 requires `2.4`. +:::: + + + +## More Help [_more_help] + +If you need more help, visit the [Elastic community forums](https://discuss.elastic.co/) and get answers from the experts in the community, including people from Elastic. + +If you find a bug, have feedback, or find any other issue using the client, [submit an issue](https://github.com/elastic/elasticsearch-ruby/issues/new/choose) on GitHub. + diff --git a/docs/release-notes/breaking-changes.md b/docs/release-notes/breaking-changes.md new file mode 100644 index 0000000000..eea940aa58 --- /dev/null +++ b/docs/release-notes/breaking-changes.md @@ -0,0 +1,41 @@ +--- +navigation_title: "Breaking changes" +--- + +# Elasticsearch Ruby Client breaking changes [elasticsearch-ruby-client-breaking-changes] +Breaking changes can impact your Elastic applications, potentially disrupting normal operations. Before you upgrade, carefully review the Elasticsearch Ruby Client breaking changes and take the necessary steps to mitigate any issues. To learn how to upgrade, check [Upgrade](docs-content://deploy-manage/upgrade.md). + +% ## Next version [elasticsearch-ruby-client-nextversion-breaking-changes] + +% ::::{dropdown} Title of breaking change +% Description of the breaking change. +% For more information, check [PR #](PR link). +% **Impact**
Impact of the breaking change. +% **Action**
Steps for mitigating deprecation impact. +% :::: + +## 9.0.0 [elasticsearch-ruby-client-900-breaking-changes] + +### Scroll APIs need to send scroll_id in request body + +Sending the `scroll_id` as a parameter has been deprecated since version 7.0.0. It needs to be specified in the request body for `clear_scroll` and `scroll`. + +**Impact**
+ +Client code using `clear_scroll` or `scroll` APIs and the deprecated `scroll_id` as a parameter needs to be updated. + +**Action**
+ +If you are using the `clear_scroll` or `scroll` APIs, and sending the `scroll_id` as a parameter, you need to update your code to send the `scroll_id` as part of the request body: +```ruby +# Before: +client.clear_scroll(scroll_id: scroll_id) +# Now: +client.clear_scroll(body: { scroll_id: scroll_id }) + +# Before: +client.scroll(scroll_id: scroll_id) +# Now: +client.scroll(body: { scroll_id: scroll_id }) +``` +% :::: diff --git a/docs/release-notes/deprecations.md b/docs/release-notes/deprecations.md new file mode 100644 index 0000000000..f1574b5278 --- /dev/null +++ b/docs/release-notes/deprecations.md @@ -0,0 +1,30 @@ +--- +navigation_title: "Deprecations" +--- + +# Elasticsearch Ruby Client deprecations [elasticsearch-ruby-client-deprecations] +Over time, certain Elastic functionality becomes outdated and is replaced or removed. To help with the transition, Elastic deprecates functionality for a period before removal, giving you time to update your applications. + +Review the deprecated functionality for Elasticsearch Ruby Client. While deprecations have no immediate impact, we strongly encourage you update your implementation after you upgrade. To learn how to upgrade, check out [Upgrade](docs-content://deploy-manage/upgrade.md). + +## 9.0.0 [elasticsearch-ruby-client-900-deprecations] + +_No deprecations_ + +% ## Next version [elasticsearch-ruby-client-versionnext-deprecations] + +% ::::{dropdown} Deprecation title +% Description of the deprecation. +% For more information, check [PR #](PR link). +% **Impact**
Impact of deprecation. +% **Action**
Steps for mitigating deprecation impact. +% :::: + +% ## 9.0.0 [elasticsearch-ruby-client-900-deprecations] + +% ::::{dropdown} Deprecation title +% Description of the deprecation. +% For more information, check [PR #](PR link). +% **Impact**
Impact of deprecation. +% **Action**
Steps for mitigating deprecation impact. +% :::: diff --git a/docs/release-notes/index.md b/docs/release-notes/index.md new file mode 100644 index 0000000000..8e2e8b53c1 --- /dev/null +++ b/docs/release-notes/index.md @@ -0,0 +1,56 @@ +--- +navigation_title: "Elasticsearch Ruby Client" +mapped_pages: + - https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/release_notes.html +--- + +# Elasticsearch Ruby Client release notes [elasticsearch-ruby-client-release-notes] + +Review the changes, fixes, and more in each version of Elasticsearch Ruby Client. + +To check for security updates, go to [Security announcements for the Elastic stack](https://discuss.elastic.co/c/announcements/security-announcements/31). + +% Release notes include only features, enhancements, and fixes. Add breaking changes, deprecations, and known issues to the applicable release notes sections. + +% ## version.next [elasticsearch-ruby-client-next-release-notes] + +% ### Features and enhancements [elasticsearch-ruby-client-next-features-enhancements] +% * + +% ### Fixes [elasticsearch-ruby-client-next-fixes] +% * + +## 9.0.0 [elasticsearch-ruby-client-900-release-notes] + +### Features and enhancements [elasticsearch-ruby-client-900-features-enhancements] + +Ruby 3.2 and up are tested and supported for 9.0. Older versions of Ruby have reached their end of life. We follow Ruby’s own maintenance policy and officially support all currently maintained versions per [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/). The required Ruby version is set to `2.6` to keep compatiblity wit JRuby 9.3. However, we only test the code against currently supported Ruby versions. + +#### Gem + +The size of both `elasticsearch` and `elasticsearch-api` gems is smaller than in previous versions. Some unnecessary files that were being included in the gem have now been removed. There has also been a lot of old code cleanup for the `9.x` branch. + +#### Elasticsearch Serverless + +With the release of `9.0`, the [Elasticsearch Serverless](https://github.com/elastic/elasticsearch-serverless-ruby) client has been discontinued. You can use this client to build your Elasticsearch Serverless Ruby applications. The Elasticsearch Serverless API is fully supported. The CI build for Elasticsearch Ruby runs tests to ensure compatibility with Elasticsearch Serverless. + +#### Elasticsearch API + +* The source code is now generated from [`elasticsearch-specification`](https://github.com/elastic/elasticsearch-specification/), so the API documentation is much more detailed and extensive. The value `Elasticsearch::ES_SPECIFICATION_COMMIT` is updated with the commit hash of elasticsearch-specification in which the code is based every time it's generated. +* The API code has been updated for compatibility with Elasticsearch API v 9.0. +* `indices.get_field_mapping` - `:fields` is a required parameter. +* `knn_search` - This API has been removed. It was only ever experimental and was deprecated in v`8.4`. It isn't supported in 9.0, and only works when the header `compatible-with=8` is set. The search API should be used for all knn queries. +* The functions in `utils.rb` that had names starting with double underscore have been renamed to remove these (e.g. `__listify` to `listify`). +* **Namespaces clean up**: The API namespaces are now generated dynamically based on the elasticsearch-specification. As such, some deprecated namespace files have been removed from the codebase: + * The `rollup` namespace was removed. The rollup feature was never GA-ed, it has been deprecated since `8.11.0` in favor of downsampling. + * The `data_frame_deprecated`, `remote` namespace files have been removed, no APIs were available. + * The `shutdown` namespace was removed. It is designed for indirect use by ECE/ESS and ECK. Direct use is not supported. + +##### Testing + +The gem `elasticsearch-api` migrated away from the Elasticsearch REST API tests and test runner in CI. We now run the [Elasticsearch Client tests](https://github.com/elastic/elasticsearch-clients-tests/) with the [Elasticsearch Tests Runner](https://github.com/elastic/es-test-runner-ruby). This gives us more control on what we're testing and makes the Buildkite build way faster in Pull Requests and scheduled builds. + +### Fixes [elasticsearch-ruby-client-900-fixes] + +* Some old rake tasks that were not being used have been removed. The rest were streamlined, the `es` namespace has been streamlined to make it easier to run Elasticsearch with Docker during development. The `docker` task namespace was merged into `es`. +* Elasticsearch's REST API Spec tests can still be ran with `rake test:deprecated:rest_api` and setting the corresponding value for the environment variable `TEST_SUITE` ('platinum' or 'free'). diff --git a/docs/release-notes/known-issues.md b/docs/release-notes/known-issues.md new file mode 100644 index 0000000000..d6f7517cfd --- /dev/null +++ b/docs/release-notes/known-issues.md @@ -0,0 +1,24 @@ +--- +navigation_title: "Known issues" + +--- + +# Elasticsearch Ruby Client known issues [elasticsearch-ruby-client-known-issues] + +## 9.0.0 + +_No known issues_ + +% Use the following template to add entries to this page. + +% :::{dropdown} Title of known issue +% **Details** +% On [Month/Day/Year], a known issue was discovered that [description of known issue]. + +% **Workaround** +% Workaround description. + +% **Resolved** +% On [Month/Day/Year], this issue was resolved. + +% ::: diff --git a/docs/release-notes/toc.yml b/docs/release-notes/toc.yml new file mode 100644 index 0000000000..a410067947 --- /dev/null +++ b/docs/release-notes/toc.yml @@ -0,0 +1,5 @@ +toc: + - file: index.md + - file: known-issues.md + - file: breaking-changes.md + - file: deprecations.md \ No newline at end of file diff --git a/docs/release_notes/70.asciidoc b/docs/release_notes/70.asciidoc deleted file mode 100644 index d620366ed9..0000000000 --- a/docs/release_notes/70.asciidoc +++ /dev/null @@ -1,195 +0,0 @@ -[[release_notes_70]] -=== 7.0 Release notes - -This version contains the following changes: - -* Added `elastic_ruby_console` executable. It opens a console with the elasticsearch gems you have installed required. -* Added macro benchmarking framework, available when developing. Use `rake -T` to view all available benchmarking tasks. - - -[discrete] -==== Client - -* Fixed failing integration test -* Updated the Manticore development dependency -* Fixed a failing Manticore unit test -* Removed "turn" and switched the tests to Minitest -* Fixed integration tests for Patron -* Allow passing request headers in `perform_request` -* Added integration test for passing request headers in `perform_request` -* Added, that request headers are printed in trace output, if set -* Fix typos in elasticsearch-transport/README.md -* Assert that connection count is at least previous count when reloaded -* Adjust test for change in default number of shards on ES 7 -* Abstract logging functionality into a Loggable Module (#556) -* Convert client integration tests to rspec -* Add flexible configuration in spec helper -* Use helper methods in spec_helper -* Remove minitest client integration tests in favor of rspec test -* Convert tests to rspec and refactor client -* minor changes to the client specs -* Use pry-nav in development for JRuby -* Keep arguments variable name for now -* Skip round-robin test for now -* Mark test as pending until there is a better way to detect rotating nodes -* Remove client unit test in favor of rspec test -* Comment-out round-robin test as it occasionally passes and pending is ineffective -* Document the default host and port constant -* Add documentation to spec_helper methods -* Redacted password if host info is printed in error message -* Adds tests for not including password in logged error message -* The redacted string change will be in 6.1.1 -* Add more tests for different ways to specify client host argument -* Do not duplicate connections in connection pool after rebuild (#591) -* Ensure that the spec rake task is run as part of integration tests -* Use constant to define Elasticsearch hosts and avoid yellow status when number of nodes is 1 -* Update handling of publish_address in _nodes/http response -* Add another test for hostname/ipv6:port format - - -[discrete] -==== API - -* Added the `wait_for_active_shards` parameter to the "Indices Open" API -* Added the "Indices Split" API -* Added the `wait_for_no_initializing_shards` argument to the "Cluster Health" API -* Added the "Cluster Remote Info" API -* Remove the dependency on "turn" -* Clear cluster transient settings in test setups -* Use `YAML.load_documents` in the REST tests runner -* Removed pinning dependency for Minitest -* Replaced the testing framework from Test::Unit to Minites and improved test output -* Added, that trace logs are printed when the `TRACE` environment variable is set -* Removed the "turn" dependency from generated test_helper.rb -* Update the "Delete By Query" API to support :slices -* Speed up `Elasticsearch::API::Utils.__listify` -* Speed up `Elasticsearch::API::Utils.__pathify` -* Use "String#strip" and "String.empty?" in `Utils.__pathify` -* Updated the inline documentation for using scripts in the "Update" API -* Updated the "Scroll" API inline example with passing the scroll ID in the body -* Marked the `percolate` method as deprecated and added an example for current percolator -* Fixed, that `Utils.__report_unsupported_parameters` and `Utils.__report_unsupported_method` use `Kernel.warn` so they can be suppressed -* Fixed the "greedy" regex in the `Utils.__rescue_from_not_found` method -* Fixed the incorrect `create` method -* Allow passing headers in `perform_request` -* Set application/x-ndjson content type on Bulk and Msearch requests -* Update the Reindex API to support :slices -* Fixed and improved the YAML tests runner -* Added the `include_type_name` parameter to APIs -* Fixed the helper for unit tests -* Removed the requirement for passing the `type` parameter to APIs -* Removed dead code from the YAML tests runner -* Fixed the `api:code:generate` Thor task -* Add copy_settings as valid param to split API -* Port api/actions tests to rspec (#543) -* Update tests to not require type -* Account for escape_utils not being available for JRuby -* Add nodes/reload_secure_settings endpoint support (#546) -* Add new params for search and msearch API -* Retrieve stashed variable if referenced in test -* Convert cat API tests to rspec -* Convert cluster API tests to rspec -* Convert indices tests to rspec -* Fix documentation of #indices.analyze -* Avoid instantiating an array of valid params for each request, each time it is called (#550) -* Add headers to custom client documentation (#527) -* Fix typos in README -* Minor update to scroll documentation example -* Convert snapshot, ingest, tasks, nodes api tests to rspec -* Update source_includes and source_excludes params names for mget -* Update source_includes and source_excludes params names for get, search, bulk, explain -* Update source_includes and source_excludes params names for get_source -* Mark _search endpoint as deprecated -* Link to 6.0 documentation explicitly for _suggest deprecation -* Update documentation for msearch -* Update documentation for scroll_id to be in body of scroll endpoint -* Remove reference to deprecated format option for _analyze endpoint -* Correct endpoints used for get and put search template -* Fix minor typo -* Note that a non-empty body argument is required for the bulk api -* Add note about empty body in yard documentation -* Support if_primary_term param on index API -* Delete test2 template in between tests in case a test is not cleanup up properly -* Support ignore_throttled option on search API -* Updates for types removal changes -* Add missing update param -* Add missing params to methods -* Support if_primary_term param for delete -* Delete an index and index template not cleaned up after in rest api tests -* Update supported params for cat API endpoints -* Update supported params for cluster API endpoints -* Update supported params for indices API endpoints -* Update supported params for ingest API endpoints -* Update supported params for nodes API endpoints -* Update supported params for snapshot API endpoints -* Update missed node API endpoints -* Update missed tasks API endpoints -* Update top-level api endpoints -* Adjust specs and code after test failures -* Fix accidental overwrite of index code -* Add missing param in cat/thread_pool -* The type argument is not required in the index method -* Delete 'nomatch' template to account for lack of test cleanup -* Ensure that the :index param is supported for cat.segments -* Ensure that the :name param is passed to the templates API - -[discrete] -==== DSL - -* Add inner_hits option support for has_parent query -* Add inner_hits option support for has_child query -* Add inner_hits option support for has_parent filter -* Add inner_hits option support for has_child filter -* adds query support for nested queries in filter context (#531) -* Convert aggregations/pipeline tests to rspec (#564) -* Convert aggregations tests to rspec (#566) -* Convert filters tests to rspec (#567) -* Fix bug in applying no_match_filter to indices filter -* Update test for current elasticsearch version -* Fix integration tests for join field syntax -* Update agg scripted metric test for deprecation in ES issue #29328 -* Fix script in update for #29328 -* minor: fix spacing -* Convert queries tests to rspec (#569) -* Add inner_hits test after cherry-picking rspec conversion -* Remove tests already converted to rspec -* spec directory structure should mirror code directory structure -* Support query_string type option -* Ensure that filters are registered when called on bool queries (#609) -* Don't specify a type when creating mappings in tests - - -[discrete] -==== X-Pack - -* Embedded the source code for the `elasticsearch-xpack` Rubygem -* Fixed the `setup` for YAML integration tests -* Added missing X-Pack APIs -* Improved the YAML integration test runner -* Updated the Rakefile for running integration tests -* Added, that password for Elasticsearch is generated -* Fixed the Watcher example -* Updated the README -* Added gitignore for the `elasticsearch-xpack` Rubygem -* Add ruby-prof as a development dependency -* Handle multiple roles passed to get_role_mapping -* Minor updates to xpack api methods (#586) -* Support freeze and unfreeze APIs -* Rewrite xpack rest api yaml test handler (#585) -* Updates to take into account SSL settings -* Fix mistake in testing version range so test can be skipped -* Support set_upgrade_mode machine learning API -* Support typed_keys and rest_total_hits_as_int params for rollup_search -* Improve string output for xpack rest api tests -* Fix logic in version checking -* Support if_seq_no and if_primary_term in put_watch -* Don't test execute_watch/60_http_input because of possible Docker issue -* Support api key methods -* Fix minor typo in test description -* Fix issue with replacing argument value with an Integer value -* Support transform_and_set in yaml tests -* Skip two more tests -* Run security tests against elasticsearch 7.0.0-rc2 -* Account for error when forecast_id is not provided and legacy path is used -* Blacklist specific tests, not the whole file -* Fix version check for skipping test \ No newline at end of file diff --git a/docs/release_notes/710.asciidoc b/docs/release_notes/710.asciidoc deleted file mode 100644 index 9751bf2026..0000000000 --- a/docs/release_notes/710.asciidoc +++ /dev/null @@ -1,62 +0,0 @@ -[[release_notes_710]] -=== 7.10 Release notes - -[discrete] -[[release_notes_7101]] -=== 7.10.1 Release notes -[discrete] -==== Client - -- Updates for connecting with Cloud. - -[discrete] -[[release_notes_7100]] -=== 7.10 Release notes - -[discrete] -==== Client - -- Support for Elasticsearch version `7.10.0`. -- Fixes a bug when building the complete endpoint URL could end with duplicate slashes `//`. -- Fixes a bug when building the complete endpoint URL with cloud id could end with duplicate ports https://github.com/elastic/elasticsearch-ruby/issues/1081[#1081]. - -[discrete] -==== API - -- Fix in RubyDoc comments, some parameters were being duplicated. -- Deprecation notice: Synced flush (`indices.flush_synced`) is deprecated and will be removed in 8.0. Use flush instead. - -[discrete] -===== New API Endpoints - -- `snapshot.clone` - - -[discrete] -===== API Changes - -- `bulk`, `index`, `update`: new parameter `require_alias` (boolean): When true, requires destination to be an alias (default: false) for `index` and `update`. For `bulk` it sets `require_alias` for all incoming documents. Defaults to unset (false). - - -[discrete] -==== X-Pack - -Deprecation notice: `searchable_snapshots.repository_stats` is deprecated and is replaced by the Repositories Metering API. - -[discrete] -===== New API Endpoints - -- `close_point_in_time` -- `open_point_in_time` -- `security.clear_api_key_cache` -- `security.grant_api_key` - -[discrete] -===== API Changes - -- `cat.ml_datafeeds`, `cat.ml_jobs`, `machine_learning.close_job`, `machine_learning.get_datafeed_stats`, `machine_learning.get_datafeeds`, `machine_learning.get_job_stats`, `machine_learning.get_jobs`, `machine_learning.get_overall_buckets`, `machine_learning.stop_datafeed`: new parameter `allow_no_match` (boolean): Whether to ignore if a wildcard expression matches no datafeeds (this includes `_all` string or when no datafeeds have been specified). --`machine_learning.get_data_frame_analytics`: new parameter `verbose` (boolean), whether the stats response should be verbose. -- `machine_learning.get_trained_models`: new parameter `include` (string), a comma-separate list of fields to optionally include. Valid options are 'definition' and 'total_feature_importance'. Default is none. -- `machine_learning.stop_datafeed`: endpoint now accepts a `body`: the URL params optionally sent in the body. -- `security.get_role`, `security/get_role_mapping`: The name parameter is now a comma-separated list of role-mapping names. -- `machine_learning.delete_trained_model`, `machine_learning.get_trained_models`, `machine_learning.get_trained_models_stats`, `machine_learning.put_trained_model`: Internal change, url changed from `_ml/inference` to `_ml/trained_models`. diff --git a/docs/release_notes/711.asciidoc b/docs/release_notes/711.asciidoc deleted file mode 100644 index 9df6f1ba1f..0000000000 --- a/docs/release_notes/711.asciidoc +++ /dev/null @@ -1,49 +0,0 @@ -[[release_notes_711]] -=== 7.11 Release notes - -[discrete] -[[release_notes_7112]] -=== 7.11.2 Release notes - -[discrete] -==== Client - -* Bug fix in meta header, fixes fail when http adapter library hasn't been loaded yet: https://github.com/elastic/elasticsearch-ruby/issues/1224[Issue]. - -[discrete] -[[release_notes_7111]] -=== 7.11.1 Release notes - -[discrete] -==== Client - -* Bug fix in meta header, adds support for unknown Faraday adapters. https://github.com/elastic/elasticsearch-ruby/pull/1204[Pull Request]. - -[discrete] -[[release_notes_7110]] -=== 7.11.0 Release notes - -[discrete] -==== Client - -- Support for Elasticsearch version `7.11.0`. -- Fixes a bug with headers in our default Faraday class. https://github.com/elastic/elasticsearch-ruby/commit/9c4afc452467cc6344359b54b98bbe5af1469219[Commit]. -- Adds the `X-Elastic-Client-Meta` HTTP header which is used by Elastic Cloud and can be disabled with the `enable_meta_header` parameter set to `false`. - - -[discrete] -==== API - -- `cat.tasks` - Parameter `node_id` changes name to `nodes`, a comma-separated list of node IDS or names. Parameter `parent_task` changes name to `parent_task_id`. -- APIs that are no longer experimental: `cluster.delete_component_template`, `cluster.exists_component_template`, `cluster.get_component_template`, `cluster.put_component_template`, `indices.delete_index_template`, `indices.exists_index_template`, `indices.get_index_template`, `indices.put_index_template`, `indices.simulate_index_template`, `indices.simulate_template`. -- Deprecation notice: The _upgrade API is no longer useful and will be removed. Instead, see `_reindex API`. Deprecated since version 8.0.0. Endpoints: `indices.get_upgrade`, `indices.upgrade` - -[discrete] -==== X-Pack - -- New endpoints:`async_search.status`, `autoscaling.get_autoscaling_capacity` (experimental), `indices.migrate_to_data_stream`, `indices.promote_data_stream`, `machine_learning.upgrade_job_snapshot`, `rollup.rollup`, `watcher.query_watches`. -- APIs that are no longer experimental: `eql.delete`, `eql.get`, `eql.search`, -- APIs promoted from experimental to beta: `machine_learning.delete_data_frame_analytics`, `ml.delete_trained_model`, `machine_learning.evaluate_data_frame`, `machine_learning.explain_data_frame_analytics`, `machine_learning.get_data_frame_analytics`, `machine_learning.get_datafeed_stats`, `machine_learning.get_trained_models`, `machine_learning.get_trained_models_stats`, `machine_learning.put_data_frame_analytics`, `machine_learning.put_trained_model`, `machine_learning.start_data_frame_analytics`, `machine_learning.stop_data_frame_analytics`, `machine_learning.update_data_frame_analytics` -- `indices.delete_data_stream`, `indices.get_data_stream` add parameter `expand_wildcards`, wether wildcard expressions should get expanded to open or closed indices (default: open). Options: open, closed, hidden, none, all. -- `machine_learning.get_data_frame_analytics`, `machine_learning.get_datafeeds`, `machine_learning.get_jobs`, `machine_learning.get_trained_models`, `transform.get_transform` add parameter `exclude_generated` - omits fields that are illegal to set on PUT. -- `data_frame_transform_deprecated.get_transform` (_data_frame/transforms/ is deprecated, use _transform/ in the future) adds parameter `exclude_generated` - omits generated files. diff --git a/docs/release_notes/712.asciidoc b/docs/release_notes/712.asciidoc deleted file mode 100644 index c23f8c560c..0000000000 --- a/docs/release_notes/712.asciidoc +++ /dev/null @@ -1,28 +0,0 @@ -[[release_notes_712]] -=== 7.12 Release notes - -[discrete] -==== Client - -- Support for Elasticsearch version 7.12.0 -- Ruby 3 is now tested, it was added to the entire test suite. -- New official documentation pages for configuration: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/basic-config.html[Basic Configuration] and https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/advanced-config.html[Advanced Configuration]. -- Integration tests runner refactored to keep skipped tests in a yaml file. - -[discrete] -==== API - -- New API namespace: `features` and endpoints `features.get_features` and `snapshot.get_features`. -- `cat.plugins` adds parameter `include_bootstrap`: Include bootstrap plugins in the response. -- Update in `indices.close` parameter `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`. -- `actions.search` adds parameter `min_compatible_shard_node`: The minimum compatible version that all shards involved in search should have for this request to be successful. - -[discrete] -==== X-Pack - -- New API namespace: `text_structure` and endpoints `text_structure.find_structure`. -- New API namespace: `logstash` and endpoints `logstash.delete_pipeline`, `logstash.get_pipeline`, `logstash.put_pipeline`. -- New API: `eql.get_status`. -- APIs migrated from experimental to stable: `autoscaling.delete_autoscaling_policy`, `autoscaling.get_autoscaling_capacity`, `autoscaling.get_autoscaling_policy`, `autoscaling.put_autoscaling_policy`. -- `searchable_snapshots.mount` adds parameter `storage`: Selects the kind of local storage used to accelerate searches. Experimental, and defaults to `full_copy`. -- `searchable_snapshots.stats` adds parameter `level`: Return stats aggregated at cluster, index or shard level (options: cluster, indices, shards). diff --git a/docs/release_notes/713.asciidoc b/docs/release_notes/713.asciidoc deleted file mode 100644 index 47594bdd12..0000000000 --- a/docs/release_notes/713.asciidoc +++ /dev/null @@ -1,53 +0,0 @@ -[[release_notes_713]] -=== 7.13 Release notes - -[discrete] -[[release_notes_7133]] -=== 7.13.3 Release notes - -- API Support for Elasticsearch version 7.13.3 - -[discrete] -[[release_notes_7132]] -=== 7.13.2 Release notes - -- Mute release, yanked from RubyGems. - -[discrete] -[[release_notes_7131]] -=== 7.13.1 Release notes - -[discrete] -==== Client -- Fixes thread safety issue in `get_connection` - https://github.com/elastic/elasticsearch-ruby/pull/1325[Pull Request]. - -[discrete] -[[release_notes_7130]] -=== 7.13.0 Release notes - -[discrete] -==== Client - -- Support for Elasticsearch version 7.13.0 -- Adds support for compatibility header for Elasticsearch. If the environment variable 'ELASTIC_CLIENT_APIVERSIONING' is set to `true` or `1`, the client will send the headers `Accept` and `Content-Type` with the following value: `application/vnd.elasticsearch+json;compatible-with=7`. -- Better detection of Elasticsearch and Enterprise Search clients in the meta header used by cloud. - -[discrete] -==== API - -- The REST API tests now use an artifact downloaded from the Elastic servers instead of depending of cloning `elasticsearch` locally. Check the README for more information. -- New parameter `include_unloaded_segments` in `cat.nodes`, `nodes.stats`: If set to true segment stats will include stats for segments that are not currently loaded into memory -- New parameter `summary` in `ingest.get_pipeline`: Return pipelines without their definitions (default: false) -- New parameter `index_details` in `snapshot.get`: Whether to include details of each index in the snapshot, if those details are available. Defaults to false. -- New endpoint `features.reset_features`, `ingest/geo_ip_stats` -- New experimental endpoints: `shutdown.delete_node`, `shutdown.get_node`, `shutdown.put_node`. - -[discrete] -==== X-Pack - -- Refactored test tasks, made it easier to run the tests by default. -- New experimental endpoints: `fleet.global_checkpoints`, `searchable_snapshots.cache_stats`. -- New beta endpoints: `security.clear_cached_service_tokens`, `security.create_service_token`, `security.delete_service_token`, `security.get_service_accounts`, `security.get_service_credentials` -- New endpoints: `machine_learning.delete_trained_model_alias`, `machine_learning.preview_data_frame_analytics`, `machine_learning.put_trained_model_alias`. -- APIs migrated from experimental or beta to stable: `machine_learning.delete_data_frame_analytics`, `machine_learning.delete_trained_model`, `machine_learning.estimate_model_memory`, `machine_learning.explain_data_frame_analytics`, `machine_learning.get_data_frame_analytics`, `machine_learning.get_data_frame_analytics_stats`, `machine_learning.get_trained_models`, `machine_learning.get_trained_models_stats`, `machine_learning.put_data_frame_analytics`, `machine_learning.put_trained_model`, `machine_learning.start_data_frame_analytics`, `machine_learning.stop_data_frame_analytics`, `machine_learning.update_data_frame_analytics` -- New parameter `body` in `machine_learning.preview_datafeed`: The datafeed config and job config with which to execute the preview. diff --git a/docs/release_notes/714.asciidoc b/docs/release_notes/714.asciidoc deleted file mode 100644 index 5cdf6092cd..0000000000 --- a/docs/release_notes/714.asciidoc +++ /dev/null @@ -1,93 +0,0 @@ -[[release_notes_714]] -=== 7.14 Release notes - -[discrete] -[[release_notes_7141]] -=== 7.14.1 Release notes - -[discrete] -==== Client - - - Fixes for Manticore Implementation: Addresses custom headers on initialization (https://github.com/elastic/elasticsearch-ruby/commit/3732dd4f6de75365460fa99c1cd89668b107ef1c[3732dd4]) and fixes tracing (https://github.com/elastic/elasticsearch-ruby/commit/3c48ebd9a783988d1f71bfb9940459832ccd63e4[3c48ebd]). Related to https://github.com/elastic/elasticsearch-ruby/issues/1426[#1426] and https://github.com/elastic/elasticsearch-ruby/issues/1428[#1428]. - -[discrete] -[[release_notes_7140]] -=== 7.14.0 Release notes - -[discrete] -==== Client - -Added check that client is connected to an Elasticsearch cluster. If the client isn't connected to a supported Elasticsearch cluster the `UnsupportedProductError` exception will be raised. - -This release changes the way in which the transport layer and the client interact. Previously, when using `elasticsearch-transport`, `Elasticsearch::Transport::Client` had a convenient wrapper, so it could be used as `Elasticsearch::Client`. Now, we are decoupling the transport layer from the Elasticsearch client. If you're using the `elasticsearch` gem, not much will change. It will instantiate a new `Elasticsearch::Transport::Client` when you instantiate `Elasticsearch::Client` and the endpoints from `elasticsearch-api` will be available. - -`Elasticsearch::Client` has an `attr_accessor` for the transport instance: - -[source,ruby] ------------------------------------- -> client = Elasticsearch::Client.new -> client.transport.class -=> Elasticsearch::Transport::Client -> client.transport.transport.class -=> Elasticsearch::Transport::Transport::HTTP::Faraday ------------------------------------- - -The interaction with `elasticsearch-api` remains unchanged. You can use the API endpoints just like before: - -[source,ruby] ------------------------------------- -> client.info -=> {"name"=>"instance", - "cluster_name"=>"elasticsearch", - "cluster_uuid"=>"id", - "version"=> - {"number"=>"7.14.0", - ... -}, - "tagline"=>"You Know, for Search"} ------------------------------------- - -Or perform request directly from the client which will return an `Elasticsearch::Transport::Response` object: - -[source,ruby] ------------------------------------- -> client.perform_request('GET', '/') -# This is the same as doing client.transport.perform_request('GET', '/') -=> #"instance", - "cluster_name"=>"elasticsearch", - "cluster_uuid"=>"id", - "version"=> - {"number"=>"7.14.0-SNAPSHOT", - ... - }, - "tagline"=>"You Know, for Search"}, - @headers= - {"content-type"=>"application/json; charset=UTF-8", - "content-length"=>"571", - ... - }, - @status=200> ------------------------------------- - -If you have any problems, please report them in https://github.com/elastic/elasticsearch-ruby/issues/1344[this issue]. - -[discrete] -==== API - -Code is now generated from Elastic artifacts instead of checked out code of Elasticsearch. See https://github.com/elastic/elasticsearch-ruby/blob/7.14/elasticsearch-api/utils/README.md#generate[the Generator README] for more info. - -- Endpoints `msearch`, `msearch_template` and `search_template` remove `query_and_fetch` and `dfs_query_and_fetch` options from the `search_type` parameter. -- New parameter `include_repository` in `snapshot.get`: (boolean) Whether to include the repository name in the snapshot info. Defaults to true. - -[discrete] -==== X-Pack - -X-Pack is being deprecated. The first time using `xpack` on the client, a warning will be triggered. Please check https://github.com/elastic/elasticsearch-ruby/issues/1274[this issue] for more information. - - -- New endpoints: `index_lifecycle_management.migrate_to_data_tiers`, `machine_learning.reset_job`, `security.saml_authenticate`, `security.saml_complete_logout`, `security.saml_invalidate`, `security.saml_logout`, `security.saml_prepare_authentication`, `security.saml_service_provider_metadata`, `sql.delete_async`, `sql.get_async`, `sql.get_async_status`, `terms_enum`. -- New experimental endpoints: `machine_learning.infer_trained_model_deployment`, `machine_learning.start_trained_model_deployment`, `machine_learning.stop_trained_model_deployment`. -- Deprecation: `indices.freeze` and `indices.unfreeze`: Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release. - diff --git a/docs/release_notes/715.asciidoc b/docs/release_notes/715.asciidoc deleted file mode 100644 index 5962394afe..0000000000 --- a/docs/release_notes/715.asciidoc +++ /dev/null @@ -1,20 +0,0 @@ -[[release_notes_715]] -=== 7.15 Release notes - -[discrete] -==== Client - -- Support for Elasticsearch v7.15.0 APIs. -- We've tested and added documentation on best practices for leveraging the client in a Function-as-a-Service (FaaS) environment to the https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/connecting.html#client-faas[official docs]. - -[discrete] -==== API -- New experimental endpoints: `indices.disk_usage`. `indices.field_usage_stats`, `nodes.clear_repositories_metering_archive`, `get_repositories_metering_info`, https://www.elastic.co/guide/en/elasticsearch/reference/7.15/search-vector-tile-api.html[`search_mvt`] -- The `index` parameter is now required for `open_point_in_time`. -- The `index_metric` parameter in `nodes.stats` adds the `shards` option. - -[discrete] -==== X-Pack - -- New parameters for `ml.put_job`: `ignore_unavailable`, `allow_no_indices`, `ignore_throttled`, `expand_wildcards`. -- New endpoint: https://www.elastic.co/guide/en/elasticsearch/reference/7.15/security-api-query-api-key.html[`security.query_api_keys`]. diff --git a/docs/release_notes/716.asciidoc b/docs/release_notes/716.asciidoc deleted file mode 100644 index 11c1b68ad7..0000000000 --- a/docs/release_notes/716.asciidoc +++ /dev/null @@ -1,96 +0,0 @@ -[[release_notes_716]] -=== 7.16 Release notes - -[discrete] -[[release_notes_7163]] -=== 7.16.3 Release notes - -==== API - -Bugfix for https://github.com/elastic/elasticsearch-ruby/issues/1475[#1475], an issue where if you indexed a document with an id such as `an id`, it would get escaped to `an+id` instead of `an%20id` when using `index` or `create`. This would result in the document id being `an+id` instead of the intended value `an id`. - -[discrete] -[[release_notes_7162]] -=== 7.16.2 Release notes - -No release. - -[discrete] -[[release_notes_7161]] -=== 7.16.1 Release notes - -Patch release corresponding with Elastic Stack version 7.16.1 that addresses the Apache Log4j2 vulnerability, https://discuss.elastic.co/t/apache-log4j2-remote-code-execution-rce-vulnerability-cve-2021-44228-esa-2021-31/291476[more information]. - -==== Client - -The only changes in the client since 7.16.0 are a few minor updates for the https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/connecting.html#client-comp[Compatibility mode with 8.0]. We added the compatibility header in `7.13.0`, but now we have integration tests and compatibility tests for version `7.x` of the client with Elasticsearch `8.0`. - -[discrete] -[[release_notes_7160]] -=== 7.16.0 Release notes - -[discrete] -==== Client - -- Adds the `delay_on_retry` parameter, a value in milliseconds to wait between each failed connection, thanks https://github.com/DinoPullerUqido[DinoPullerUqido]! https://github.com/elastic/elasticsearch-ruby/pull/1521[Pull Request] and https://github.com/elastic/elasticsearch-ruby/pull/1523[backport]. -- Adds *CA fingerprinting*. You can configure the client to only trust certificates that are signed by a specific CA certificate (CA certificate pinning) by providing a `ca_fingerprint` option. This will verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied value. The verification will be run once per connection. Code example: - -[source,ruby] ------------------------------------- -ca_fingerprint = '64F2593F...' -client = Elasticsearch::Client.new( - host: 'https://elastic:changeme@localhost:9200', - transport_options: { ssl: { verify: false } }, - ca_fingerprint: ca_fingerprint -) ------------------------------------- - -- Fixes compression. When `compression` is set to `true`, the client will now gzip the request body properly and use the appropiate headers. Thanks https://github.com/johnnyshields[johnnyshields]! https://github.com/elastic/elasticsearch-ruby/pull/1478[Pull Request] and https://github.com/elastic/elasticsearch-ruby/pull/1526[backport]. -- Warnings emitted by Elasticsearch are now logged via `log_warn` through the Loggable interface in the client, instead of using `Kernel.warn`. https://github.com/elastic/elasticsearch-ruby/pull/1517[Pull Request]. - -[discrete] -==== API - -- Cleaned up some deprecated code. -- `count` - The API is documented as using `GET`, but it supports both GET and POST on the Elasticsearch side. So it was updated to only use `POST` when there's a body present, or else use `GET`. Elasticsearch would still accept a body with `GET`, but to be more semantically correct in the clients we use `POST` when there's a body. -- `delete_index_template` was updated to support the `ignore_404` parameter to ignore 404 errors when attempting to delete a non-existing template. -- `ingest.put_pipeline` adds new parameter `if_version`: Required version for optimistic concurrency control for pipeline updates. -- `ml.put_trained_model`: adds new parameter `defer_definition_decompression`: If set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations. -- `nodes.hot_threads` adds new parameter `sort`: The sort order for 'cpu' type (default: total) (options: cpu, total). -- `open_point_in_time`: `keep_alive` is now a required parameter. -- `search_mvt`: adds new parameter `track_total_hits`: Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. -- `transform.preview_transform`: adds new parameter `transform_id`. Body is now optional and the API will use `GET` or `POST` depending on the presence of a body. - -*APIs promoted from experimental to stable since last version:* - -- `fleet.global_checkpoints` -- `get_script_context` -- `get_script_language` -- `indices.resolve_index` -- `monitoring.bulk` -- `rank_eval` -- `searchable_snapshots.mount` -- `searchable_snapshots.stats` -- `security.clear_cached_service_tokens` -- `security.create_service_token` -- `security.delete_service_token` -- `security.get_service_accounts` -- `security.get_service_credentials` -- `shutdown.delete_node` -- `shutdown.get_node` -- `shutdown.put_node` -- `terms_enum` - -*New APIs* - -- `fleet.mseach` -- `fleet.search` -- `indices.modify_data_stream` -- `ml.infer_trained_model_deployment` -- `ml.start_trained_model_deployment` -- `ml.stop_trained_model_deployment` -- `migration.get_feature_upgrade_status` -- `migration.post_feature_upgrade_status` -- `security.enroll_kibana` -- `security.enroll_node` -- `transform.updgrade_transforms` diff --git a/docs/release_notes/717.asciidoc b/docs/release_notes/717.asciidoc deleted file mode 100644 index 4413dd225a..0000000000 --- a/docs/release_notes/717.asciidoc +++ /dev/null @@ -1,29 +0,0 @@ -[[release_notes_717]] -=== 7.17 Release notes - -[discrete] -[[release_notes_7177]] -=== 7.17.7 Release notes - -- Compatibility with Elasticsearch v7.17.7 APIs. -- Tested versions of Ruby for 7.17.7: Ruby (MRI) 2.6, 2.7, 3.0 and 3.1, JRuby 9.3. - -[discrete] -[[release_notes_7172]] -=== 7.17.2, 7.17.3, 7.17.4, 7.17.5, 7.17.6 Release notes - -No release. - -[discrete] -[[release_notes_7171]] -=== 7.17.1 Release notes - -- Improves handling of YAML parsing, uses `safe_load` instead of `load` when doing the product verification (should only affect Ruby < 3.0). -- Updates headers setup when using the Manticore adapter. This fixes an issue where the user-agent header was being foverridden even when it was being set on initialization via the transport options. https://github.com/elastic/elasticsearch-ruby/pull/1685[Pull Request], https://github.com/elastic/elasticsearch-ruby/issues/1684[issue]. - -[discrete] -[[release_notes_7170]] -=== 7.17.0 Release notes - -- Drops Ruby 2.5 from the test matrix. Support for Ruby 2.5 was dropped March 2021. -- Updates the product verification when the response is a `413` error. diff --git a/docs/release_notes/75.asciidoc b/docs/release_notes/75.asciidoc deleted file mode 100644 index ac874d0cfb..0000000000 --- a/docs/release_notes/75.asciidoc +++ /dev/null @@ -1,59 +0,0 @@ -[[release_notes_75]] -=== 7.5 Release notes - -- Support for Elasticsearch 7.5. -- Update API spec generator: The code for Elasticsearch OSS and X-Pack APIs is being generated from the rest api spec. -- Specs have been updated to address new/deprecated parameters. -- Ruby versions tested: 2.3.8, 2.4.9, 2.5.7, 2.6.5 and 2.7.0 (new). - - -[discrete] -==== API - -Endpoints that changed: - -- `_bulk`: body is now required as an argument. -- `cat`: `local` and `master_timeout` parameters are gone. - - `health`: New parameter `health`. - - `indices`: Adds `time` and `include_unload_segments` parameters. - - `nodes`: Adds `bytes`, `time` parameters. - - `pending_tasks`: Adds `time` parameter. - - `recovery`: Adds `active_only`, `detailed`, `index`, `time` parameters. - - `segments`: Removes `index` parameter and it's now a url part. - - `shards`: Adds `time` parameter. - - `snapshots`: Adds `time` parameter. - - `tasks`: Adds `time` parameter. - - `templates`: The `name` parameter is now passed in as a part but not a parameter. - - `thread_pool`: The `thread_pool_patterns` parameter is now passed in as a part but not as a parameter. -- `cluster` - - `put_settings`: body is required. - - `state`: `index_templates` is gone. - - `node_id` is now a url part. -- `delete` - `parent` parameter is gone. -- `delete_by_query`: `analyzer` parameters are gone, `max_docs` is a new parameter, `body` is now a required parameter. -- `delete_by_query_rethrottle` new endpoint. -- `delete_by_rethrottle` - uses `delete_by_query_rethrottle` and hasn't changed. -- `exists`, `exists_source`, `explain`: `parent` parameter is gone. -- `field_caps`: `fields` param is no longer required. -- `get`: `parent` parameter is gone -- `get_source`: `parent` parameter is gone -- `index`: `body` parameter is required, `wait_for_shard` is a new parameter, `consistency`, `include_type_name`, `parent`, `percolate`, `replication`, `timestamp`, `ttl` parameters are gone -- `indices` - - `get`: `feature` paramatere was deprecated and is gone. - - `delete_aliases`, `put_alias`: URL changed internally to 'aliases' instead of 'alias' but shouldn't affect the client's API. -- `render_search_template`: `id` is now a part not a parameter -- `search`: `fielddata_fields`, `include_type_name`, `fields`, `ignore_indices`, `lowercase_expanded_terms`, `query_cache`, `source` parameters are gone, `ccs_minimize_roundtrips`, `track_scores` are new parameters. -- `tasks` - `list`: task_id is not supported anymore, it's in get now. -- `termvectors`: `parent` parameter is gone. -- `update`: `version` parameter is not supported anymore. - - -[discrete] -==== X-Pack - -Some urls changed internally to remove `_xpack`, but it shouldn't affect the client's API. - -- `explore`: `index` is now required. -- `info`: `human` parameter is gone. -- `migration`: some endpoints are gone: `get_assistance`, `get_assistance_test` and `upgrade_test`. -- `watcher`: `restart` endpoint is gone. diff --git a/docs/release_notes/76.asciidoc b/docs/release_notes/76.asciidoc deleted file mode 100644 index bd546df82f..0000000000 --- a/docs/release_notes/76.asciidoc +++ /dev/null @@ -1,86 +0,0 @@ -[[release_notes_76]] -=== 7.6 Release notes - - -[discrete] -==== Client - -* Support for Elasticsearch version 7.6. -* Last release supporting Ruby 2.4. Ruby 2.4 has reached it's end of life and no more security updates will be provided, users are suggested to update to a newer version of Ruby. - - -[discrete] -===== API Key Support - -The client now supports API Key Authentication, check "Authentication" on the https://github.com/elastic/elasticsearch-ruby/tree/7.x/elasticsearch-transport#authentication[transport README] for information on how to use it. - - -[discrete] -===== X-Opaque-Id Support - -The client now supports identifying running tasks with X-Opaque-Id. Check https://github.com/elastic/elasticsearch-ruby/tree/7.x/elasticsearch-transport#identifying-running-tasks-with-x-opaque-id[transport README] for information on how to use X-Opaque-Id. - - -[discrete] -===== Faraday migrated to 1.0 - -We're now using version 1.0 of Faraday: - -* The client initializer was modified but this should not disrupt final users at all, check this commit for more information. -* Migrated error checking to remove the deprecated Faraday::Error namespace. -* *This change is not compatible with https://github.com/typhoeus/typhoeus[Typhoeus]*. The latest release is 1.3.1, but it's https://github.com/typhoeus/typhoeus/blob/v1.3.1/lib/typhoeus/adapters/faraday.rb#L100[still using the deprecated `Faraday::Error` namespace]. This has been fixed on master, but the last release was November 6, 2018. Version 1.4.0 should be ok once it's released. -* Note: Faraday 1.0 drops official support for JRuby. It installs fine on the tests we run with JRuby in this repo, but it's something we should pay attention to. - -Reference: https://github.com/lostisland/faraday/blob/master/UPGRADING.md[Upgrading - Faraday 1.0] - -https://github.com/elastic/elasticsearch-ruby/pull/808[Pull Request] - - -[discrete] -==== API - - -[discrete] -===== API Changes: - -- `cat.indices`: argument `bytes` options were: `b,k,m,g` and are now `b,k,kb,m,mb,g,gb,t,tb,p,pb`. -- `delete_by_query`: New parameter `analyzer` - The analyzer to use for the query string. -- `indices.put_template`: Removed parameters: `timeout`, `flat_settings`. -- `msearch_template`: New Parameter `ccs_minimize_roundtrips` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution. -- `rank_eval`: New parameter `search_type` - Search operation type (options: `query_then_fetch,dfs_query_then_fetch`). -- `search_template`: New parameter `ccs_minimize_roundtrips` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution. - - -[discrete] -===== New API endpoints: - -- `get_script_context` -- `get_script_languages` - - -[discrete] -===== Warnings: - -Synced flush is deprecated and will be removed in 8.0. - - -[discrete] -==== X-Pack - - -[discrete] -===== New API endpoints: - -- `ml/delete_trained_model` -- `ml/explain_data_frame_analytics` -- `ml/get_trained_models` -- `ml/get_trained_models_stats` -- `ml/put_trained_model` - - -[discrete] -===== API changes: - -- `license/get`: Added parameter `accept_enterprise`. -- `ml/delete_data_frame_analytics` Added parameter `force`. -- `monitoring/bulk` - Removed parameter `system_version`. \ No newline at end of file diff --git a/docs/release_notes/77.asciidoc b/docs/release_notes/77.asciidoc deleted file mode 100644 index 87f5e1bdbb..0000000000 --- a/docs/release_notes/77.asciidoc +++ /dev/null @@ -1,77 +0,0 @@ -[[release_notes_77]] -=== 7.7 Release notes - -This version drops support for Ruby 2.4 since it's reached it's end of life. - - -[discrete] -==== Client - -- Support for Elasticsearch version `7.7` - - -[discrete] -===== Custom Headers - -You can set custom HTTP headers on the client's initializer or pass them as a parameter to any API endpoint. https://github.com/elastic/elasticsearch-ruby/tree/7.x/elasticsearch-transport#custom-http-headers[More info and code examples]. - - -[discrete] -==== API - - -[discrete] -===== API Changes - -- Clean: Removes up some deprecated endpoints: `abort_benchmark`, `benchmark`, `delete_by_rethrottle`, `nodes.shutdown`, `remote.info`. -- `expand_wildcards` Whether to expand wildcard expressions to concrete indices that are open, closed or both. Options: open, closed, hidden, none, all. `hidden` option is new. It was also added to the following endpoints: `cat.aliases`, `cat.indices`. -- `delete_by_query`: Parameter `slices` can now be set to `auto`. -- `reindex`: Parameter `slices` can now be set to `auto`. -- `update_by_query`: Parameter `slices` can now be set to `auto`. -- `snapshot.cleanup_repository`: Parameter `body` is removed. - - -[discrete] -===== New API Endpoints - -- `cluster.delete_component_template` -- `cluster.get_component_template` -- `cluster.put_component_template` -- `indices.create_data_stream` (experimental) -- `indices.delete_data_stream` (experimental) -- `indices.get_data_stream` (experimental) - - -[discrete] -==== X-Pack - - -[discrete] -===== API Changes - -- `machine_learing.get_trained_models`: New parameter `tags` -- `machine_learning.put_datafeed`, `machine_learning.update_datafeed`: Added parameters `ignore_unavailable`, `allow_no_indices`, `ignore_throttled`, `expand_wildcards` -- `reload_secure_settings`: New parameter `body`, an object containing the password for the keystore. - - -[discrete] -===== New API Endpoints - -- `async_search.delete` -- `async_search.get` -- `async_search.submit` -- `cat.ml_data_frame_analytics` -- `cat.ml_datafeeds` -- `cat.ml_jobs` -- `cat.ml_trained_models` -- `cat.transform` -- `cat.transforms` -- `machine_learning.estimate_model_memory` -- `transform.delete_transform` -- `transform.get_transform` -- `transform.get_transform_stats` -- `transform.preview_transform` -- `transform.put_transform` -- `transform.start_transform` -- `transform.stop_transform` -- `transform.update_transform` \ No newline at end of file diff --git a/docs/release_notes/78.asciidoc b/docs/release_notes/78.asciidoc deleted file mode 100644 index a5d59e985e..0000000000 --- a/docs/release_notes/78.asciidoc +++ /dev/null @@ -1,103 +0,0 @@ -[[release_notes_78]] -=== 7.8 Release notes - -[discrete] -[[release_notes_781]] -=== 7.8.1 Release notes - -[discrete] -==== Client - -- Support for Elasticsearch version `7.8.1`. -- Bug fix: Fixed a bug on the API endpoints documentation for RubyDocs: there was an unnecessary empty new line in the documentation for parameters that have options. So the parameters before that empty newline were not being documented in RubyDocs. - - -[discrete] -==== X-Pack - - -[discrete] -===== API Changes - -- Update to `info` endpoint. New parameter `accept_enterprise` (boolean): If an enterprise license is installed, return the type and mode as 'enterprise' (default: false). - - -[discrete] -[[release_notes_780]] -=== 7.8.0 Release notes - -[discrete] -==== Client - -- Support for Elasticsearch version `7.8`. -- Surface deprecation headers from Elasticsearch. When there's a `warning` response header in Elasticsearch's response, the client will emit a warning with `warn`. -- Typhoeus is supported again, version 1.4+ and has been added back to the docs. -- Adds documentation and example for integrating with Elastic APM. - - -[discrete] -==== API - - -[discrete] -===== New API Endpoints - -- `abort_benchmark` -- `benchmark` -- `cluster.delete_voting_config_exclusions` -- `cluster.post_voting_config_exclusions` -- `delete_by_rethrottle` -- `nodes.shutdown` -- `remote.info` - -Experimental endpoints: - -- `cluster.delete_component_template` -- `cluster.exists_component_template` -- `cluster.get_component_template` -- `cluster.put_component_template` - -- `indices.delete_index_template` -- `indices.exists_index_template` -- `indices.get_index_template` -- `indices.put_index_template` -- `indices.simulate_index_template` - - -[discrete] -===== API Changes - -- `cat/thread_pool`: `size` is deprecated. -- `indices.get_data_streams`: `name` is now a string instead of list, the name or wildcard expression of the requested data streams. -- `indices.put_index_template`: new parameter: `cause` (string), user defined reason for creating/updating the index template. -- `indices.simulate_index_template`: Two new parameters: `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. `cause` User defined reason for dry-run creating the new template for simulation purposes. -- `snapshot.delete_repository`: New parameter `repository`, name of the snapshot repository, wildcard (`*`) patterns are now supported. -- `task.cancel`: new parameter `wait_for_completion` (boolean) Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false. - - -[discrete] -==== X-Pack - - -[discrete] -===== New API Endpoints - -New namespace: `indices` - -- `indices.freeze` -- `indices.reload_search_analyzers` -- `indices.unfreeze` - -New namespace: `searchable_snapshots` - -- `clear_cache` -- `mount` -- `repository_stats` -- `stats` - - -[discrete] -===== API Changes - -- `machine_learning.delete_expired_data` new param `body`: deleting expired data parameters. -- `machine_learning.delete_data_frame_analytics` new param `timeout`: controls the time to wait until a job is deleted. Defaults to 1 minute. diff --git a/docs/release_notes/79.asciidoc b/docs/release_notes/79.asciidoc deleted file mode 100644 index cd780239fb..0000000000 --- a/docs/release_notes/79.asciidoc +++ /dev/null @@ -1,60 +0,0 @@ -[[release_notes_79]] -=== 7.9 Release notes - -[discrete] -==== Client - -- Support for Elasticsearch version `7.9.0`. -- Transport/Connection: Considers attributes values for equality - https://github.com/elastic/elasticsearch-ruby/commit/06ffd03bf51f5f33a0d87e9914e66b39357d40af[Commit]. -- When an API endpoint accepts both `GET` and `POST`, the client will always use `POST` when a request body is present. - -[discrete] -==== API - -- Documentation for API endpoints will point out when an API is experimental, beta or unstable. - -[discrete] -===== New API Endpoints - -- New namespace: `dangling_indices` -- `dangling_indices.delete_dangling_index` -- `dangling_indices.import_dangling_index` -- `dangling_indices.list_dangling_indices` -- `indices.add_block` - -Experimental endpoints: -- `indices.resolve_index` -- `simulate_template` - -[discrete] -===== API Changes - -- `field_caps`: adds body parameter allowing to filter indices if `index_filter` is provided. -- `eql.search`: new parameters `wait_for_completion`, `keep_on_completion` and `keep_alive`. -- `info`: New parameter `accept_enterprise`: If an enterprise license is installed, return the type and mode as 'enterprise' (default: false). -- `indices.put_mapping`: new parameter `write_index_only`. - -[discrete] -==== X-Pack - -[discrete] -===== New API Endpoints - -The Ruby client now supports all the X-Pack API endpoints. - -- New namespace `autoscaling`: `autoscaling.delete_autoscaling_policy`, `autoscaling.get_autoscaling_decision`, `autoscaling.get_autoscaling_policy`, `autoscaling.put_autoscaling_policy` -- New namespace `enrich`: `enrich.delete_policy`, `enrich.execute_policy`, `enrich.get_policy`, `enrich.put_policy`, `enrich.stats` -- New namespace `eql`: `eql.delete`, `eql.get`, `eql.search` -- New namespace `cross_cluster_replication`: `cross_cluster_replication.delete_auto_follow_pattern`, `cross_cluster_replication.follow`, `cross_cluster_replication.follow_info`, `cross_cluster_replication.follow_stats`, `cross_cluster_replication.forget_follower`, `cross_cluster_replication.get_auto_follow_pattern`, `cross_cluster_replication.pause_auto_follow_pattern`, `cross_cluster_replication.pause_follow`, `cross_cluster_replication.put_auto_follow_pattern`, `cross_cluster_replication.resume_auto_follow_pattern`, `cross_cluster_replication.resume_follow`, `cross_cluster_replication.stats`, `cross_cluster_replication.unfollow` -- New namespace `snapshot_lifecycle_management`: `snapshot_lifecycle_management.delete_lifecycle`, `snapshot_lifecycle_management.execute_lifecycle`, `snapshot_lifecycle_management.execute_retention`, `snapshot_lifecycle_management.get_lifecycle`, `snapshot_lifecycle_management.get_stats`, `snapshot_lifecycle_management.get_status`, `snapshot_lifecycle_management.put_lifecycle`, `snapshot_lifecycle_management.start`, `snapshot_lifecycle_management.stop` -- `indices.create_data_stream` -- `indices.data_streams_stats` -- `indices.delete_data_stream` -- `indices.get_data_stream` -- `security.clear_cached_privileges` -- `machine_learning.update_data_frame_analytics` - -[discrete] -===== API Changes - -- `machine_learning.delete_expired_data`: new parameters `job_id`, `requests_per_second` and `timeout` \ No newline at end of file diff --git a/docs/release_notes/80.asciidoc b/docs/release_notes/80.asciidoc deleted file mode 100644 index c97e91cc7b..0000000000 --- a/docs/release_notes/80.asciidoc +++ /dev/null @@ -1,74 +0,0 @@ -[[release_notes_80]] -=== 8.0 Release notes - -[discrete] -[[release_notes_801]] -=== 8.0.1 Release notes - -- Fixes an issue with the generated API code. When updating the code generator for 8.x, the order of `arguments.clone` in the generated code was changed. This would make it so that we would modify the parameters passed in before cloning them, which is undesired. Issue: https://github.com/elastic/elasticsearch-ruby/issues/1727[#1727]. - -[discrete] -[[release_notes_800]] -=== 8.0.0 Release notes - -First release for the 8.x branch with a few major changes. - -- Tested versions of Ruby for 8.0.0: Ruby (MRI) 2.6, 2.7, 3.0 and 3.1, JRuby 9.3. - -[discrete] -==== Client - -The code for the dependency `elasticsearch-transport` has been promoted to https://github.com/elastic/elastic-transport-ruby[its own repository] and the project and gem have been renamed to https://rubygems.org/gems/elastic-transport[`elastic-transport`]. This gem now powers https://rubygems.org/gems/elasticsearch[`elasticsearch`] and https://rubygems.org/gems/elastic-enterprise-search[`elastic-enterprise-search`]. The `elasticsearch-transport` gem won't be maintained after the last release in the `7.x` branch, in favour of `elastic-transport`. - -This will allow us to better address maintainance in both clients and the library itself. - -[discrete] -==== API - -The `elasticsearch-api` library has been generated based on the {es} 8.0.0 REST specification. - -#### X-Pack Deprecation - -X-Pack has been deprecated. The `elasticsearch-xpack` gem will no longer be maintained after the last release in the `7.x` branch. The "X-Pack" integration library codebase was merged into `elasticsearch-api`. All the functionality is available from `elasticsearch-api`. The `xpack` namespace was removed for accessing any APIs other than `_xpack` (`client.xpack.info`) and `_xpack/usage` (`client.xpack.usage`). But APIs which were previously available through the `xpack` namespace e.g.: `client.xpack.machine_learning` are now only available directly: `client.machine_learning`. - -#### Parameter checking was removed - -The code in `elasticsearch-api` will no longer validate all the parameters sent. It will only validate the required parameters such as those needed to build the path for the request. But other API parameters are going to be validated by {es}. This provides better forwards and backwards compatibility in the client. - -#### Response object - -In previous versions of the client, calling an API endpoint would return the JSON body of the response. With `8.0`, we are returning a new Response object `Elasticsearch::API::Response`. It still behaves like a Hash to maintain backwards compatibility, but adds the `status` and `headers` methods from the `Elastic::Transport:Transport::Response` object: - -```ruby -elastic_ruby(main)> response = client.info -=> #"instance", - "cluster_name"=>"elasticsearch-8-0-0-SNAPSHOT-rest-test", - "cluster_uuid"=>"oIfRARuYRGuVYybjxQJ87w", - "version"=> - {"number"=>"8.0.0-SNAPSHOT", - "build_flavor"=>"default", - "build_type"=>"docker", - "build_hash"=>"7e23c54eb31cc101d1a4811b9ab9c4fd33ed6a8d", - "build_date"=>"2021-11-04T00:21:32.464485627Z", - "build_snapshot"=>true, - "lucene_version"=>"9.0.0", - "minimum_wire_compatibility_version"=>"7.16.0", - "minimum_index_compatibility_version"=>"7.0.0"}, - "tagline"=>"You Know, for Search"}, - @headers={"X-elastic-product"=>"Elasticsearch", "content-type"=>"application/json", "content-length"=>"567"}, - @status=200>> -elastic_ruby(main)> response.status -=> 200 -elastic_ruby(main)> response.headers -=> {"X-elastic-product"=>"Elasticsearch", "content-type"=>"application/json", "content-length"=>"567"} -elastic_ruby(main)> response['name'] -=> "instance" -elastic_ruby(main)> response['tagline'] -=> "You Know, for Search" -``` - -Please https://github.com/elastic/elasticsearch-ruby/issues[let us know if you find any issues]. diff --git a/docs/release_notes/81.asciidoc b/docs/release_notes/81.asciidoc deleted file mode 100644 index 871486ead8..0000000000 --- a/docs/release_notes/81.asciidoc +++ /dev/null @@ -1,55 +0,0 @@ -[[release_notes_81]] -=== 8.1 Release notes - -[discrete] -[[release_notes_812]] -=== 8.1.2 Release notes - -[discrete] -==== API - -- Fixes an issue with the generated API code. When updating the code generator for 8.x, the order of `arguments.clone` in the generated code was changed. This would make it so that we would modify the parameters passed in before cloning them, which is undesired. Issue: https://github.com/elastic/elasticsearch-ruby/issues/1727[#1727]. - -[discrete] -[[release_notes_811]] -=== 8.1.1 Release notes - -No release, no changes on the client. - -[discrete] -[[release_notes_810]] -=== 8.1.0 Release notes - -- Tested versions of Ruby for 8.1.0: Ruby (MRI) 2.6, 2.7, 3.0 and 3.1, JRuby 9.3. - -[discrete] -==== API - -Updated for compatibility with Elasticsearch 8.1's API. - -[discrete] -===== New parameters: -- `indices.forcemerge` - `wait_for_completion` Should the request wait until the force merge is completed. -- `indices.get` - `features` Return only information on specified index features (options: aliases, mappings, settings). -- `ingest.put_pipeline` `if_version` (Integer), required version for optimistic concurrency control for pipeline updates. -- `ml.delete_trained_model` - `timeout` controls the amount of time to wait for the model to be deleted. `force` (Boolean) true if the model should be forcefully deleted. -- `ml.stop_trained_model_deployment` - `allow_no_match` whether to ignore if a wildcard expression matches no deployments. (This includes `_all` string or when no deployments have been specified). `force` true if the deployment should be forcefully stopped. Adds `body` parameter, the stop deployment parameters. -- `nodes.hot_threads` - `sort` the sort order for 'cpu' type (default: total) (options: cpu, total) - -[discrete] -===== Updated parameters: -- `indices.get_index_template` - `name` is now a String, a pattern that returned template names must match. -- `knn_search` - `index` removes option to use empty string to perform the operation on all indices. -- `ml.close_job`, `ml.get_job_stats`, `ml.get_jobs`, `ml.get_overall_buckets` - Remove `allow_no_jobs` parameter. -- `ml.get_datafeed_stats`, `ml.get_datafeeds` - Remove `allow_no_datafeeds` parameter. -- `nodes.hot_threads` - `type` parameter adds `mem` option. -- `nodes.info` - `metric` updated to use `_all` to retrieve all metrics and `_none` to retrieve the node identity without any additional metrics. (options: settings, os, process, jvm, thread_pool, transport, http, plugins, ingest, indices, aggregations, _all, _none). `index_metric` option `shards` changes to `shard_stats`. -- `open_point_in_time` - `keep_alive` is now a required parameter. -- `search_mvt` - `grid_type` parameter adds `centroid` option in addition to `grid` and `point`. - -- New experimental APIs, designed for internal use by the fleet server project: `fleet.search`, `fleet.msearch`. - -[discrete] -===== New APIs -- OpenID Connect Authentication: `security.oidc_authenticate`, `security.oidc_logout`, `security.oidc_prepare_authentication`. -- `transform.reset_transform`. diff --git a/docs/release_notes/82.asciidoc b/docs/release_notes/82.asciidoc deleted file mode 100644 index 401958b6c7..0000000000 --- a/docs/release_notes/82.asciidoc +++ /dev/null @@ -1,49 +0,0 @@ -[[release_notes_82]] -=== 8.2 Release notes - -[discrete] -[[release_notes_822]] -=== 8.2.2 Release notes - -- Updates dependency on `elastic-transport` to `~> 8.0` - - -[discrete] -[[release_notes_821]] -=== 8.2.1 Release notes - -No release, no changes on the client. - -[discrete] -[[release_notes_820]] -=== 8.2.0 Release notes - - -- Tested versions of Ruby for 8.2.0: Ruby (MRI) 2.7, 3.0 and 3.1, JRuby 9.3. - -[discrete] -==== API - -Updated for compatibility with Elasticsearch 8.2's API. - -[discrete] -===== New parameters: - -* `field_caps` -** `filters` An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent -** `types` Only return results for fields that have one of the types in the list - -[discrete] -===== New APIs - -- `cat.component_templates` - Returns information about existing component_templates templates. -- `ml.get_memory_stats` - Returns information on how ML is using memory. - -[discrete] -===== New Experimental APIs -- `security.activate_user_profile` - Creates or updates the user profile on behalf of another user. -- `security.disable_user_profile` - Disables a user profile so it's not visible in user profile searches. -- `security.enable_user_profile` - Enables a user profile so it's visible in user profile searches. -- `security.get_user_profile` - Retrieves a user profile for the given unique ID. -- `security.suggest_user_profiles` - Get suggestions for user profiles that match specified search criteria. -- `security.update_user_profile_data` - Update application specific data for the user profile of the given unique ID. diff --git a/docs/release_notes/83.asciidoc b/docs/release_notes/83.asciidoc deleted file mode 100644 index aa0b2d8d53..0000000000 --- a/docs/release_notes/83.asciidoc +++ /dev/null @@ -1,33 +0,0 @@ -[[release_notes_83]] -=== 8.3 Release notes - -[discrete] -[[release_notes_830]] -=== 8.3.0 Release notes - -- Tested versions of Ruby for 8.3.0: Ruby (MRI) 2.7, 3.0 and 3.1, JRuby 9.3. - -[discrete] -==== API - -- Added build hash to auto generated code. The code generator obtains the git hash from the Elasticsearch specification and adds it as a comment in the code. This allows us to track the version for each generated class. -- Updated for compatibility with Elasticsearch 8.3's API. - -[discrete] -===== API Changes - -* `cluster.delete_voting_config_exclusions`, `cluster.post_voting_config_exclusions` - Add new parameter `master_timeout` (Time) Timeout for submitting request to master. -* `machine_learning.infer_trained_model_deployment` is renamed to `machine_learning.infer_trained_model`. The url `/_ml/trained_models/{model_id}/deployment/_infer` is deprecated since 8.3, use `/_ml/trained_models/{model_id}/_infer` instead. -* `machine_learning.preview_datafeed` - Adds new parameters: -** `start` (String) The start time from where the datafeed preview should begin -** `end` (String) The end time when the datafeed preview should stop -* `machine_learning.start_trained_model_deployment` - Adds new parameters: -** `number_of_allocations` (Integer) The number of model allocations on each node where the model is deployed. -** `threads_per_allocation` (Integer) The number of threads used by each model allocation during inference. -** `queue_capacity` (Integer) Controls how many inference requests are allowed in the queue at a time. -* `search_mvt` - Adds new parameter: `with_labels` (Boolean) If true, the hits and aggs layers will contain additional point features with suggested label positions for the original features -* `snapshot.get` - Adds new parameter: `index_names` (Boolean) Whether to include the name of each index in the snapshot. Defaults to true. - -[discrete] -===== New Experimental APIs -* `security.has_privileges_user_profile` Determines whether the users associated with the specified profile IDs have all the requested privileges diff --git a/docs/release_notes/84.asciidoc b/docs/release_notes/84.asciidoc deleted file mode 100644 index 19901f675e..0000000000 --- a/docs/release_notes/84.asciidoc +++ /dev/null @@ -1,31 +0,0 @@ -[[release_notes_84]] -=== 8.4 Release notes - -[discrete] -[[release_notes_840]] -=== 8.4.0 Release notes - -- Tested versions of Ruby for 8.4.0: Ruby (MRI) 2.7, 3.0 and 3.1, JRuby 9.3. - -[discrete] -==== API - -[discrete] -===== New APIs - -* `security.update_api_key` - Updates attributes of an existing API key. https://www.elastic.co/guide/en/elasticsearch/reference/8.4/security-api-update-api-key.html[Documentation]. - -[discrete] -===== API Changes -* `get` - Adds new parameter `force_synthetic_source` (Boolean) Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. -* `machine_learning.start_trained_model_deployment` - Adds new parameter `cache_size` (String) A byte-size value for configuring the inference cache size. For example, 20mb. -* `mget` - Adds new parameter `force_synthetic_source` (Boolean) Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. -* `search` - Adds new parameter `force_synthetic_source` (Boolean) Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. -* `snapshot.get` - Adds new parameters: -** `sort` (String) Allows setting a sort order for the result. Defaults to start_time (options: start_time, duration, name, repository, index_count, shard_count, failed_shard_count). -** `size` (Integer) Maximum number of snapshots to return. Defaults to 0 which means return all that match without limit. -** `order` (String) Sort order (options: asc, desc). -** `from_sort_value` (String) Value of the current sort column at which to start retrieval. -** `after` (String) Offset identifier to start pagination from as returned by the 'next' field in the response body. -** `offset` (Integer) Numeric offset to start pagination based on the snapshots matching the request. Defaults to 0. -** `slm_policy_filter` (String) Filter snapshots by a comma-separated list of SLM policy names that snapshots belong to. Accepts wildcards. Use the special pattern '_none' to match snapshots without an SLM policy. diff --git a/docs/release_notes/85.asciidoc b/docs/release_notes/85.asciidoc deleted file mode 100644 index 4ba0e56497..0000000000 --- a/docs/release_notes/85.asciidoc +++ /dev/null @@ -1,105 +0,0 @@ -[[release_notes_85]] -=== 8.5 Release notes - -[discrete] -[[release_notes_852]] -=== 8.5.2 Release notes - -[discrete] -==== API Bugfix - -Fixes `security.create_service_token` API, uses `POST` when token name isn't present. -Thanks https://github.com/carlosdelest[@carlosdelest] for reporting in https://github.com/elastic/elasticsearch-ruby/pull/1961[#1961]. - -[discrete] -[[release_notes_851]] -=== 8.5.1 Release notes - -[discrete] -==== Bugfixes - -Fixes bug when instantiating client with `api_key`: When passing in `api_key` and `transport_options` that don't include headers to the client, the `api_key` code would overwrite the arguments passed in for `transport_options`. This was fixed in https://github.com/elastic/elasticsearch-ruby/pull/1941/files[this Pull Request]. -Thanks @svdasein for reporting in https://github.com/elastic/elasticsearch-ruby/issues/1940[#1940]. - -[discrete] -[[release_notes_850]] -=== 8.5.0 Release notes - -- Tested versions of Ruby for 8.5.0: Ruby (MRI) 2.7, 3.0 and 3.1, JRuby 9.3. - -[discrete] -==== Client - -With the latest release of `elastic-transport` - `v8.1.0` - this gem now supports Faraday v2. Elasticsearch Ruby has an open dependency on `elastic-transport` (`'elastic-transport', '~> 8'`), so when you upgrade your gems, `8.1.0` will be installed. This supports both Faraday v1 and Faraday v2. The main change on dependencies when using Faraday v2 is all adapters, except for the default `net_http` one, have been moved out of Faraday into separate gems. This means if you're not using the default adapter and you migrate to Faraday v2, you'll need to add the adapter gems to your Gemfile. - -These are the gems required for the different adapters with Faraday 2, instead of the libraries on which they were based: - -[source,ruby] ------------------------------------- -# HTTPCLient -gem 'faraday-httpclient' - -# NetHTTPPersistent -gem 'faraday-net_http_persistent' - -# Patron -gem 'faraday-patron' - -# Typhoeus -gem 'faraday-typhoeus' ------------------------------------- - -Things should work fine if you migrate to Faraday 2 as long as you include the adapter (unless you're using the default one `net-http`), but worst case scenario, you can always lock the version of Faraday in your project to 1.x: -gem 'faraday', '~> 1' - -Be aware if migrating to Faraday v2 that it requires at least Ruby `2.6`, unlike Faraday v1 which requires `2.4`. - -*Troubleshooting* - -If you see a message like: - -[source,ruby] ------------------------------------- -:adapter is not registered on Faraday::Adapter (Faraday::Error) ------------------------------------- -Then you probably need to include the adapter library in your gemfile and require it. - -Please https://github.com/elastic/elasticsearch-ruby/issues[submit an issue] if you encounter any problems. - -[discrete] -==== API - -[discrete] -===== New APIs - -- `machine_learning.clear_trained_model_deployment_cache` - Clear the cached results from a trained model deployment (Beta). -- `security.bulk_update_api_keys` - Updates the attributes of multiple existing API keys. - -[discrete] -===== API Changes - -- `rollup.rollup` renamed to `indices.downsample`. The method now receives the `index` to downsample (Required) and instead of `rollup_index`, use target_index as the index to store downsampled data. - -- `security.get_api_key` and `security.query_api_keys` add `:with_limited_by` flag to show the limited-by role descriptors of API Keys. -- `security.get_user` adds `:with_profile_uid` flag to retrieve profile uid (if exists) associated to the user. -- `security.get_user_profile` now retrieves user profiles for given unique ID(s). `:uid` is now a list of comma-separated list of unique identifier for user profiles. -- `text_structure.find_structure` adds `:ecs_compatibility`, optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled'. - -Machine learning APIs promoted from *Experimental* to *Beta*: - -- `machine_learning.clear_trained_model_deployment_cache.rb` -- `machine_learning.infer_trained_model.rb` -- `machine_learning.put_trained_model_definition_part.rb` -- `machine_learning.put_trained_model_vocabulary.rb` -- `machine_learning.start_trained_model_deployment.rb` -- `machine_learning.stop_trained_model_deployment.rb` - -Security usef profile APIs promoted from *Experimental* to *Stable*: - -- `security/activate_user_profile` -- `security/disable_user_profile` -- `security/enable_user_profile` -- `security/get_user_profile` -- `security/has_privileges_user_profile` -- `security/suggest_user_profile` -- `security/update_user_profile_data` diff --git a/docs/release_notes/86.asciidoc b/docs/release_notes/86.asciidoc deleted file mode 100644 index 88a7ad47d2..0000000000 --- a/docs/release_notes/86.asciidoc +++ /dev/null @@ -1,23 +0,0 @@ -[[release_notes_86]] -=== 8.6 Release notes - -[discrete] -[[release_notes_860]] -=== 8.6.0 Release notes - -- Tested versions of Ruby for 8.6.0: Ruby (MRI) 2.7, 3.0, 3.1 and **3.2**. JRuby 9.3 and **JRuby 9.4**. - -[discrete] -==== API - -[discrete] -===== New APIs - -- `update_trained_model_deployment` - Updates certain properties of trained model deployment (This functionality is in Beta and is subject to change). - -[discrete] -===== API Changes - -- `cluster.reroute` - `:metric` parameter adds `none` as an option. -- `ml.start_trained_model_deployment` - New parameter `:priority` (String), the deployment priority - diff --git a/docs/release_notes/87.asciidoc b/docs/release_notes/87.asciidoc deleted file mode 100644 index f58e0856c6..0000000000 --- a/docs/release_notes/87.asciidoc +++ /dev/null @@ -1,35 +0,0 @@ -[[release_notes_87]] -=== 8.7 Release notes - -[discrete] -[[release_notes_871]] -=== 8.7.1 Release notes - -[discrete] -==== API Bugfix - -- Updates `logstash.get_pipeline`, fixed in the specification `id` is not a required parameter, so removes raising `ArgumentError` when id is not present. - - -[discrete] -[[release_notes_870]] -=== 8.7.0 Release notes - -- Tested versions of Ruby for 8.7.0: Ruby (MRI) 2.7, 3.0, 3.1 and **3.2**. JRuby 9.3 and JRuby 9.4. Ruby 2.7's end of life is coming in a few days, so this'll probably be the last release to test for Ruby 2.7. - -[discrete] -==== API - -[discrete] -===== New APIs - -- `health_report` - Returns the health of the cluster. -- `transform.schedule_now_transform` - Schedules now a transform. - -[discrete] -===== API Changes - -- `transform.get_transform_stats` - Adds `timeout` (Time) parameter. Controls the time to wait for the stats. -- `transform.start_transform` - Adds `from` (String) parameter. Restricts the set of transformed entities to those changed after this time. -- `ml.delete_job`, `ml.reset_job` - Add `delete_user_annotations` (Boolean) parameter. Should annotations added by the user be deleted. -- `ml.clear_trained_model_deployment_cache`, `ml.infer_trained_model`, `ml.put_trained_model_definition_part`, `ml.put_trained_model_vocabulary`, `ml.start_trained_model_deployment`, `ml.stop_trained_model_deployment` - These APIs are no longer in Beta. diff --git a/docs/release_notes/88.asciidoc b/docs/release_notes/88.asciidoc deleted file mode 100644 index 13f093fd07..0000000000 --- a/docs/release_notes/88.asciidoc +++ /dev/null @@ -1,47 +0,0 @@ -[[release_notes_88]] -=== 8.8 Release notes - -[discrete] -[[release_notes_880]] -=== 8.8.0 Release notes - -- Tested versions of Ruby for 8.8.0: Ruby (MRI) 3.0, 3.1 and **3.2**. JRuby 9.3 and JRuby 9.4. - -[discrete] -==== API - -- Updates development dependency `minitest-reporters` to `>= 1.6` to include showing failures at the end of the test run. - -[discrete] -===== New APIs - -- `watcher.get_settings` - Retrieve settings for the watcher system index. -- `watcher.update_settings` - Update settings for the watcher system index. - -[discrete] -===== New Experimental APIs - -- `indices.delete_data_lifecycle`- Deletes the data lifecycle of the selected data streams -- `indices.explain_data_lifecycle` - Retrieves information about the index's current DLM lifecycle, such as any potential encountered error, time since creation etc. -- `indices.get_data_lifecycle` - Returns the data lifecycle of the selected data streams. -- `indices.put_data_lifecycle` - Updates the data lifecycle of the selected data streams. -- `search_application.delete` - Deletes a search application. -- `search_application.delete_behavioral_analytics` - Delete a behavioral analytics collection. -- `search_application.get` - Returns the details about a search application. -- `search_application.get_behavioral_analytics` - Returns the existing behavioral analytics collections. -- `search_application.list` - Returns the existing search applications. -- `search_application.post_behavioral_analytics_event` - Creates a behavioral analytics event for existing collection. -- `search_application.put` - Creates or updates a search application. -- `search_application.put_behavioral_analytics` - Creates a behavioral analytics collection. -- `search_application.search` - Perform a search against a search application. - -[discrete] -===== API Changes - -- `clear_scroll` now works with the argument `ignore: 404`. https://github.com/elastic/elasticsearch-ruby/issues/2067[Issue on GitHub]. -- The code generator was updated to fix a bug for `ignore: 404`. APIs that were supposed to support this wouldn't parse the parameters correctly. The support it now: `security.get_role`, `watcher.delete_watch` -- `cluster.get_component_template`, `indices.get_data_stream`, `indices.get_index_template`, `indices.simulate_index_template`, `indices.simulate_template` - Add `include_defaults` (Boolean) parameter: Return all default configurations for the component template (default: false). -- `machine_learning.put_trained_model` - Adds `wait_for_completion` (Boolean) parameter: Whether to wait for all child operations(e.g. model download) to complete, before returning or not (default: false). -- `machine_learning.start_trained_model_deployment` - Adds `deployiment_id` (String) parameter: The Id of the new deployment. Defaults to the model_id if not set. -- `search` - Adds `include_named_queries_score` (Boolean) parameter: 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). -- `transform.delete_transform` - Adds `delete_dest_index` (Boolean) parameter: When `true`, the destination index is deleted together with the transform. The default value is `false`, meaning that the destination index will not be deleted. diff --git a/docs/release_notes/89.asciidoc b/docs/release_notes/89.asciidoc deleted file mode 100644 index de0f431856..0000000000 --- a/docs/release_notes/89.asciidoc +++ /dev/null @@ -1,54 +0,0 @@ -[[release_notes_89]] -=== 8.9 Release notes - -[discrete] -[[release_notes_890]] -=== 8.9.0 Release notes - -[discrete] -=== Client -* Tested versions of Ruby for 8.9.0: Ruby (MRI) 3.0, 3.1 and 3.2. JRuby 9.3 and JRuby 9.4. -* Updated product validation. The code for the product validation was refactored in a few ways: -** Just check header, does not check the version of the server. -** Warns only once when there's a general server error. -** Removes the call to '/' (client.info) when doing the first request, checking on the first actual request from the client. -* Fixes User-Agent code. In the migration to 8.x, the user agent code was extracted into transport, since we're now using that library in other projects. So for the Elasticsearch Client, the user-agent would be reported as the one defined in elastic-transport. This release fixes the issue and brings back the user agent in the format that was being used in 7.x - -[discrete] -=== Helpers -This release introduces two new Helpers in the client: - -* BulkHelper - This helper provides a better developer experience when using the Bulk API. At its simplest, you can send it a collection of hashes in an array, and it will bulk ingest them into {es}. -* ScrollHelper - This helper provides an easy way to get results from a Scroll. - -See <> to read more about them. - -[discrete] -=== API - -[discrete] -==== New APIs - -* `cluster.info` - Returns different information about the cluster. - -[discrete] -==== New Experimental APIs and namespaces: - -This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. - -* New namespace: `query_ruleset` -** `query_ruleset.delete` - Deletes a query ruleset. -** `query_ruleset.get` - Returns the details about a query ruleset. -** `query_ruleset.put` - Creates or updates a query ruleset. -* New API: `search_application.render_query` Renders a query for given search application search parameters. -* New API: `security.create_cross_cluster_api_key` - Creates a cross-cluster API key for API key based remote cluster access. -* New API: `security.upate_cross_cluster_api_key` - Updates attributes of an existing cross-cluster API key. -* New namespace: `synonyms` -** `synonyms.delete`- Deletes a synonym set -** `synonyms.get` - Retrieves a synonym set -** `synonyms.put` - Creates or updates a synonyms set -* New namespace: `synonym_rule` -** `synonym_rule.put` - Creates or updates a synonym rule in a synonym set -* New namespace: `synonyms` -** `synonyms_set.get` - Retrieves a summary of all defined synonym sets - diff --git a/docs/release_notes/index.asciidoc b/docs/release_notes/index.asciidoc deleted file mode 100644 index 50c38f3b57..0000000000 --- a/docs/release_notes/index.asciidoc +++ /dev/null @@ -1,57 +0,0 @@ -[[release_notes]] -== Release Notes - -[discrete] -=== 8.x -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> - -[discrete] -=== 7.x -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> -* <> - -include::89.asciidoc[] -include::88.asciidoc[] -include::87.asciidoc[] -include::86.asciidoc[] -include::85.asciidoc[] -include::84.asciidoc[] -include::83.asciidoc[] -include::82.asciidoc[] -include::81.asciidoc[] -include::80.asciidoc[] -include::717.asciidoc[] -include::716.asciidoc[] -include::715.asciidoc[] -include::714.asciidoc[] -include::713.asciidoc[] -include::712.asciidoc[] -include::711.asciidoc[] -include::710.asciidoc[] -include::79.asciidoc[] -include::78.asciidoc[] -include::77.asciidoc[] -include::76.asciidoc[] -include::75.asciidoc[] -include::70.asciidoc[] diff --git a/docs/transport.asciidoc b/docs/transport.asciidoc deleted file mode 100644 index b9199b19ed..0000000000 --- a/docs/transport.asciidoc +++ /dev/null @@ -1,284 +0,0 @@ -[[transport]] -=== Transport - -The `elastic-transport` library provides a low-level Ruby client for connecting to an {es} cluster. It currently powers the https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html[Elasticsearch Ruby] and the https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/index.html[Enterprise Search Ruby] clients. - -When available, it handles connecting to multiple nodes in the cluster, rotating across connections, logging and tracing requests and responses, maintaining failed connections, discovering nodes in the cluster, and provides an abstraction for data serialization and transport. - -It does not handle calling the {es} or Enterprise Search APIs. - -This library uses https://github.com/lostisland/faraday[Faraday] by default as the HTTP transport implementation. We test it with Faraday versions 1.x and 2.x. - -For optimal performance, use a HTTP library which supports persistent ("keep-alive") connections, such as https://github.com/toland/patron[patron] or https://github.com/typhoeus/typhoeus[Typhoeus]. Require the library (`require 'patron'`) in your code for Faraday 1.x or the adapter (`require 'faraday/patron'`) for Faraday 2.x, and it will be automatically used. - -Currently these libraries are supported: - -* https://github.com/toland/patron[Patron] -* https://github.com/typhoeus/typhoeus[Typhoeus] -* https://rubygems.org/gems/httpclient[HTTPClient] -* https://rubygems.org/gems/net-http-persistent[Net::HTTP::Persistent] - -NOTE: Use https://github.com/typhoeus/typhoeus[Typhoeus] v1.4.0 or up since older versions are not compatible with Faraday 1.0. - -You can customize Faraday and implement your own HTTP transport. For detailed information, see the example configurations and more information <>. - -Features overview: - -* Pluggable logging and tracing -* Pluggable connection selection strategies (round-robin, random, custom) -* Pluggable transport implementation, customizable and extendable -* Pluggable serializer implementation -* Request retries and dead connections handling -* Node reloading (based on cluster state) on errors or on demand - -Refer to <> to read about more configuration options. - -[discrete] -[[transport-install]] -==== Installation - -Install the package from https://rubygems.org/[Rubygems]: - -[source,bash] ----------------------------- -gem install elastic-transport ----------------------------- - -To use an unreleased version, either add it to your `Gemfile` for -http://gembundler.com/[Bundler]: - -[source,bash] ----------------------------- -gem 'elastic-transport', git: 'git@github.com:elastic/elastic-transport-ruby.git' ----------------------------- - -or install it from a source code checkout: - -[source,bash] ----------------------------- -git clone https://github.com/elastic/elastic-transport-ruby.git -cd elastic-transport -bundle install -rake install ----------------------------- - -[discrete] -[[transport-example-usage]] -==== Example usage - -In the simplest form, connect to {es} running on http://localhost:9200 without any configuration: - -[source,rb] ----------------------------- -require 'elastic/transport' - -client = Elastic::Transport::Client.new -response = client.perform_request('GET', '_cluster/health') -# => # ----------------------------- - -Documentation is included as RDoc annotations in the source code and available online at http://rubydoc.info/gems/elastic-transport[RubyDoc]. - -[discrete] -[[transport-implementations]] -==== Transport implementations - -By default, the client uses the https://rubygems.org/gems/faraday[Faraday] HTTP library as a transport implementation. - -The Client auto-detects and uses an _adapter_ for _Faraday_ based on gems loaded in your code, preferring HTTP clients with support for persistent connections. Faraday 2 changed the way adapters are used (https://github.com/lostisland/faraday/blob/main/UPGRADING.md#adapters-have-moved[read more here]). If you're using Faraday 1.x, you can require the HTTP library. To use the https://github.com/toland/patron[_Patron_] HTTP, for example, require it: - - -To use the https://github.com/toland/patron[Patron] HTTP, for example, require it: - -[source,rb] ----------------------------- -require 'patron' ----------------------------- - -If you're using Faraday 2.x, you need to add the corresponding adapter gem to your Gemfile and require it after you require `faraday`: - -[source,rb] ----------------------------- -# Gemfile -gem 'faraday-patron' - -# Code -require 'faraday' -require 'faraday/patron' ----------------------------- - - -Then, create a new client, and the Patron gem will be used as the "driver": - -[source,rb] ----------------------------- -client = Elastic::Transport::Client.new - -client.transport.connections.first.connection.builder.adapter -# => Faraday::Adapter::Patron - -10.times do - client.nodes.stats(metric: 'http')['nodes'].values.each do |n| - puts "#{n['name']} : #{n['http']['total_opened']}" - end -end - -# => Stiletoo : 24 -# => Stiletoo : 24 -# => Stiletoo : 24 -# => ... ----------------------------- - -To use a specific adapter for Faraday, pass it as the `adapter` argument: - -[source,rb] ----------------------------- -client = Elastic::Client.new(adapter: :net_http_persistent) - -client.transport.connections.first.connection.builder.handlers -# => [Faraday::Adapter::NetHttpPersistent] ----------------------------- - -If you see this error: - -[source,rb] ----------------------------- -Faraday::Error: :net_http_persistent is not registered on Faraday::Adapter ----------------------------- -When you're using Faraday 2, you need to require the adapter before instantiating the client: - -[source,rb] ----------------------------- -> client = Elasticsearch::Client.new(adapter: :net_http_persistent) -Faraday::Error: :net_http_persistent is not registered on Faraday::Adapter -> require 'faraday/net_http_persistent' -=> true -> client = Elasticsearch::Client.new(adapter: :net_http_persistent) -=> # 'yaml' }, - ssl: { verify: false } - } -) ----------------------------- - -To configure the Faraday instance directly, use a block: - -[source,rb] ----------------------------- -require 'patron' - -client = Elastic::Client.new(host: 'localhost', port: '9200') do |f| - f.response :logger - f.adapter :patron -end ----------------------------- - -You can use any standard Faraday middleware and plugins in the configuration block. - -You can also initialize the transport class yourself, and pass it to the client constructor as the `transport` argument. The Elasticsearch and Enterprise Search clients accept `:transport` as parameter when initializing a client. So you can pass in a transport you've initialized with the following options: - -[source,rb] ----------------------------- -require 'patron' - -transport_configuration = lambda do |f| - f.response :logger - f.adapter :patron -end - -transport = Elastic::Transport::Transport::HTTP::Faraday.new( - hosts: [ { host: 'localhost', port: '9200' } ], - &transport_configuration -) - -# Pass the transport to the client -# -client = Elastic::Client.new(transport: transport) ----------------------------- - -Instead of passing the transport to the constructor, you can inject it at run time: - -[source,rb] ----------------------------- -# Set up the transport -# -faraday_configuration = lambda do |f| - f.instance_variable_set :@ssl, { verify: false } - f.adapter :excon -end - -faraday_client = Elastic::Transport::Transport::HTTP::Faraday.new( - hosts: [ - { - host: 'my-protected-host', - port: '443', - user: 'USERNAME', - password: 'PASSWORD', - scheme: 'https' - } - ], - &faraday_configuration -) - -# Create a default client -# -client = Elastic::Client.new - -# Inject the transport to the client -# -client.transport = faraday_client ----------------------------- - -You can also use a bundled https://rubygems.org/gems/curb[Curb] based transport implementation: - -[source,rb] ----------------------------- -require 'curb' -require 'elastic/transport/transport/http/curb' - -client = Elastic::Client.new(transport_class: Elastic::Transport::Transport::HTTP::Curb) - -client.transport.connections.first.connection -# => # ----------------------------- - -It's possible to customize the Curb instance by passing a block to the constructor as well (in this case, as an inline block): - -[source,rb] ----------------------------- -transport = Elastic::Transport::Transport::HTTP::Curb.new( - hosts: [ { host: 'localhost', port: '9200' } ], - & lambda { |c| c.verbose = true } -) - -client = Elastic::Client.new(transport: transport) ----------------------------- - -You can write your own transport implementation by including the {Elastic::Transport::Transport::Base} module, implementing the required contract, and passing it to the client as the `transport_class` parameter – or by injecting it directly. - -[discrete] -[[transport-architecture]] -==== Transport architecture - -* `Elastic::Transport::Client` is composed of `Elastic::Transport::Transport`. -* `Elastic::Transport::Transport` is composed of `Elastic::Transport::Transport::Connections`, and an instance of logger, tracer, serializer and sniffer. -* Logger and tracer can be any object conforming to Ruby logging interface, for example, an instance of https://ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html[`Logger`], https://rubygems.org/gems/log4r[log4r], https://github.com/TwP/logging/[logging], and so on. -* The `Elastic::Transport::Transport::Serializer::Base` implementations handle converting data for {es} (for example, to JSON). You can implement your own serializer. -* `Elastic::Transport::Transport::Sniffer` allows to discover nodes in the cluster and use them as connections. -* `Elastic::Transport::Transport::Connections::Collection` is composed of `Elastic::Transport::Transport::Connections::Connection` instances and a selector instance. -* `Elastic::Transport::Transport::Connections::Connection` contains the connection attributes such as hostname and port, as well as the concrete persistent "session" connected to a specific node. -* The `Elastic::Transport::Transport::Connections::Selector::Base` implementations allow to choose connections from the pool, for example, in a round-robin or random fashion. You can implement your own selector strategy. -* The `Elastic::Transport::Transport::Response` object wraps the Elasticsearch JSON response. It provides `body`, `status`, and `headers` methods but you can treat it as a hash and access the keys directly. diff --git a/docs/troubleshooting.asciidoc b/docs/troubleshooting.asciidoc deleted file mode 100644 index 9b889f51bd..0000000000 --- a/docs/troubleshooting.asciidoc +++ /dev/null @@ -1,29 +0,0 @@ -[[troubleshooting]] -== Troubleshooting - -The client provides several options for logging that can help when things go wrong. Check out the extensive documentation on <>. - -If you are having trouble sending a request to {es} with the client, we suggest enabling `tracing` on the client and testing the cURL command that appears in your terminal: - -[source,rb] ----------------------------- -client = Elasticsearch::Client.new(trace: true) -client.info -curl -X GET -H 'x-elastic-client-meta: es=8.9.0,rb=3.2.2,t=8.2.1,fd=2.7.4,nh=0.3.2, User-Agent: elastic-t -ransport-ruby/8.2.1 (RUBY_VERSION: 3.2.2; linux x86_64; Faraday v2.7.4), Content-Type: application/json' 'http://localhost:9200//?pretty' ----------------------------- - -Testing the cURL command can help find out if there's a connection issue or if the issue is in the client code. - -[discrete] -=== Connection -When working with multiple hosts, you might want to enable the `retry_on_failure` or `retry_on_status` options to perform a failed request on another node (refer to <>). - -For optimal performance, use a HTTP library which supports persistent ("keep-alive") connections, such as https://github.com/toland/patron[patron] or https://github.com/typhoeus/typhoeus[Typhoeus]. Require the library (`require 'patron'`) in your code for Faraday 1.x or the adapter (`require 'faraday/patron'`) for Faraday 2.x, and it will be automatically used. - -[discrete] -=== More Help - -If you need more help, you can hop on our https://discuss.elastic.co/[Elastic community forums] and get answers from the experts in the community, including people from Elastic. - -If you find a bug, have feedback, or find any other issue using the client, please https://github.com/elastic/elasticsearch-ruby/issues/new/choose[submit an issue] on GitHub. diff --git a/elasticsearch-api/.gitignore b/elasticsearch-api/.gitignore index d87d4be66f..fc492d778b 100644 --- a/elasticsearch-api/.gitignore +++ b/elasticsearch-api/.gitignore @@ -2,6 +2,7 @@ *.rbc .bundle .config +.env .yardoc Gemfile.lock InstalledFiles diff --git a/elasticsearch-api/Gemfile b/elasticsearch-api/Gemfile index 74ca453845..6f2646fa20 100644 --- a/elasticsearch-api/Gemfile +++ b/elasticsearch-api/Gemfile @@ -20,8 +20,8 @@ source 'https://rubygems.org' # Specify your gem's dependencies in elasticsearch-api.gemspec gemspec -if File.exist? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__) - gem 'elasticsearch', path: File.expand_path('../../elasticsearch', __FILE__), require: false +if File.exist? File.expand_path('../elasticsearch/elasticsearch.gemspec', __dir__) + gem 'elasticsearch', path: File.expand_path('../elasticsearch', __dir__), require: false end group :development do @@ -30,6 +30,6 @@ group :development do if defined?(JRUBY_VERSION) gem 'pry-nav' else - gem 'pry-byebug' + gem 'debug' end end diff --git a/elasticsearch-api/README.md b/elasticsearch-api/README.md index 94ff4c86f1..7c175ebcac 100644 --- a/elasticsearch-api/README.md +++ b/elasticsearch-api/README.md @@ -4,7 +4,7 @@ **Refer to the [official documentation on Elasticsearch API](https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/api.html).** -The `elasticsearch-api` library provides a Ruby implementation of the [Elasticsearch](http://elasticsearch.com) REST API. It does not provide an Elasticsearch client; see the [`elastic-transport`](https://github.com/elastic/elastic-transport-ruby/) library. +The `elasticsearch-api` library provides a Ruby implementation of the [Elasticsearch](http://elasticsearch.com) REST API. It does not provide an Elasticsearch client. See [elasticsearch](https://github.com/elastic/elasticsearch-ruby) and the [`elastic-transport`](https://github.com/elastic/elastic-transport-ruby/) libraries for a full Elasticsearch client and HTTP transport layer respectively. We follow Ruby’s own maintenance policy and officially support all currently maintained versions per [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/). @@ -15,17 +15,21 @@ Language clients are forward compatible; meaning that clients support communicat Refer to [CONTRIBUTING](https://github.com/elastic/elasticsearch-ruby/blob/main/CONTRIBUTING.md). -We run the test suite for Elasticsearch's Rest API tests. You can read more about this in [the test runner README](https://github.com/elastic/elasticsearch-ruby/tree/main/api-spec-testing#rest-api-yaml-test-runner). +Use `bundle exec rake test:unit` to run Unit tests. Add the environment variable `COVERAGE` to see Simplecov test coverage. -The `rest_api` task needs the test files from Elasticsearch. You can run the rake task to download the test artifacts in the root folder of the project. You can pass in a version to the task as a parameter: +The integration tests on this project run the [Elasticsearch Client tests](https://github.com/elastic/elasticsearch-clients-tests/) with the [Elasticsearch Tests Runner](https://github.com/elastic/es-test-runner-ruby/) library. You can run a docker container with Elasticsearch with a Rake task from the root directory of this project: -`rake download_artifacts[8.5.0-SNAPSHOT]` +```bash +$ rake es:up +``` -Or it can get the version from a running cluster to determine which version and build hash of Elasticsearch to use and test against: +This will start whatever version of Elasticsearch is set in the Buildkite pipeline file (`../.buildkite/pipeline.yml`) with security enabled. You can also specify a version and a suite ('free' or 'platinum' for security disabled/enabled): -`TEST_ES_SERVER=http://localhost:9200 rake elasticsearch:download_artifacts` +```bash +$ rake es:start[version,suite] # e.g. rake es:start[9.0.0-SNAPSHOT, free] +``` -This will download the necessary files used for the integration tests to `./tmp`. +You can run the integration tests with `bundle exec rake test:integration`. ### Code generation diff --git a/elasticsearch-api/Rakefile b/elasticsearch-api/Rakefile index acbe366852..957016d205 100644 --- a/elasticsearch-api/Rakefile +++ b/elasticsearch-api/Rakefile @@ -32,16 +32,10 @@ namespace :test do end desc 'Run unit tests' - task unit: :spec - RSpec::Core::RakeTask.new(:spec) do |t| - t.pattern = 'spec/elasticsearch/api/**/*_spec.rb' - t.exclude_pattern = 'spec/platinum/**/*_spec.rb' - end - - desc 'Run Rest API Spec tests' - RSpec::Core::RakeTask.new(:rest_api) do |t| - test_dir = Rake.application.original_dir - t.pattern = "#{test_dir}/spec/rest_api/rest_api_yaml_spec.rb" + task :unit + RSpec::Core::RakeTask.new(:unit) do |t| + t.pattern = 'spec/unit/**/*_spec.rb' + t.exclude_pattern = 'spec/unit/perform_request_spec.rb' unless ENV['TEST_WITH_OTEL'] end desc 'Run unit and integration tests' @@ -50,27 +44,27 @@ namespace :test do Rake::Task['test:integration'].invoke end - namespace :platinum do - desc 'Run Platinum Rest API Spec tests' - RSpec::Core::RakeTask.new(:api) do - ENV['TEST_SUITE'] = 'platinum' - Rake::Task['test:rest_api'].invoke - end - - desc 'Run Platinum Unit tests - DEPRECATED: Will be migrated to RSpec' - Rake::TestTask.new(:unit) do |test| - test.libs << 'spec/platinum/unit' - test.test_files = FileList['spec/platinum/unit/**/*_test.rb'] - test.verbose = false - test.warning = false - end + desc 'Run tests with yaml runner' + task :yaml do + ruby './spec/yaml-test-runner/run.rb' + end - desc 'Run Platinum Integration Specs' - RSpec::Core::RakeTask.new(:integration) do |t| - exit(0) unless ENV['TEST_SUITE'] == 'platinum' + desc 'Run Integration tests' + RSpec::Core::RakeTask.new(:integration) do |t| + t.pattern = 'spec/integration/**/*_spec.rb' + end - t.pattern = 'spec/platinum/integration/**/*_spec.rb' - t.ruby_opts = '-W0' + # This is the task to run the Elasticsearch REST tests which we stopped using for 9.x. + # Use the environment variable TEST_SUITE to choose between 'free' and 'platinum' tests. For + # platinum, the test cluster needs to have the license activated and run with security enabled. + # For 'free', security must be disabled in the test cluster. + # + namespace :deprecated do + # TODO: TEST_SUITE + desc 'Run Elasticsearch test suite free tests.' + RSpec::Core::RakeTask.new(:rest_api) do |t| + test_dir = Rake.application.original_dir + t.pattern = "#{test_dir}/spec/rest_api/rest_api_yaml_spec.rb" end end end diff --git a/elasticsearch-api/api-spec-testing/README.md b/elasticsearch-api/api-spec-testing/README.md index a1dcffce0d..0e03647e40 100644 --- a/elasticsearch-api/api-spec-testing/README.md +++ b/elasticsearch-api/api-spec-testing/README.md @@ -1,6 +1,10 @@ # Rest API YAML Test Runner -The specs in `elasticsearch-api` automatically run the tests from [Elasticsearch's REST API Spec tests](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/test#test-suite). The test runner is defined in the `spec` folder, starting with the `rest_api_yaml_spec.rb` file. +The integration tests on this project run the [Elasticsearch Client tests](https://github.com/elastic/elasticsearch-clients-tests/) with the [Elasticsearch Tests Runner](https://github.com/elastic/es-test-runner-ruby/) library. This runs in CI against an Elasticsearch cluster in Docker. The [Elasticsearch's REST API Spec tests](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/test#test-suite) can still be ran following the instructions below: + +## Elasticsearch Test Suite + +The specs in `elasticsearch-api` can run the tests from [Elasticsearch's REST API Spec tests](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/test#test-suite). The test runner is defined in the `spec` folder, starting with the `rest_api_yaml_spec.rb` file. You can run the tests with Rake. The main task is `rake test:rest_api`. This task will evaluate the `TEST_SUITE` environment variable. It will run either the `free` or `platinum` tests suites depending on the value of `TEST_SUITE`. If you don't set this value, the task will run the `free` test suite by default. To run the `platinum` test suite use: ``` diff --git a/elasticsearch-api/api-spec-testing/rspec_matchers.rb b/elasticsearch-api/api-spec-testing/rspec_matchers.rb index 93e3612d39..cb8db34b5d 100644 --- a/elasticsearch-api/api-spec-testing/rspec_matchers.rb +++ b/elasticsearch-api/api-spec-testing/rspec_matchers.rb @@ -106,7 +106,6 @@ RSpec::Matchers.define :match_gt_field do |expected_pairs, test| match do |response| expected_pairs.all? do |expected_key, expected_value| - split_key = TestFile::Test.split_and_parse_key(expected_key).collect do |k| test.get_cached_value(k) end @@ -128,7 +127,6 @@ RSpec::Matchers.define :match_lte_field do |expected_pairs, test| match do |response| expected_pairs.all? do |expected_key, expected_value| - split_key = TestFile::Test.split_and_parse_key(expected_key).collect do |k| test.get_cached_value(k) end @@ -150,7 +148,6 @@ RSpec::Matchers.define :match_lt_field do |expected_pairs, test| match do |response| expected_pairs.all? do |expected_key, expected_value| - split_key = TestFile::Test.split_and_parse_key(expected_key).collect do |k| test.get_cached_value(k) end @@ -177,7 +174,7 @@ failure_message do |response| "the expected response pair/value(s) #{@mismatched_pairs}" + - " does not match the pair/value(s) in the response #{response}" + " does not match the pair/value(s) in the response #{response}" end def sanitize_pairs(expected_pairs) @@ -238,13 +235,21 @@ def compare_hash(expected_pairs, actual_hash, test) when Hash compare_hash(expected_value, actual_value, test) when Array - unless compare_array(expected_value, actual_value, test, actual_hash) - @mismatched_pairs.merge!(expected_key => expected_value) + begin + unless compare_array(expected_value.sort, actual_value.sort, test, actual_hash) + @mismatched_pairs.merge!(expected_key => expected_value) + end + rescue TypeError, ArgumentError + unless compare_array(expected_value, actual_value, test, actual_hash) + @mismatched_pairs.merge!(expected_key => expected_value) + end end when String unless compare_string(expected_value, actual_value, test, actual_hash) @mismatched_pairs.merge!(expected_key => expected_value) end + when Time + compare_string(expected_value.to_s, Time.new(actual_value).to_s, test, actual_hash) else unless expected_value == actual_value @mismatched_pairs.merge!(expected_key => expected_value) @@ -284,6 +289,8 @@ def compare_array(expected, actual, test, response) return false unless compare_array(value, actual[i], test, response) when String return false unless compare_string(value, actual[i], test, response) + else + true end end end @@ -300,7 +307,8 @@ def compare_string_response(expected_string, response) # Remove surrounding '/' in string representing Regex expected_error = expected_error.chomp("/") expected_error = expected_error[1..-1] if expected_error =~ /^\// - message = actual_error.message.tr("\\","") + + message = actual_error.message.tr('\\', '') case expected_error when 'request_timeout' @@ -315,12 +323,12 @@ def compare_string_response(expected_string, response) message =~ /\[400\]/ when 'param' message =~ /\[400\]/ || - actual_error.is_a?(ArgumentError) + actual_error.is_a?(ArgumentError) when 'unauthorized' actual_error.is_a?(Elastic::Transport::Transport::Errors::Unauthorized) when 'forbidden' actual_error.is_a?(Elastic::Transport::Transport::Errors::Forbidden) - when /error parsing field/ + when /error parsing field/, /illegal_argument_exception/ message =~ /\[400\]/ || actual_error.is_a?(Elastic::Transport::Transport::Errors::BadRequest) when /NullPointerException/ diff --git a/elasticsearch-api/api-spec-testing/test_file.rb b/elasticsearch-api/api-spec-testing/test_file.rb index a4e88119db..41d97a775a 100644 --- a/elasticsearch-api/api-spec-testing/test_file.rb +++ b/elasticsearch-api/api-spec-testing/test_file.rb @@ -76,10 +76,9 @@ def skip_entire_test_file?(file_name) def skip_version?(client, skip_definition) return true if skip_definition.fetch('version', '').include? 'all' - range_partition = /\s*-\s*/ return unless (versions = skip_definition['version']) - low, high = __parse_versions(versions.partition(range_partition)) + low, high = __parse_versions(versions) range = low..high begin server_version = client.info['version']['number'] @@ -90,7 +89,13 @@ def skip_version?(client, skip_definition) end def __parse_versions(versions) - versions = versions.split('-') if versions.is_a? String + if versions.count('-') == 2 + versions = versions.gsub(/\s/, '').gsub(/-/, '').split(',') + else + range_partition = /\s*-\s*/ + versions = versions.partition(range_partition) + versions = versions.split('-') if versions.is_a? String + end low = (['', nil].include? versions[0]) ? '0' : versions[0] high = (['', nil].include? versions[2]) ? '9999' : versions[2] @@ -157,6 +162,7 @@ def run_actions_and_retry(actions) action.execute(client) true rescue Elastic::Transport::Transport::Errors::RequestTimeout, + Net::ReadTimeout, # TODO: Replace this if we change adapters Elastic::Transport::Transport::Errors::ServiceUnavailable => e # The action sometimes gets the cluster in a recovering state, so we # retry a few times and then raise an exception if it's still diff --git a/elasticsearch-api/api-spec-testing/test_file/action.rb b/elasticsearch-api/api-spec-testing/test_file/action.rb index 7db913419d..22dfdd2a99 100644 --- a/elasticsearch-api/api-spec-testing/test_file/action.rb +++ b/elasticsearch-api/api-spec-testing/test_file/action.rb @@ -37,6 +37,7 @@ class Action # @since 6.2.0 def initialize(definition) @definition = definition + @retries = 0 end # Execute the action. The method returns the client, in case the action created a new client @@ -66,71 +67,9 @@ def execute(client, test = nil) shadow_client.send(method) end end - _method = chain[-1] - case _method - when 'bulk' - arguments = prepare_arguments(args, test) - arguments[:body].map! do |item| - if item.is_a?(Hash) - item - elsif item.is_a?(String) - symbolize_keys(JSON.parse(item)) - end - end if arguments[:body].is_a? Array - @response = client.send(_method, arguments) - client - when 'headers' - headers = prepare_arguments(args, test) - host = client.transport.instance_variable_get('@hosts') - transport_options = client.transport.instance_variable_get('@options')&.dig(:transport_options) || {} - if ENV['QUIET'] == 'true' - # todo: create a method on Elasticsearch::Client that can clone the client with new options - Elasticsearch::Client.new( - host: host, - transport_options: transport_options.merge(headers: headers) - ) - else - Elasticsearch::Client.new( - host: host, - tracer: Logger.new($stdout), - transport_options: transport_options.merge(headers: headers) - ) - end - when 'catch', 'warnings', 'allowed_warnings', 'allowed_warnings_regex' - client - when 'put_trained_model_alias' - args.merge!('reassign' => true) unless args['reassign'] === false - @response = client.send(_method, prepare_arguments(args, test)) - client - when 'create' - begin - @response = client.send(_method, prepare_arguments(args, test)) - rescue Elastic::Transport::Transport::Errors::BadRequest => e - case e.message - when /resource_already_exists_exception/ - client.delete(index: args['index']) - when /failed to parse date field/ - body = args['body'] - time_series = body['settings']['index']['time_series'] - time_series.each { |k, v| time_series[k] = v.strftime("%FT%TZ") } - args['body'] = body - else - raise e - end - @response = client.send(_method, prepare_arguments(args, test)) - end - client - when 'update_user_profile_data', 'get_user_profile', 'enable_user_profile', 'disable_user_profile' - args.each do |key, value| - args[key] = value.gsub(value, test.cached_values[value.gsub('$', '')]) if value.match?(/^\$/) - end - @response = client.send(_method, prepare_arguments(args, test)) - client - else - @response = client.send(_method, prepare_arguments(args, test)) - client - end + + perform_action(_method, args, client, test) end end end @@ -188,6 +127,69 @@ def perform_internal(method, args, client, test) client end + def perform_action(method, args, client, test) + case method + when 'bulk' + arguments = prepare_arguments(args, test) + arguments[:body].map! do |item| + if item.is_a?(Hash) + item + elsif item.is_a?(String) + symbolize_keys(JSON.parse(item)) + end + end if arguments[:body].is_a? Array + @response = client.send(method, arguments) + client + when 'headers' + transport_options = client.transport.instance_variable_get('@options')&.dig(:transport_options) || {} + Elasticsearch::Client.new( + hosts: client.transport.hosts, + tracer: client.transport.tracer || nil, + transport_options: transport_options.merge(headers: prepare_arguments(args, test)) + ) + when 'put_trained_model_alias' + args.merge!('reassign' => true) unless args['reassign'] === false + @response = client.send(method, prepare_arguments(args, test)) + client + when 'create' + begin + @response = client.send(method, prepare_arguments(args, test)) + rescue Elastic::Transport::Transport::Errors::BadRequest => e + case e.message + when /resource_already_exists_exception/ + client.delete(index: args['index']) + when /failed to parse date field/ + body = args['body'] + time_series = body['settings']['index']['time_series'] + time_series.each { |k, v| time_series[k] = v.strftime("%FT%TZ") } + args['body'] = body + else + raise e + end + @response = client.send(method, prepare_arguments(args, test)) + end + client + when 'update_user_profile_data', 'get_user_profile', 'enable_user_profile', 'disable_user_profile' + args.each do |key, value| + args[key] = value.gsub(value, test.cached_values[value.gsub('$', '')]) if value.match?(/^\$/) + end + @response = client.send(method, prepare_arguments(args, test)) + client + when 'catch', 'warnings', 'allowed_warnings', 'allowed_warnings_regex', 'warnings_regex' + client + else + @response = client.send(method, prepare_arguments(args, test)) + client + end + rescue Elastic::Transport::Transport::Error => e + if e.message.match(/Net::ReadTimeout/) && @retries <= 5 + @retries += 1 + perform_action(method, args, client, test) + else + raise e + end + end + def prepare_arguments(args, test) symbolize_keys(args).tap do |args| if test diff --git a/elasticsearch-api/api-spec-testing/test_file/task_group.rb b/elasticsearch-api/api-spec-testing/test_file/task_group.rb index c7e6e0c10c..1af199ac73 100644 --- a/elasticsearch-api/api-spec-testing/test_file/task_group.rb +++ b/elasticsearch-api/api-spec-testing/test_file/task_group.rb @@ -15,6 +15,8 @@ # specific language governing permissions and limitations # under the License. +require 'base64' + module Elasticsearch module RestAPIYAMLTests class TestFile @@ -102,7 +104,7 @@ def run(client) def response @response ||= begin if do_actions.any? { |a| a.yaml_response? } - YAML.load(do_actions[-1].response) + YAML.load(do_actions[-1].response.body) else do_actions[-1].response end @@ -282,6 +284,7 @@ def length_match_clauses ACTIONS = (Test::GROUP_TERMINATORS + ['do']).freeze def do_actions + return [] if @actions.empty? @do_actions ||= @actions.group_by { |a| a.keys.first }['do'].map { |definition| Action.new(definition['do']) } end @@ -315,7 +318,10 @@ def set_variable(action) set_definition['set'].each do |response_key, variable_name| nested_key_chain = response_key.split('.').map do |key| # If there's a variable in the set key, get the value: - key.gsub!(key, @test.cached_values[key.gsub('$', '')]) if key.match?(/\$.+/) + if key.match?(/\$.+/) + value = @test.cached_values[key.gsub('$', '')] + key.gsub!(key, value) if value + end (key =~ /\A[-+]?[0-9]+\z/) ? key.to_i: key end diff --git a/elasticsearch-api/api-spec-testing/test_file/test.rb b/elasticsearch-api/api-spec-testing/test_file/test.rb index d62d58c44e..32364a4056 100644 --- a/elasticsearch-api/api-spec-testing/test_file/test.rb +++ b/elasticsearch-api/api-spec-testing/test_file/test.rb @@ -71,7 +71,7 @@ def split_and_parse_key(key) end end - attr_reader :description, :test_file, :cached_values, :file_basename + attr_reader :description, :test_file, :cached_values, :file_basename, :skip # Actions that if followed by a 'do' action, indicate that they complete their task group. # For example, consider this sequence of actions: diff --git a/elasticsearch-api/api-spec-testing/wipe_cluster.rb b/elasticsearch-api/api-spec-testing/wipe_cluster.rb index 0ee0f8dbae..6290445d98 100644 --- a/elasticsearch-api/api-spec-testing/wipe_cluster.rb +++ b/elasticsearch-api/api-spec-testing/wipe_cluster.rb @@ -15,9 +15,7 @@ # specific language governing permissions and limitations # under the License. -require_relative 'logging' require_relative 'custom_cleanup' -include Elasticsearch::RestAPIYAMLTests::Logging module Elasticsearch module RestAPIYAMLTests @@ -41,8 +39,8 @@ module WipeCluster 'synthetics', 'synthetics-settings', 'synthetics-mappings', '.snapshot-blob-cache', '.deprecation-indexing-template', '.deprecation-indexing-mappings', '.deprecation-indexing-settings', - 'security-index-template', 'data-streams-mappings', 'ecs@dynamic_templates', - 'search-acl-filter' + 'security-index-template', 'data-streams-mappings', 'search-acl-filter', + '.kibana-reporting' ].freeze # Wipe Cluster, based on PHP's implementation of ESRestTestCase.java:wipeCluster() @@ -61,6 +59,55 @@ def self.create_xpack_rest_user(client) ) end + def self.create_enterprise_search_users(client) + client.security.put_role( + name: 'entuser', + body: { + cluster: [ + 'post_behavioral_analytics_event', + 'manage_api_key', + 'read_connector_secrets', + 'write_connector_secrets' + ], + indices: [ + { + names: [ + 'test-index1', + 'test-search-application', + 'test-search-application-1', + 'test-search-application-with-aggs', + 'test-search-application-with-list', + 'test-search-application-with-list-invalid', + '.elastic-connectors-v1', + '.elastic-connectors-sync-jobs-v1' + ], + privileges: ['read'] + } + ] + } + ) + client.security.put_role( + name: 'unprivileged', + body: { + indices: [ + { + names: ['test-*', 'another-test-search-application'], + privileges: ['manage', 'write', 'read'] + } + ] + } + ) + + client.security.put_user( + username: 'entsearch-user', + body: { password: 'entsearch-user-password', roles: ['entuser'] } + ) + client.security.put_user( + username: 'entsearch-unprivileged', + body: { password: 'entsearch-unprivileged-password', roles: ['privileged'] } + ) + end + class << self private @@ -100,9 +147,9 @@ def ensure_no_initializing_shards(client) def check_for_unexpectedly_recreated_objects(client) unexpected_ilm_policies = client.index_lifecycle_management.get_lifecycle - unexpected_ilm_policies.reject! { |k, _| PRESERVE_ILM_POLICY_IDS.include? k } + unexpected_ilm_policies.reject! { |k, _| preserve_policy?(k) } unless unexpected_ilm_policies.empty? - logger.info( + client.logger.info( "Expected no ILM policies after deletions, but found #{unexpected_ilm_policies.keys.join(',')}" ) end @@ -117,7 +164,7 @@ def check_for_unexpectedly_recreated_objects(client) unexpected_templates << legacy_templates.keys.reject { |t| platinum_template?(t) } unless unexpected_templates.reject(&:empty?).empty? - logger.info( + client.logger.info( "Expected no templates after deletions, but found #{unexpected_templates.join(',')}" ) end @@ -162,7 +209,7 @@ def wait_for_pending_rollup_tasks(client) end break unless count.positive? && Time.now.to_i < (start_time + 1) end - logger.debug("Waited for #{count} pending rollup tasks for #{Time.now.to_i - start_time}s.") if count.positive? + client.logger.debug("Waited for #{count} pending rollup tasks for #{Time.now.to_i - start_time}s.") if count.positive? end def delete_all_slm_policies(client) @@ -198,7 +245,7 @@ def wipe_snapshots(client) response = client.snapshot.get(repository: repository, snapshot: '_all', ignore_unavailable: true) response['snapshots'].each do |snapshot| if snapshot['state'] != 'SUCCESS' - logger.debug("Found snapshot that did not succeed #{snapshot}") + client.logger.debug("Found snapshot that did not succeed #{snapshot}") end client.snapshot.delete(repository: repository, snapshot: snapshot['snapshot'], ignore: 404) end @@ -212,7 +259,7 @@ def wipe_datastreams(client) begin client.indices.delete_data_stream(name: '*', expand_wildcards: 'all') rescue StandardError => e - logger.error "Caught exception attempting to delete data streams: #{e}" + client.logger.error "Caught exception attempting to delete data streams: #{e}" client.indices.delete_data_stream(name: '*') end end @@ -241,29 +288,34 @@ def wipe_all_templates(client) end # Always check for legacy templates - templates = client.indices.get_template - templates.each do |name, _| + client.indices.get_template.each_key do |name| next if platinum_template?(name) begin client.indices.delete_template(name: name) rescue StandardError => e - logger.info("Unable to remove index template #{name}") + client.logger.info("Unable to remove index template #{name} - #{e}") end end end def platinum_template?(template) + return true if template.include?('@') + platinum_prefixes = [ '.monitoring', '.watch', '.triggered-watches', '.data-frame', '.ml-', '.transform', '.deprecation', 'data-streams-mappings', '.fleet', - 'behavioral_analytics-', 'profiling', 'elastic-connectors' + 'behavioral_analytics-', 'profiling', 'elastic-connectors', 'ilm-history', '.slm-history' ].freeze return true if template.start_with?(*platinum_prefixes) PLATINUM_TEMPLATES.include? template end + def preserve_policy?(policy) + PRESERVE_ILM_POLICY_IDS.include?(policy) || policy.include?('@') + end + def wait_for_cluster_tasks(client) start_time = Time.now.to_i count = 0 @@ -276,12 +328,12 @@ def wait_for_cluster_tasks(client) end break unless count.positive? && Time.now.to_i < (start_time + 5) end - logger.debug("Waited for #{count} pending cluster tasks for #{Time.now.to_i - start_time}s.") if count.positive? end def skippable_task?(task) names = ['health-node', 'cluster:monitor/tasks/lists', 'create-index-template-v2', - 'remove-component-template'] + 'remove-component-template', 'create persistent task', + 'finish persistent task'] if task.is_a?(String) names.select { |n| task.match? n }.any? elsif task.is_a?(Hash) @@ -292,7 +344,7 @@ def skippable_task?(task) def delete_all_ilm_policies(client) policies = client.ilm.get_lifecycle policies.each do |policy| - client.ilm.delete_lifecycle(policy: policy[0]) unless PRESERVE_ILM_POLICY_IDS.include? policy[0] + client.ilm.delete_lifecycle(policy: policy[0]) unless preserve_policy?(policy[0]) end end @@ -385,11 +437,11 @@ def clear_ml_filters(client) end def delete_all_node_shutdown_metadata(client) - nodes = client.shutdown.get_node - return unless nodes['nodes'] + nodes = client.perform_request(Elasticsearch::API::HTTP_GET, '_nodes/shutdown') + return unless nodes&.body['nodes'].any? - nodes['nodes'].each do |node| - client.shutdown.delete_node(node['node_id']) + nodes.body['nodes'].each do |node| + client.perform_request(Elasticsearch::API::HTTP_DELETE, "_nodes/#{node['node_id']}/shutdown") end end @@ -407,7 +459,12 @@ def delete_trained_models(client) return unless models['trained_model_configs'] models['trained_model_configs'].each do |model| - client.ml.delete_trained_model(model_id: model['model_id'], force: true, ignore: 400) + client.ml.delete_trained_model( + model_id: model['model_id'], + force: true, + ignore: 400, + timeout: '10s' + ) end end end diff --git a/elasticsearch-api/elasticsearch-api.gemspec b/elasticsearch-api/elasticsearch-api.gemspec index d8b8933060..b0376cb87d 100644 --- a/elasticsearch-api/elasticsearch-api.gemspec +++ b/elasticsearch-api/elasticsearch-api.gemspec @@ -23,8 +23,8 @@ require 'elasticsearch/api/version' Gem::Specification.new do |s| s.name = 'elasticsearch-api' s.version = Elasticsearch::API::VERSION - s.authors = ['Karel Minarik', 'Emily Stolfo', 'Fernando Briano'] - s.email = ['clients-team@elastic.co'] + s.authors = ['Elastic Client Library Maintainers'] + s.email = ['client-libs@elastic.co'] s.summary = 'Ruby API for Elasticsearch.' s.homepage = 'https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html' s.license = 'Apache-2.0' @@ -34,49 +34,36 @@ Gem::Specification.new do |s| 'source_code_uri' => 'https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-api', 'bug_tracker_uri' => 'https://github.com/elastic/elasticsearch-ruby/issues' } - s.files = `git ls-files`.split($/) - s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } - s.test_files = s.files.grep(%r{^(test|spec|features)/}) + s.files = `git ls-files`.split($/).reject do |file| + file.match(/^utils\/|^spec\/|^api-spec-testing\/|^Gemfile|^Rakefile/) + end s.require_paths = ['lib'] - s.extra_rdoc_files = ['README.md', 'LICENSE.txt'] s.rdoc_options = ['--charset=UTF-8'] - s.required_ruby_version = '>= 2.5' - + s.required_ruby_version = '>= 2.6' # For compatibility with JRuby 9.3 s.add_dependency 'multi_json' s.add_development_dependency 'ansi' s.add_development_dependency 'bundler' s.add_development_dependency 'elasticsearch' - s.add_development_dependency 'minitest' - s.add_development_dependency 'minitest-reporters', '>= 1.6' - s.add_development_dependency 'mocha' + s.add_development_dependency 'elasticsearch-test-runner' unless defined?(JRUBY_VERSION) && JRUBY_VERSION <= '9.4' s.add_development_dependency 'pry' s.add_development_dependency 'rake' - s.add_development_dependency 'shoulda-context' s.add_development_dependency 'yard' # Gems for testing integrations - s.add_development_dependency 'jsonify' + s.add_development_dependency 'concurrent-ruby', '1.3.4' if defined? JRUBY_VERSION && JRUBY_VERSION < '9.4' + s.add_development_dependency 'activesupport' s.add_development_dependency 'hashie' - # Temporary support for Ruby 2.6, since it's EOL March 2022: - if RUBY_VERSION < '2.7.0' - s.add_development_dependency 'jbuilder', '< 7.0.0' - else - s.add_development_dependency 'activesupport' - s.add_development_dependency 'jbuilder' - end + s.add_development_dependency 'jbuilder' + s.add_development_dependency 'jsonify' s.add_development_dependency 'cane' s.add_development_dependency 'escape_utils' unless defined? JRUBY_VERSION - s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius) s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius) s.add_development_dependency 'simplecov' - - s.add_development_dependency 'test-unit', '~> 2' - s.description = <<-DESC.gsub(/^ /, '') Ruby API for Elasticsearch. See the `elasticsearch` gem for full integration. DESC diff --git a/elasticsearch-api/lib/elasticsearch/api.rb b/elasticsearch-api/lib/elasticsearch/api.rb index b6c5ebdb86..f187a05021 100644 --- a/elasticsearch-api/lib/elasticsearch/api.rb +++ b/elasticsearch-api/lib/elasticsearch/api.rb @@ -15,19 +15,19 @@ # specific language governing permissions and limitations # under the License. -require "cgi" -require "multi_json" - -require "elasticsearch/api/version" -require "elasticsearch/api/namespace/common" -require "elasticsearch/api/utils" +require 'cgi' +require 'multi_json' +require 'elasticsearch/api/version' +require 'elasticsearch/api/utils' require 'elasticsearch/api/response' -Dir[ File.expand_path('../api/actions/**/*.rb', __FILE__) ].each { |f| require f } -Dir[ File.expand_path('../api/namespace/**/*.rb', __FILE__) ].each { |f| require f } +Dir[File.expand_path('api/actions/**/*.rb', __dir__)].each { |f| require f } module Elasticsearch + # This is the main module for including all API endpoint functions + # It includes the namespace modules from ./api/actions module API + include Elasticsearch::API::Actions DEFAULT_SERIALIZER = MultiJson HTTP_GET = 'GET'.freeze @@ -35,58 +35,82 @@ module API HTTP_POST = 'POST'.freeze HTTP_PUT = 'PUT'.freeze HTTP_DELETE = 'DELETE'.freeze - UNDERSCORE_SEARCH = '_search'.freeze - UNDERSCORE_ALL = '_all'.freeze - DEFAULT_DOC = '_doc'.freeze - # Auto-include all namespaces in the receiver + module CommonClient + attr_reader :client + + def initialize(client) + @client = client + end + + def perform_request(method, path, params = {}, body = nil, headers = nil, request_opts = {}) + client.perform_request(method, path, params, body, headers, request_opts) + end + end + + # Add new namespaces to this constant # - def self.included(base) - base.send :include, - Elasticsearch::API::Common, - Elasticsearch::API::Actions, - Elasticsearch::API::Cluster, - Elasticsearch::API::Nodes, - Elasticsearch::API::Indices, - Elasticsearch::API::Ingest, - Elasticsearch::API::Snapshot, - Elasticsearch::API::Tasks, - Elasticsearch::API::Cat, - Elasticsearch::API::Remote, - Elasticsearch::API::DanglingIndices, - Elasticsearch::API::Features, - Elasticsearch::API::Shutdown, - Elasticsearch::API::AsyncSearch, - Elasticsearch::API::Autoscaling, - Elasticsearch::API::CrossClusterReplication, - Elasticsearch::API::DataFrameTransformDeprecated, - Elasticsearch::API::Enrich, - Elasticsearch::API::Eql, - Elasticsearch::API::Fleet, - Elasticsearch::API::Graph, - Elasticsearch::API::IndexLifecycleManagement, - Elasticsearch::API::License, - Elasticsearch::API::Logstash, - Elasticsearch::API::Migration, - Elasticsearch::API::MachineLearning, - Elasticsearch::API::Monitoring, - Elasticsearch::API::Rollup, - Elasticsearch::API::SearchableSnapshots, - Elasticsearch::API::Security, - Elasticsearch::API::SnapshotLifecycleManagement, - Elasticsearch::API::SQL, - Elasticsearch::API::SSL, - Elasticsearch::API::TextStructure, - Elasticsearch::API::Transform, - Elasticsearch::API::Watcher, - Elasticsearch::API::XPack, - Elasticsearch::API::SearchApplication, - Elasticsearch::API::Synonyms, - Elasticsearch::API::SynonymsSets, - Elasticsearch::API::QueryRuleset, - Elasticsearch::API::SynonymRule + API_NAMESPACES = [:async_search, + :cat, + :cross_cluster_replication, + :cluster, + :connector, + :dangling_indices, + :enrich, + :eql, + :esql, + :features, + :fleet, + :graph, + :index_lifecycle_management, + :indices, + :inference, + :ingest, + :license, + :logstash, + :migration, + :machine_learning, + :nodes, + :query_rules, + :search_application, + :searchable_snapshots, + :security, + :simulate, + :snapshot_lifecycle_management, + :snapshot, + :sql, + :ssl, + :synonyms, + :tasks, + :text_structure, + :transform, + :watcher, + :xpack].freeze + + UPPERCASE_APIS = ['sql', 'ssl'].freeze + API_NAMESPACES.each do |namespace| + name = namespace.to_s + module_name = if UPPERCASE_APIS.include?(name) + name.upcase + elsif name == 'xpack' + 'XPack' + else + name.split('_').map(&:capitalize).join + end + class_name = "#{module_name}Client" + + klass = Class.new(Object) do + include CommonClient, Object.const_get("Elasticsearch::API::#{module_name}::Actions") + end + Object.const_set(class_name, klass) + define_method(name) do + instance_variable_set("@#{name}", klass.new(self)) + end end + alias ml machine_learning + alias ilm index_lifecycle_management + # The serializer class # def self.serializer diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/async_search/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/async_search/delete.rb index 2d48e84bcd..940a47498d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/async_search/delete.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/async_search/delete.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module AsyncSearch module Actions - # Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. + # Delete an async search. + # If the asynchronous search is still running, it is cancelled. + # Otherwise, the saved search results are deleted. + # If the Elasticsearch security features are enabled, the deletion of a specific async search is restricted to: the authenticated user that submitted the original search request; users that have the +cancel_task+ cluster privilege. # - # @option arguments [String] :id The async search ID + # @option arguments [String] :id A unique identifier for the async search. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-async-search-submit # def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'async_search.delete' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +50,11 @@ def delete(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE - path = "_async_search/#{Utils.__listify(_id)}" + path = "_async_search/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/async_search/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/async_search/get.rb index 98e0940929..93e982c95e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/async_search/get.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/async_search/get.rb @@ -15,24 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module AsyncSearch module Actions - # Retrieves the results of a previously submitted async search request given its ID. + # Get async search results. + # Retrieve the results of a previously submitted asynchronous search request. + # If the Elasticsearch security features are enabled, access to the results of a specific async search is restricted to the user or API key that submitted it. # - # @option arguments [String] :id The async search ID - # @option arguments [Time] :wait_for_completion_timeout Specify the time that the request should block waiting for the final response - # @option arguments [Time] :keep_alive Specify the time interval in which the results (partial or final) for this search will be available + # @option arguments [String] :id A unique identifier for the async search. (*Required*) + # @option arguments [Time] :keep_alive The length of time that the async search should be available in the cluster. + # When not specified, the +keep_alive+ set with the corresponding submit async request will be used. + # Otherwise, it is possible to override the value and extend the validity of the request. + # When this period expires, the search, if still running, is cancelled. + # If the search is completed, its saved results are deleted. # @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response + # @option arguments [Time] :wait_for_completion_timeout Specifies to wait for the search to be completed up until the provided timeout. + # Final results will be returned if available before the timeout expires, otherwise the currently available results will be returned once the timeout expires. + # By default no timeout is set meaning that the currently available results will be returned without any additional wait. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-async-search-submit # def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'async_search.get' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -43,11 +58,11 @@ def get(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET - path = "_async_search/#{Utils.__listify(_id)}" + path = "_async_search/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/async_search/status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/async_search/status.rb index 842771be0d..67c4c0f650 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/async_search/status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/async_search/status.rb @@ -15,21 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module AsyncSearch module Actions - # Retrieves the status of a previously submitted async search request given its ID. + # Get the async search status. + # Get the status of a previously submitted async search request given its identifier, without retrieving search results. + # If the Elasticsearch security features are enabled, the access to the status of a specific async search is restricted to: + # * The user or API key that submitted the original async search request. + # * Users that have the +monitor+ cluster privilege or greater privileges. # - # @option arguments [String] :id The async search ID + # @option arguments [String] :id A unique identifier for the async search. (*Required*) + # @option arguments [Time] :keep_alive The length of time that the async search needs to be available. + # Ongoing async searches and any saved search results are deleted after this period. Server default: 5d. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-async-search-submit # def status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'async_search.status' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +53,11 @@ def status(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET - path = "_async_search/status/#{Utils.__listify(_id)}" - params = {} + path = "_async_search/status/#{Utils.listify(_id)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/async_search/submit.rb b/elasticsearch-api/lib/elasticsearch/api/actions/async_search/submit.rb index 6ef7381cf4..546cf0714c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/async_search/submit.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/async_search/submit.rb @@ -15,80 +15,96 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module AsyncSearch module Actions - # Executes a search request asynchronously. + # Run an async search. + # When the primary sort of the results is an indexed field, shards get sorted based on minimum and maximum value that they hold for that field. Partial results become available following the sort criteria that was requested. + # Warning: Asynchronous search does not support scroll or search requests that include only the suggest section. + # By default, Elasticsearch does not allow you to store an async search response larger than 10Mb and an attempt to do this results in an error. + # The maximum allowed size for a stored async search response can be set by changing the +search.max_async_search_response_size+ cluster level setting. # - # @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 [Time] :wait_for_completion_timeout Specify the time that the request should block waiting for the final response - # @option arguments [Boolean] :keep_on_completion Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - # @option arguments [Time] :keep_alive Update the time interval in which the results (partial or final) for this search will be available - # @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 the granularity at which progress results will be made available. - # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to true + # @option arguments [String, Array] :index A comma-separated list of index names to search; use +_all+ or empty string to perform the operation on all indices + # @option arguments [Time] :wait_for_completion_timeout Blocks and waits until the search is completed up to a certain timeout. + # When the async search completes within the timeout, the response won’t include the ID as the results are not stored in the cluster. Server default: 1s. + # @option arguments [Time] :keep_alive Specifies how long the async search needs to be available. + # Ongoing async searches and any saved search results are deleted after this period. Server default: 5d. + # @option arguments [Boolean] :keep_on_completion If +true+, results are stored for later retrieval when the search completes within the +wait_for_completion_timeout+. + # @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 [Boolean] :allow_partial_search_results Indicate if an error should be returned if there is a partial search failure or timeout # @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 [Integer] :batched_reduce_size Affects how often partial results become available, which happens whenever shard results are reduced. + # A partial reduction is performed every time the coordinating node has received a certain number of new shard responses (5 by default). Server default: 5. + # @option arguments [Boolean] :ccs_minimize_roundtrips The default value is the only supported value. + # @option arguments [String] :default_operator The default operator for query string query (AND or OR) # @option arguments [String] :df The field to use as default where no field prefix is given in the query string + # @option arguments [String, Array] :docvalue_fields A comma-separated list of fields to return as the docvalue representation of a field for each hit + # @option arguments [String, Array] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. # @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] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + # @option arguments [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 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 [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 [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to true Server default: true. + # @option arguments [String] :routing A comma-separated list of specific routing values + # @option arguments [String] :search_type Search operation type + # @option arguments [Array] :stats Specific 'tag' of the request for logging and statistical purposes + # @option arguments [String, Array] :stored_fields A comma-separated list of stored fields to return as part of a hit + # @option arguments [String] :suggest_field Specifies which field to use for suggestions. + # @option arguments [String] :suggest_mode Specify suggest mode + # @option arguments [Integer] :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 [Integer] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [Boolean, Integer] :track_total_hits Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. # @option arguments [Boolean] :track_scores Whether to calculate and return scores even if they are not used for sorting - # @option arguments [Boolean|long] :track_total_hits Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. - # @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] :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] :version Specify whether to return document version as part of a hit + # @option arguments [Boolean, String, Array] :_source True or false to return the _source field or not, or a list of fields to return + # @option arguments [String, Array] :_source_excludes A list of fields to exclude from the returned _source field + # @option arguments [String, Array] :_source_includes A list of fields to extract and return from the _source field # @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 [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 [String] :q Query in the Lucene query string syntax + # @option arguments [Integer] :size Number of hits to return (default: 10) + # @option arguments [Integer] :from Starting offset (default: 0) + # @option arguments [String] :sort A comma-separated list of : pairs # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-async-search-submit # def submit(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'async_search.submit' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_async_search" + "#{Utils.listify(_index)}/_async_search" else - "_async_search" + '_async_search' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/delete_autoscaling_policy.rb b/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/delete_autoscaling_policy.rb deleted file mode 100644 index 1f0960a0cf..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/delete_autoscaling_policy.rb +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Autoscaling - module Actions - # Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - # - # @option arguments [String] :name the name of the autoscaling policy - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-delete-autoscaling-policy.html - # - def delete_autoscaling_policy(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _name = arguments.delete(:name) - - method = Elasticsearch::API::HTTP_DELETE - path = "_autoscaling/policy/#{Utils.__listify(_name)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/get_autoscaling_capacity.rb b/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/get_autoscaling_capacity.rb deleted file mode 100644 index ed2d383bec..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/get_autoscaling_capacity.rb +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Autoscaling - module Actions - # Gets the current autoscaling capacity based on the configured autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - # - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html - # - def get_autoscaling_capacity(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - method = Elasticsearch::API::HTTP_GET - path = "_autoscaling/capacity" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/get_autoscaling_policy.rb b/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/get_autoscaling_policy.rb deleted file mode 100644 index e4dfa1782d..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/get_autoscaling_policy.rb +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Autoscaling - module Actions - # Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - # - # @option arguments [String] :name the name of the autoscaling policy - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-policy.html - # - def get_autoscaling_policy(arguments = {}) - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _name = arguments.delete(:name) - - method = Elasticsearch::API::HTTP_GET - path = "_autoscaling/policy/#{Utils.__listify(_name)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/put_autoscaling_policy.rb b/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/put_autoscaling_policy.rb deleted file mode 100644 index f13afffc89..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/autoscaling/put_autoscaling_policy.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Autoscaling - module Actions - # Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - # - # @option arguments [String] :name the name of the autoscaling policy - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body the specification of the autoscaling policy (*Required*) - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-put-autoscaling-policy.html - # - def put_autoscaling_policy(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _name = arguments.delete(:name) - - method = Elasticsearch::API::HTTP_PUT - path = "_autoscaling/policy/#{Utils.__listify(_name)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb b/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb index bd4b706ba2..868854b915 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb @@ -15,58 +15,159 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows to perform multiple index/update/delete operations in a single request. + # Bulk index or delete documents. + # Perform multiple +index+, +create+, +delete+, and +update+ actions in a single request. + # This reduces overhead and can greatly increase indexing speed. + # If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias: + # * To use the +create+ action, you must have the +create_doc+, +create+, +index+, or +write+ index privilege. Data streams support only the +create+ action. + # * To use the +index+ action, you must have the +create+, +index+, or +write+ index privilege. + # * To use the +delete+ action, you must have the +delete+ or +write+ index privilege. + # * To use the +update+ action, you must have the +index+ or +write+ index privilege. + # * To automatically create a data stream or index with a bulk API request, you must have the +auto_configure+, +create_index+, or +manage+ index privilege. + # * To make the result of a bulk operation visible to search using the +refresh+ parameter, you must have the +maintenance+ or +manage+ index privilege. + # Automatic data stream creation requires a matching index template with data stream enabled. + # The actions are specified in the request body using a newline delimited JSON (NDJSON) structure: + # + + # action_and_meta_data\n + # optional_source\n + # action_and_meta_data\n + # optional_source\n + # .... + # action_and_meta_data\n + # optional_source\n + # + + # The +index+ and +create+ actions expect a source on the next line and have the same semantics as the +op_type+ parameter in the standard index API. + # A +create+ action fails if a document with the same ID already exists in the target + # An +index+ action adds or replaces a document as necessary. + # NOTE: Data streams support only the +create+ action. + # To update or delete a document in a data stream, you must target the backing index containing the document. + # An +update+ action expects that the partial doc, upsert, and script and its options are specified on the next line. + # A +delete+ action does not expect a source on the next line and has the same semantics as the standard delete API. + # NOTE: The final line of data must end with a newline character (+\n+). + # Each newline character may be preceded by a carriage return (+\r+). + # When sending NDJSON data to the +_bulk+ endpoint, use a +Content-Type+ header of +application/json+ or +application/x-ndjson+. + # Because this format uses literal newline characters (+\n+) as delimiters, make sure that the JSON actions and sources are not pretty printed. + # If you provide a target in the request path, it is used for any actions that don't explicitly specify an +_index+ argument. + # A note on the format: the idea here is to make processing as fast as possible. + # As some of the actions are redirected to other shards on other nodes, only +action_meta_data+ is parsed on the receiving node side. + # Client libraries using this protocol should try and strive to do something similar on the client side, and reduce buffering as much as possible. + # There is no "correct" number of actions to perform in a single bulk request. + # Experiment with different settings to find the optimal size for your particular workload. + # Note that Elasticsearch limits the maximum size of a HTTP request to 100mb by default so clients must ensure that no request exceeds this size. + # It is not possible to index a single document that exceeds the size limit, so you must pre-process any such documents into smaller pieces before sending them to Elasticsearch. + # For instance, split documents into pages or chapters before indexing them, or store raw binary data in a system outside Elasticsearch and replace the raw data with a link to the external system in the documents that you send to Elasticsearch. + # **Client suppport for bulk requests** + # Some of the officially supported clients provide helpers to assist with bulk requests and reindexing: + # * Go: Check out +esutil.BulkIndexer+ + # * Perl: Check out +Search::Elasticsearch::Client::5_0::Bulk+ and +Search::Elasticsearch::Client::5_0::Scroll+ + # * Python: Check out +elasticsearch.helpers.*+ + # * JavaScript: Check out +client.helpers.*+ + # * .NET: Check out +BulkAllObservable+ + # * PHP: Check out bulk indexing. + # **Submitting bulk requests with cURL** + # If you're providing text file input to +curl+, you must use the +--data-binary+ flag instead of plain +-d+. + # The latter doesn't preserve newlines. For example: + # + + # $ cat requests + # { "index" : { "_index" : "test", "_id" : "1" } } + # { "field1" : "value1" } + # $ curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@requests"; echo + # {"took":7, "errors": false, "items":[{"index":{"_index":"test","_id":"1","_version":1,"result":"created","forced_refresh":false}}]} + # + + # **Optimistic concurrency control** + # Each +index+ and +delete+ action within a bulk API call may include the +if_seq_no+ and +if_primary_term+ parameters in their respective action and meta data lines. + # The +if_seq_no+ and +if_primary_term+ parameters control how operations are run, based on the last modification to existing documents. See Optimistic concurrency control for more details. + # **Versioning** + # Each bulk item can include the version value using the +version+ field. + # It automatically follows the behavior of the index or delete operation based on the +_version+ mapping. + # It also support the +version_type+. + # **Routing** + # Each bulk item can include the routing value using the +routing+ field. + # It automatically follows the behavior of the index or delete operation based on the +_routing+ mapping. + # NOTE: Data streams do not support custom routing unless they were created with the +allow_custom_routing+ setting enabled in the template. + # **Wait for active shards** + # When making bulk calls, you can set the +wait_for_active_shards+ parameter to require a minimum number of shard copies to be active before starting to process the bulk request. + # **Refresh** + # Control when the changes made by this request are visible to search. + # NOTE: Only the shards that receive the bulk request will be affected by refresh. + # Imagine a +_bulk?refresh=wait_for+ request with three documents in it that happen to be routed to different shards in an index with five shards. + # The request will only wait for those three shards to refresh. + # The other two shards that make up the index do not participate in the +_bulk+ request at all. # - # @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 [String] :type Default document type for items which don't provide one - # @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 [String] :index The name of the data stream, index, or index alias to perform bulk actions on. + # @option arguments [Boolean] :include_source_on_error True or false if to include the document source in the error message in case of parsing errors. Server default: true. + # @option arguments [Boolean] :list_executed_pipelines If +true+, the response will include the ingest pipelines that were run for each index or create. + # @option arguments [String] :pipeline The pipeline identifier to use to preprocess incoming documents. + # If the index has a default ingest pipeline specified, setting the value to +_none+ turns off 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 arguments [String] :refresh If +true+, Elasticsearch refreshes the affected shards to make this operation visible to search. + # If +wait_for+, wait for a refresh to make this operation visible to search. + # If +false+, do nothing with refreshes. + # Valid values: +true+, +false+, +wait_for+. Server default: false. + # @option arguments [String] :routing A custom value that is used to route operations to a specific shard. + # @option arguments [Boolean, String, Array] :_source Indicates whether to return the +_source+ field (+true+ or +false+) or contains a list of fields to return. + # @option arguments [String, Array] :_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 arguments [String, Array] :_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 arguments [Time] :timeout The period each action waits for the following operations: automatic index creation, dynamic mapping updates, and waiting for active shards. + # The default is +1m+ (one minute), which guarantees Elasticsearch waits for at least the timeout before failing. + # The actual wait time could be longer, particularly when multiple waits occur. Server default: 1m. + # @option arguments [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+). + # The default is +1+, which waits for each primary shard to be active. Server default: 1. + # @option arguments [Boolean] :require_alias If +true+, the request's actions must target an index alias. + # @option arguments [Boolean] :require_data_stream If +true+, the request's actions must target a data stream (existing or to be created). # @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 Elasticsearch::API::Utils.__bulkify documentation. + # @option arguments [String|Array] :body operations. Array of Strings, Header/Data pairs, or the conveniency "combined" format can be passed, refer to Elasticsearch::API::Utils.bulkify documentation. # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk # def bulk(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'bulk' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_bulk" + "#{Utils.listify(_index)}/_bulk" else - "_bulk" + '_bulk' end params = Utils.process_params(arguments) - if body.is_a? Array - payload = Elasticsearch::API::Utils.__bulkify(body) - else - payload = body - end + payload = if body.is_a? Array + Elasticsearch::API::Utils.bulkify(body) + else + body + end - headers.merge!("Content-Type" => "application/x-ndjson") + headers.merge!({ + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + }) Elasticsearch::API::Response.new( - perform_request(method, path, params, payload, headers) + perform_request(method, path, params, payload, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/aliases.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/aliases.rb index 6aeba66637..0211dbc973 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/aliases.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/aliases.rb @@ -15,28 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Shows information about currently configured aliases to indices including filter and routing infos. + # Get aliases. + # Get the cluster's index aliases, including filter and routing information. + # This API does not return data stream aliases. + # IMPORTANT: CAT APIs are only intended for human consumption using the command line or the Kibana console. They are not intended for use by applications. For application consumption, use the aliases API. # - # @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 [String, Array] :name A comma-separated list of aliases to retrieve. Supports wildcards (+*+). To retrieve all aliases, omit this parameter or use +*+ or +_all+. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [String, Array] :expand_wildcards The 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. + # It supports comma-separated values, such as +open,hidden+. + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicated that the request should never timeout, you can set it to +-1+. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-alias.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-aliases # def aliases(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.aliases' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -46,15 +64,15 @@ def aliases(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_cat/aliases/#{Utils.__listify(_name)}" + "_cat/aliases/#{Utils.listify(_name)}" else - "_cat/aliases" + '_cat/aliases' end params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/allocation.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/allocation.rb index ff7aba8654..b08f92074c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/allocation.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/allocation.rb @@ -15,29 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API 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. + # Get shard allocation information. + # Get a snapshot of the number of shards allocated to each data node and their disk space. + # IMPORTANT: CAT APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. # - # @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 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 [String, Array] :node_id A comma-separated list of node identifiers or names used to limit the returned information. + # @option arguments [String] :bytes The unit used to display byte values. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-allocation.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-allocation # def allocation(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.allocation' } + + defined_params = [:node_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -47,15 +63,15 @@ def allocation(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _node_id - "_cat/allocation/#{Utils.__listify(_node_id)}" + "_cat/allocation/#{Utils.listify(_node_id)}" else - "_cat/allocation" + '_cat/allocation' end params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/component_templates.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/component_templates.rb index 79c56e02d0..3d77c58d2c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/component_templates.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/component_templates.rb @@ -15,28 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about existing component_templates templates. + # Get component templates. + # Get information about component templates in a cluster. + # Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases. + # IMPORTANT: CAT APIs are only intended for human consumption using the command line or Kibana console. + # They are not intended for use by applications. For application consumption, use the get component template API. # - # @option arguments [String] :name A pattern that returned component 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 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 [String] :name The name of the component template. + # It accepts wildcard expressions. + # If it is omitted, all component templates are returned. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-component-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-component-templates # def component_templates(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.component_templates' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -46,14 +66,14 @@ def component_templates(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_cat/component_templates/#{Utils.__listify(_name)}" + "_cat/component_templates/#{Utils.listify(_name)}" else - "_cat/component_templates" + '_cat/component_templates' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb index da96e79935..3bd4eb3fd2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/count.rb @@ -15,44 +15,61 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Provides quick access to the document count of the entire cluster, or individual indices. + # Get a document count. + # Get quick access to a document count for a data stream, an index, or an entire cluster. + # The document count only includes live documents, not deleted documents which have not yet been removed by the merge process. + # IMPORTANT: CAT APIs are only intended for human consumption using the command line or Kibana console. + # They are not intended for use by applications. For application consumption, use the count API. # - # @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 [String, Array] :index A comma-separated list of data streams, indices, and aliases used to limit the request. + # It supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-count # def count(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.count' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "_cat/count/#{Utils.__listify(_index)}" + "_cat/count/#{Utils.listify(_index)}" else - "_cat/count" + '_cat/count' end params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/fielddata.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/fielddata.rb index cedc5d89a8..5a08c6d8ec 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/fielddata.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/fielddata.rb @@ -15,27 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Shows how much heap memory is currently being used by fielddata on every data node in the cluster. + # Get field data cache information. + # Get the amount of heap memory currently used by the field data cache on every data node in the cluster. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. + # They are not intended for use by applications. For application consumption, use the nodes stats API. # - # @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 [String, Array] :fields Comma-separated list of fields used to limit returned information. + # To retrieve all fields, omit this parameter. + # @option arguments [String] :bytes The unit used to display byte values. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-fielddata.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-fielddata # def fielddata(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.fielddata' } + + defined_params = [:fields].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -45,14 +60,14 @@ def fielddata(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _fields - "_cat/fielddata/#{Utils.__listify(_fields)}" + "_cat/fielddata/#{Utils.listify(_fields)}" else - "_cat/fielddata" + '_cat/fielddata' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/health.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/health.rb index b85a478441..241b38e607 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/health.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/health.rb @@ -15,39 +15,54 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns a concise representation of the cluster health. + # Get the cluster health status. + # IMPORTANT: CAT APIs are only intended for human consumption using the command line or Kibana console. + # They are not intended for use by applications. For application consumption, use the cluster health API. + # This API is often used to check malfunctioning clusters. + # To help you track cluster health alongside log files and alerting systems, the API returns timestamps in two formats: + # +HH:MM:SS+, which is human-readable but includes no date information; + # +Unix epoch time+, which is machine-sortable and includes date information. + # The latter format is useful for cluster recoveries that take multiple days. + # You can use the cat health API to verify cluster health across multiple nodes. + # You also can use the API to track the recovery of a large cluster over a longer period of time. # - # @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 [String] :time The unit used to display time values. + # @option arguments [Boolean] :ts If true, returns +HH:MM:SS+ and Unix epoch timestamps. Server default: true. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-health.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-health # def health(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.health' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat/health" + path = '_cat/health' params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/help.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/help.rb index e8690abbab..9e60e0a3ab 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/help.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/help.rb @@ -15,33 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns help for the Cat APIs. + # Get CAT help. + # Get 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 # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-cat # def help(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.help' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat" - params = Utils.process_params(arguments) + path = '_cat' + params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/indices.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/indices.rb index 026de0e783..993d292105 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/indices.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/indices.rb @@ -15,51 +15,74 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about indices: number of primaries and replicas, document counts, disk size, ... + # Get index information. + # Get high-level information about indices in a cluster, including backing indices for data streams. + # Use this request to get the following information for each index in a cluster: + # - shard count + # - document count + # - deleted document count + # - primary store size + # - total store size of all shards, including shard replicas + # These metrics are retrieved directly from Lucene, which Elasticsearch uses internally to power indexing and search. As a result, all document counts include hidden nested documents. + # To get an accurate count of Elasticsearch documents, use the cat count or count APIs. + # CAT APIs are only intended for human consumption using the command line or Kibana console. + # They are not intended for use by applications. For application consumption, use an index endpoint. # - # @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 [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 [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 [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [String] :bytes The unit used to display byte values. + # @option arguments [String, Array] :expand_wildcards The type of index that wildcard patterns can match. + # @option arguments [String] :health The health status used to limit returned indices. By default, the response includes indices of any health status. + # @option arguments [Boolean] :include_unloaded_segments If true, the response includes information from segments that are not loaded into memory. + # @option arguments [Boolean] :pri If true, the response only includes information from primary shards. + # @option arguments [String] :time The unit used to display time values. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-indices # def indices(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.indices' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "_cat/indices/#{Utils.__listify(_index)}" + "_cat/indices/#{Utils.listify(_index)}" else - "_cat/indices" + '_cat/indices' end params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/master.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/master.rb index 92df41d96e..68c3f8d712 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/master.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/master.rb @@ -15,38 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about the master node. + # Get master node information. + # Get information about the master node, including the ID, bound IP address, and name. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the nodes info API. # - # @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 [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-master.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-master # def master(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.master' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat/master" + path = '_cat/master' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_data_frame_analytics.rb index dfaa649b2d..f4744c521e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_data_frame_analytics.rb @@ -15,29 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Gets configuration and usage information about data frame analytics jobs. + # Get data frame analytics jobs. + # Get configuration and usage information about data frame analytics jobs. + # IMPORTANT: CAT APIs are only intended for human consumption using the Kibana + # console or command line. They are not intended for use by applications. For + # application consumption, use the get data frame analytics jobs statistics API. # # @option arguments [String] :id The ID of the data frame analytics to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified) - # @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 [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] :allow_no_match Whether to ignore if a wildcard expression matches no configs. (This includes +_all+ string or when no configs have been specified) + # @option arguments [String] :bytes The unit in which to display byte values + # @option arguments [String, Array] :h Comma-separated list of column names to display. Server default: create_time,id,state,type. + # @option arguments [String, Array] :s Comma-separated list of column names or column aliases used to sort the + # response. + # @option arguments [String] :time Unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-ml-data-frame-analytics # def ml_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.ml_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -47,14 +61,14 @@ def ml_data_frame_analytics(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _id - "_cat/ml/data_frame/analytics/#{Utils.__listify(_id)}" + "_cat/ml/data_frame/analytics/#{Utils.listify(_id)}" else - "_cat/ml/data_frame/analytics" + '_cat/ml/data_frame/analytics' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_datafeeds.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_datafeeds.rb index c2170b7efd..4e54293420 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_datafeeds.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_datafeeds.rb @@ -15,28 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Gets configuration and usage information about datafeeds. + # Get datafeeds. + # Get configuration and usage information about datafeeds. + # This API returns a maximum of 10,000 datafeeds. + # If the Elasticsearch security features are enabled, you must have +monitor_ml+, +monitor+, +manage_ml+, or +manage+ + # cluster privileges to use this API. + # IMPORTANT: CAT APIs are only intended for human consumption using the Kibana + # console or command line. They are not intended for use by applications. For + # application consumption, use the get datafeed statistics API. # - # @option arguments [String] :datafeed_id The ID of the datafeeds stats to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - # @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] :v Verbose mode. Display column headers + # @option arguments [String] :datafeed_id A numerical character string that uniquely identifies the datafeed. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no datafeeds that match. + # - Contains the +_all+ string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If +true+, the API returns an empty datafeeds array when there are no matches and the subset of results when + # there are partial matches. If +false+, the API returns a 404 status code when there are no matches or only + # partial matches. Server default: true. + # @option arguments [String, Array] :h Comma-separated list of column names to display. Server default: ['bc', 'id', 'sc', 's']. + # @option arguments [String, Array] :s Comma-separated list of column names or column aliases used to sort the response. + # @option arguments [String] :time The unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-ml-datafeeds # def ml_datafeeds(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.ml_datafeeds' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -46,14 +68,14 @@ def ml_datafeeds(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _datafeed_id - "_cat/ml/datafeeds/#{Utils.__listify(_datafeed_id)}" + "_cat/ml/datafeeds/#{Utils.listify(_datafeed_id)}" else - "_cat/ml/datafeeds" + '_cat/ml/datafeeds' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_jobs.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_jobs.rb index ceb6771691..cf4bdfe666 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_jobs.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_jobs.rb @@ -15,29 +15,51 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Gets configuration and usage information about anomaly detection jobs. + # Get anomaly detection jobs. + # Get configuration and usage information for anomaly detection jobs. + # This API returns a maximum of 10,000 jobs. + # If the Elasticsearch security features are enabled, you must have +monitor_ml+, + # +monitor+, +manage_ml+, or +manage+ cluster privileges to use this API. + # IMPORTANT: CAT APIs are only intended for human consumption using the Kibana + # console or command line. They are not intended for use by applications. For + # application consumption, use the get anomaly detection job statistics API. # - # @option arguments [String] :job_id The ID of the jobs stats to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - # @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 [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 [String] :job_id Identifier for the anomaly detection job. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no jobs that match. + # - Contains the +_all+ string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If +true+, the API returns an empty jobs array when there are no matches and the subset of results when there + # are partial matches. If +false+, the API returns a 404 status code when there are no matches or only partial + # matches. Server default: true. + # @option arguments [String] :bytes The unit used to display byte values. + # @option arguments [String, Array] :h Comma-separated list of column names to display. Server default: buckets.count,data.processed_records,forecasts.total,id,model.bytes,model.memory_status,state. + # @option arguments [String, Array] :s Comma-separated list of column names or column aliases used to sort the response. + # @option arguments [String] :time The unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-ml-jobs # def ml_jobs(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.ml_jobs' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -47,14 +69,14 @@ def ml_jobs(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _job_id - "_cat/ml/anomaly_detectors/#{Utils.__listify(_job_id)}" + "_cat/ml/anomaly_detectors/#{Utils.listify(_job_id)}" else - "_cat/ml/anomaly_detectors" + '_cat/ml/anomaly_detectors' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_trained_models.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_trained_models.rb index fc206369cc..4d4401af64 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_trained_models.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/ml_trained_models.rb @@ -15,31 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Gets configuration and usage information about inference trained models. + # Get trained models. + # Get configuration and usage information about inference trained models. + # IMPORTANT: CAT APIs are only intended for human consumption using the Kibana + # console or command line. They are not intended for use by applications. For + # application consumption, use the get trained models statistics API. # - # @option arguments [String] :model_id The ID of the trained models stats to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) - # @option arguments [Integer] :from skips a number of trained models - # @option arguments [Integer] :size specifies a max number of trained models to get - # @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 [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 [String] :model_id A unique identifier for the trained model. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: contains wildcard expressions and there are no models that match; contains the +_all+ string or no identifiers and there are no matches; contains wildcard expressions and there are only partial matches. + # If +true+, the API returns an empty array when there are no matches and the subset of results when there are partial matches. + # If +false+, the API returns a 404 status code when there are no matches or only partial matches. Server default: true. + # @option arguments [String] :bytes The unit used to display byte values. + # @option arguments [String, Array] :h A comma-separated list of column names to display. + # @option arguments [String, Array] :s A comma-separated list of column names or aliases used to sort the response. + # @option arguments [Integer] :from Skips the specified number of transforms. + # @option arguments [Integer] :size The maximum number of transforms to display. + # @option arguments [String] :time Unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-ml-trained-models # def ml_trained_models(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.ml_trained_models' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -49,14 +64,14 @@ def ml_trained_models(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _model_id - "_cat/ml/trained_models/#{Utils.__listify(_model_id)}" + "_cat/ml/trained_models/#{Utils.listify(_model_id)}" else - "_cat/ml/trained_models" + '_cat/ml/trained_models' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb index dbf07acb05..b2035b5d0c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodeattrs.rb @@ -15,38 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about custom node attributes. + # Get node attribute information. + # Get information about custom node attributes. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the nodes info API. # - # @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 [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodeattrs.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-nodeattrs # def nodeattrs(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.nodeattrs' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat/nodeattrs" + path = '_cat/nodeattrs' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodes.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodes.rb index 47356741e8..e5bb34ad56 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodes.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/nodes.rb @@ -15,42 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns basic statistics about performance of cluster nodes. + # Get node information. + # Get information about the nodes in a cluster. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the nodes info API. # - # @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 [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 [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] :bytes The unit used to display byte values. + # @option arguments [Boolean, String] :full_id If +true+, return the full node ID. If +false+, return the shortened node ID. Server default: false. + # @option arguments [Boolean] :include_unloaded_segments If true, the response includes information from segments that are not loaded into memory. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :time Unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-nodes # def nodes(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.nodes' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat/nodes" + path = '_cat/nodes' params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h], escape: false) if params[:h] + params[:h] = Utils.listify(params[:h], escape: false) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/pending_tasks.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/pending_tasks.rb index 1d3dba91b7..345f0d1332 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/pending_tasks.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/pending_tasks.rb @@ -15,40 +15,51 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns a concise representation of the cluster pending tasks. + # Get pending task information. + # Get information about cluster-level changes that have not yet taken effect. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the pending cluster tasks API. # - # @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 [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 [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :time Unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-pending-tasks.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-pending-tasks # def pending_tasks(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.pending_tasks' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat/pending_tasks" + path = '_cat/pending_tasks' params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/plugins.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/plugins.rb index 9dea6c0d31..db1602a6e9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/plugins.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/plugins.rb @@ -15,39 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about installed plugins across nodes node. + # Get plugin information. + # Get a list of plugins running on each node of a cluster. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the nodes info API. # - # @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 [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. # @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 [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-plugins.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-plugins # def plugins(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.plugins' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat/plugins" + path = '_cat/plugins' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb index 445924eb78..93dec9c32c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb @@ -15,48 +15,64 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about index shard recoveries, both on-going completed. + # Get shard recovery information. + # Get information about ongoing and completed shard recoveries. + # Shard recovery is the process of initializing a shard copy, such as restoring a primary shard from a snapshot or syncing a replica shard from a primary shard. When a shard recovery completes, the recovered shard is available for search and indexing. + # For data streams, the API returns information about the stream’s backing indices. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the index recovery API. # - # @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 [String, Array] :index A comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [Boolean] :active_only If +true+, the response only includes ongoing shard recoveries. + # @option arguments [String] :bytes The unit used to display byte values. + # @option arguments [Boolean] :detailed If +true+, the response includes detailed information about shard recoveries. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [String] :time Unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-recovery # def recovery(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.recovery' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "_cat/recovery/#{Utils.__listify(_index)}" + "_cat/recovery/#{Utils.listify(_index)}" else - "_cat/recovery" + '_cat/recovery' end params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/repositories.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/repositories.rb index 1454d0b12c..b565d40edd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/repositories.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/repositories.rb @@ -15,38 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about snapshot repositories registered in the cluster. + # Get snapshot repository information. + # Get a list of snapshot repositories for a cluster. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the get snapshot repository API. # - # @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 - # @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 [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-repositories.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-repositories # def repositories(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.repositories' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat/repositories" + path = '_cat/repositories' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb index 3deb0db3f0..cab1160b86 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb @@ -15,44 +15,65 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Provides low-level information about the segments in the shards of an index. + # Get segment information. + # Get low-level information about the Lucene segments in index shards. + # For data streams, the API returns information about the backing indices. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the index segments API. # - # @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 [String, Array] :index A comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [String] :bytes The unit used to display byte values. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-segments.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-segments # def segments(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.segments' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "_cat/segments/#{Utils.__listify(_index)}" + "_cat/segments/#{Utils.listify(_index)}" else - "_cat/segments" + '_cat/segments' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/shards.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/shards.rb index ccedb98ea7..04550ec87c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/shards.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/shards.rb @@ -15,47 +15,63 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Provides a detailed view of shard allocation on nodes. + # Get shard information. + # Get information about the shards in a cluster. + # For data streams, the API returns information about the backing indices. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. # - # @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 [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 [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 [String, Array] :index A comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [String] :bytes The unit used to display byte values. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :time Unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-shards # def shards(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.shards' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "_cat/shards/#{Utils.__listify(_index)}" + "_cat/shards/#{Utils.listify(_index)}" else - "_cat/shards" + '_cat/shards' end params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb index 7f3e9f66d9..2d39833e93 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb @@ -15,29 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns all snapshots in a specific repository. + # Get snapshot information. + # Get information about the snapshots stored in one or more repositories. + # A snapshot is a backup of an index or running Elasticsearch cluster. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the get snapshot API. # - # @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 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 [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 [String, Array] :repository 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, Elasticsearch returns an error. + # @option arguments [Boolean] :ignore_unavailable If +true+, the response does not include information from unavailable snapshots. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :time Unit used to display time values. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-snapshots # def snapshots(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.snapshots' } + + defined_params = [:repository].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -47,14 +64,14 @@ def snapshots(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _repository - "_cat/snapshots/#{Utils.__listify(_repository)}" + "_cat/snapshots/#{Utils.listify(_repository)}" else - "_cat/snapshots" + '_cat/snapshots' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/tasks.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/tasks.rb index a40f6429b6..050890bc76 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/tasks.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/tasks.rb @@ -15,45 +15,56 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about the tasks currently executing on one or more nodes in the cluster. + # Get task information. + # Get information about tasks currently running in the cluster. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the task management API. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :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 [Array] :actions The task action names, which are used to limit the response. + # @option arguments [Boolean] :detailed If +true+, the response includes detailed information about shard recoveries. + # @option arguments [Array] :nodes Unique node identifiers, which are used to limit the response. + # @option arguments [String] :parent_task_id The parent task identifier, which is used to limit the response. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [String] :time Unit used to display time values. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Boolean] :wait_for_completion If +true+, the request blocks until the task has completed. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-tasks # def tasks(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.tasks' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cat/tasks" + path = '_cat/tasks' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/templates.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/templates.rb index afc0e72390..5bdc457bcd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/templates.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/templates.rb @@ -15,28 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns information about existing templates. + # Get index template information. + # Get information about the index templates in a cluster. + # You can use index templates to apply index settings and field mappings to new indices at creation. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the get index template API. # - # @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 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 [String] :name The name of the template to return. + # Accepts wildcard expressions. If omitted, all templates are returned. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-templates # def templates(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.templates' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -46,14 +64,14 @@ def templates(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_cat/templates/#{Utils.__listify(_name)}" + "_cat/templates/#{Utils.listify(_name)}" else - "_cat/templates" + '_cat/templates' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/thread_pool.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/thread_pool.rb index 3407cc92c7..be0cd62fdc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/thread_pool.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/thread_pool.rb @@ -15,30 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Returns cluster-wide thread pool statistics per node. - # By default the active, queue and rejected statistics are returned for all thread pools. + # Get thread pool statistics. + # Get thread pool statistics for each node in a cluster. + # Returned information includes all built-in thread pools and custom thread pools. + # IMPORTANT: cat APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the nodes info API. # - # @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] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos) - # @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 [String, Array] :thread_pool_patterns A comma-separated list of thread pool names used to limit the request. + # Accepts wildcard expressions. + # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # Sorting defaults to ascending and can be changed by setting +:asc+ + # or +:desc+ as a suffix to the column name. + # @option arguments [String] :time The unit used to display time values. + # @option arguments [Boolean] :local If +true+, the request computes the list of selected nodes from the + # local cluster state. If +false+ the list of selected nodes are computed + # from the cluster state of the master node. In both cases the coordinating + # node will send requests for further information to each selected node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-thread-pool.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-thread-pool # def thread_pool(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.thread_pool' } + + defined_params = [:thread_pool_patterns].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -48,15 +65,15 @@ def thread_pool(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _thread_pool_patterns - "_cat/thread_pool/#{Utils.__listify(_thread_pool_patterns)}" + "_cat/thread_pool/#{Utils.listify(_thread_pool_patterns)}" else - "_cat/thread_pool" + '_cat/thread_pool' end params = Utils.process_params(arguments) - params[:h] = Utils.__listify(params[:h]) if params[:h] + params[:h] = Utils.listify(params[:h]) if params[:h] Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/transforms.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/transforms.rb index 7414201f94..9390a25881 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/transforms.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/transforms.rb @@ -15,30 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cat module Actions - # Gets configuration and usage information about transforms. + # Get transform information. + # Get configuration and usage information about transforms. + # CAT APIs are only intended for human consumption using the Kibana + # console or command line. They are not intended for use by applications. For + # application consumption, use the get transform statistics API. # - # @option arguments [String] :transform_id The id of the transform for which to get stats. '_all' or '*' implies all transforms - # @option arguments [Integer] :from skips a number of transform configs, defaults to 0 - # @option arguments [Integer] :size specifies a max number of transforms to get, defaults to 100 - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - # @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] :v Verbose mode. Display column headers + # @option arguments [String] :transform_id A transform identifier or a wildcard expression. + # If you do not specify one of these options, the API returns information for all transforms. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: contains wildcard expressions and there are no transforms that match; contains the +_all+ string or no identifiers and there are no matches; contains wildcard expressions and there are only partial matches. + # If +true+, it returns an empty transforms array when there are no matches and the subset of results when there are partial matches. + # If +false+, the request returns a 404 status code when there are no matches or only partial matches. Server default: true. + # @option arguments [Integer] :from Skips the specified number of transforms. Server default: 0. + # @option arguments [String, Array] :h Comma-separated list of column names to display. Server default: changes_last_detection_time,checkpoint,checkpoint_progress,documents_processed,id,last_search_time,state. + # @option arguments [String, Array] :s Comma-separated list of column names or column aliases used to sort the response. + # @option arguments [String] :time The unit used to display time values. + # @option arguments [Integer] :size The maximum number of transforms to obtain. Server default: 100. + # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to + # +text+, +json+, +cbor+, +yaml+, or +smile+. Server default: text. + # @option arguments [Boolean] :help When set to +true+ will output available columns. This option + # can't be combined with any other query string option. + # @option arguments [Boolean] :v When set to +true+ will enable verbose output. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-transforms # def transforms(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cat.transforms' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -48,14 +64,14 @@ def transforms(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _transform_id - "_cat/transforms/#{Utils.__listify(_transform_id)}" + "_cat/transforms/#{Utils.listify(_transform_id)}" else - "_cat/transforms" + '_cat/transforms' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb b/elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb index d3e918a518..520f28001a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/clear_scroll.rb @@ -15,26 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Explicitly clears the search context for a scroll. + # Clear a scrolling search. + # Clear the search context and results for a scrolling search. # - # @option arguments [List] :scroll_id A comma-separated list of scroll IDs to clear *Deprecated* + # @option arguments [String, Array] :scroll_id A comma-separated list of scroll IDs to clear. + # To clear all scroll IDs, use +_all+. + # IMPORTANT: Scroll IDs can be long. It is recommended to specify scroll IDs in the request body parameter. # @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 + # @option arguments [Hash] :body request body # # *Deprecation notice*: # A scroll id can be quite large and should be specified as part of the body # Deprecated since version 7.0.0 # # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-clear-scroll # def clear_scroll(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'clear_scroll' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -43,22 +48,18 @@ def clear_scroll(arguments = {}) _scroll_id = arguments.delete(:scroll_id) method = Elasticsearch::API::HTTP_DELETE - path = if _scroll_id - "_search/scroll/#{Utils.__listify(_scroll_id)}" - else - "_search/scroll" - end + path = '_search/scroll' params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/close_point_in_time.rb b/elasticsearch-api/lib/elasticsearch/api/actions/close_point_in_time.rb index b82d581896..537ed0eff6 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/close_point_in_time.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/close_point_in_time.rb @@ -15,31 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Close a point in time + # Close a point in time. + # A point in time must be opened explicitly before being used in search requests. + # The +keep_alive+ parameter tells Elasticsearch how long it should persist. + # A point in time is automatically closed when the +keep_alive+ period has elapsed. + # However, keeping points in time has a cost; close them as soon as they are no longer required for search requests. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body a point-in-time id to close + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/point-in-time-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-open-point-in-time # def close_point_in_time(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'close_point_in_time' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_DELETE - path = "_pit" + path = '_pit' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb index d554b92c91..fb48a14d65 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/allocation_explain.rb @@ -15,27 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Provides explanations for shard allocations in the cluster. + # Explain the shard allocations. + # Get explanations for shard allocations in the cluster. + # For unassigned shards, it provides an explanation for why the shard is unassigned. + # For assigned shards, it provides an explanation for why the shard is remaining on its current node and has not moved or rebalanced to another node. + # This API can be very useful when attempting to diagnose why a shard is unassigned or why a shard continues to remain on its current node when you might expect otherwise. # - # @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 [Boolean] :include_disk_info If true, returns information about disk usage and shard sizes. + # @option arguments [Boolean] :include_yes_decisions If true, returns YES decisions in explanation. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The index, shard, and primary flag to explain. Empty means 'explain a randomly-chosen unassigned shard' + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-allocation-explain # def allocation_explain(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.allocation_explain' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = if body Elasticsearch::API::HTTP_POST @@ -43,11 +50,11 @@ def allocation_explain(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_cluster/allocation/explain" + path = '_cluster/allocation/explain' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/delete_component_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/delete_component_template.rb index caae9e6c07..7f50cd4187 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/delete_component_template.rb @@ -15,23 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Deletes a component template + # Delete component templates. + # Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases. # - # @option arguments [String] :name The name of the template - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [String, Array] :name Comma-separated list or wildcard expression of component template names used to limit the request. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-component-template.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template # def delete_component_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.delete_component_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -42,11 +52,11 @@ def delete_component_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_component_template/#{Utils.__listify(_name)}" + path = "_component_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb index 33b279e300..390eadc180 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb @@ -15,33 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Clears cluster voting config exclusions. + # Clear cluster voting config exclusions. + # Remove master-eligible nodes from the voting configuration exclusion list. # - # @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 [Time] :master_timeout Timeout for submitting request to master + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @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. + # 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. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/voting-config-exclusions.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-post-voting-config-exclusions # def delete_voting_config_exclusions(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.delete_voting_config_exclusions' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_DELETE - path = "_cluster/voting_config_exclusions" + path = '_cluster/voting_config_exclusions' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/exists_component_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/exists_component_template.rb index 7e2289b508..f895baacec 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/exists_component_template.rb @@ -15,23 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Returns information about whether a particular component template exist + # Check component templates. + # Returns information about whether a particular component template exists. # - # @option arguments [String] :name The name of the template - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) + # @option arguments [String, Array] :name Comma-separated list of component template names used to limit the request. + # Wildcard (*) expressions are supported. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is + # received before the timeout expires, the request fails and returns an + # error. Server default: 30s. + # @option arguments [Boolean] :local If true, the request retrieves information from the local node only. + # Defaults to false, which means information is retrieved from the master node. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-component-template.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template # def exists_component_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.exists_component_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -42,15 +54,15 @@ def exists_component_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_HEAD - path = "_component_template/#{Utils.__listify(_name)}" + path = "_component_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end - alias_method :exists_component_template?, :exists_component_template + alias exists_component_template? exists_component_template end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_component_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_component_template.rb index 11dab29e49..3f57430a52 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_component_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_component_template.rb @@ -15,24 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Returns one or more component templates + # Get component templates. + # Get information about component templates. # - # @option arguments [List] :name The comma separated names of the component templates - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) + # @option arguments [String] :name Comma-separated list of component template names used to limit the request. + # Wildcard (+*+) expressions are supported. + # @option arguments [Boolean] :flat_settings If +true+, returns settings in flat format. # @option arguments [Boolean] :include_defaults Return all default configurations for the component template (default: false) + # @option arguments [Boolean] :local If +true+, the request retrieves information from the local node only. + # If +false+, information is retrieved from the master node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-component-template.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template # def get_component_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.get_component_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -42,14 +54,14 @@ def get_component_template(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_component_template/#{Utils.__listify(_name)}" + "_component_template/#{Utils.listify(_name)}" else - "_component_template" + '_component_template' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_settings.rb index 02e72b246a..6f636d813d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/get_settings.rb @@ -15,35 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Returns cluster settings. + # Get cluster-wide settings. + # By default, it returns only settings that have been explicitly defined. # - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :include_defaults Whether to return all default clusters setting. + # @option arguments [Boolean] :flat_settings If +true+, returns settings in flat format. + # @option arguments [Boolean] :include_defaults If +true+, returns default cluster settings from the local node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-get-settings.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-get-settings # def get_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.get_settings' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cluster/settings" + path = '_cluster/settings' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/health.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/health.rb index 01e659b1c9..bf5a38b0ff 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/health.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/health.rb @@ -15,49 +15,63 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Returns basic information about the health of the cluster. + # Get the cluster health status. + # You can also use the API to get the health status of only specified data streams and indices. + # For data streams, the API retrieves the health status of the stream’s backing indices. + # The cluster health status is: green, yellow or red. + # On the shard level, a red status indicates that the specific shard is not allocated in the cluster. Yellow means that the primary shard is allocated but replicas are not. Green means that all shards are allocated. + # The index level status is controlled by the worst shard status. + # One of the main benefits of the API is the ability to wait until the cluster reaches a certain high watermark health level. + # The cluster status is controlled by the worst index status. # - # @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 master node (default: false) - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master 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 [String, Array] :index Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (+*+) are supported. To target all data streams and indices in a cluster, omit this parameter or use _all or +*+. + # @option arguments [String, Array] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. + # @option arguments [String] :level Can be one of cluster, indices or shards. Controls the details level of the health information returned. Server default: cluster. + # @option arguments [Boolean] :local If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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. Server default: 0. + # @option arguments [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 arguments [String, Integer] :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 arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-health # def health(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.health' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "_cluster/health/#{Utils.__listify(_index)}" + "_cluster/health/#{Utils.listify(_index)}" else - "_cluster/health" + '_cluster/health' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/info.rb index a501535c15..0de66c3a67 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/info.rb @@ -15,21 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Returns different information about the cluster. + # Get cluster info. + # Returns basic information about the cluster. # - # @option arguments [List] :target Limit the information returned to the specified target. (options: _all, http, ingest, thread_pool, script) + # @option arguments [String, Array] :target Limits the information returned to the specific target. Supports a comma-separated list, such as http,ingest. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-info.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-info # def info(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.info' } + + defined_params = [:target].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] arguments = arguments.clone @@ -40,11 +48,11 @@ def info(arguments = {}) _target = arguments.delete(:target) method = Elasticsearch::API::HTTP_GET - path = "_info/#{Utils.__listify(_target)}" + path = "_info/#{Utils.listify(_target)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/pending_tasks.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/pending_tasks.rb index f8b556bc2b..f0430b73c3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/pending_tasks.rb @@ -15,34 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster 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. + # Get the pending cluster tasks. + # Get information about cluster-level changes (such as create index, update mapping, allocate or fail shard) that have not yet taken effect. + # NOTE: This API returns a list of any pending updates to the cluster state. + # These are distinct from the tasks reported by the task management API which include periodic tasks and tasks initiated by the user, such as node stats, search queries, or create index requests. + # However, if a user-initiated task such as a create index command causes a cluster state update, the activity of this task might be reported by both task api and pending cluster tasks API. # - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [Boolean] :local If +true+, the request retrieves information from the local node only. + # If +false+, information is retrieved from the master node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-pending-tasks # def pending_tasks(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.pending_tasks' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_cluster/pending_tasks" + path = '_cluster/pending_tasks' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb index 8901d8bc66..35bd36c80c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb @@ -15,35 +15,56 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Updates the cluster voting config exclusions by node ids or node names. + # Update voting configuration exclusions. + # Update the cluster voting config exclusions by node IDs or node names. + # By default, if there are more than three master-eligible nodes in the cluster and you remove fewer than half of the master-eligible nodes in the cluster at once, the voting configuration automatically shrinks. + # If you want to shrink the voting configuration to contain fewer than three nodes or to remove half or more of the master-eligible nodes in the cluster at once, use this API to remove departing nodes from the voting configuration manually. + # The API adds an entry for each specified node to the cluster’s voting configuration exclusions list. + # It then waits until the cluster has reconfigured its voting configuration to exclude the specified nodes. + # Clusters should have no voting configuration exclusions in normal operation. + # Once the excluded nodes have stopped, clear the voting configuration exclusions with +DELETE /_cluster/voting_config_exclusions+. + # This API waits for the nodes to be fully removed from the cluster before it returns. + # If your cluster has voting configuration exclusions for nodes that you no longer intend to remove, use +DELETE /_cluster/voting_config_exclusions?wait_for_removal=false+ to clear the voting configuration exclusions without waiting for the nodes to leave the cluster. + # A response to +POST /_cluster/voting_config_exclusions+ with an HTTP status code of 200 OK guarantees that the node has been removed from the voting configuration and will not be reinstated until the voting configuration exclusions are cleared by calling +DELETE /_cluster/voting_config_exclusions+. + # If the call to +POST /_cluster/voting_config_exclusions+ fails or returns a response with an HTTP status code other than 200 OK then the node may not have been removed from the voting configuration. + # In that case, you may safely retry the call. + # NOTE: Voting exclusions are required only when you remove at least half of the master-eligible nodes from a cluster in a short time period. + # They are not required when removing master-ineligible nodes or when removing fewer than half of the master-eligible nodes. # - # @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 [Time] :master_timeout Timeout for submitting request to master + # @option arguments [String, Array] :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 [String, Array] :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 [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [Time] :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. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/voting-config-exclusions.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-post-voting-config-exclusions # def post_voting_config_exclusions(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.post_voting_config_exclusions' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_cluster/voting_config_exclusions" + path = '_cluster/voting_config_exclusions' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/put_component_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/put_component_template.rb index 330de203fe..498d36572c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/put_component_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/put_component_template.rb @@ -15,25 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Creates or updates a component template + # Create or update a component template. + # Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases. + # An index template can be composed of multiple component templates. + # To use a component template, specify it in an index template’s +composed_of+ list. + # Component templates are only applied to new data streams and indices as part of a matching index template. + # Settings and mappings specified directly in the index template or the create index request override any settings or mappings specified in a component template. + # Component templates are only used during index creation. + # For data streams, this includes data stream creation and the creation of a stream’s backing indices. + # Changes to component templates do not affect existing indices, including a stream’s backing indices. + # You can use C-style +/* *\/+ block comments in component templates. + # You can include comments anywhere in the request body except before the opening curly bracket. + # **Applying component templates** + # You cannot directly apply a component template to a data stream or index. + # To be applied, a component template must be included in an index template's +composed_of+ list. # - # @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 Specify timeout for connection to master + # @option arguments [String] :name Name of the component template to create. + # Elasticsearch includes the following built-in component templates: +logs-mappings+; +logs-settings+; +metrics-mappings+; +metrics-settings+;+synthetics-mapping+; +synthetics-settings+. + # Elastic Agent uses these templates to configure backing indices for its data streams. + # If you use Elastic 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 Elastic Agent and want to disable all built-in component and index templates, set +stack.templates.enabled+ to +false+ using the cluster update settings API. (*Required*) + # @option arguments [Boolean] :create If +true+, this request cannot replace or update existing component templates. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The template definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-component-template.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-component-template # def put_component_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.put_component_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -45,11 +69,11 @@ def put_component_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_component_template/#{Utils.__listify(_name)}" + path = "_component_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/put_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/put_settings.rb index aaec93ee7c..655fa2cc63 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/put_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/put_settings.rb @@ -15,37 +15,52 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Updates the cluster settings. + # Update the cluster settings. + # Configure and update dynamic settings on a running cluster. + # You can also configure dynamic settings locally on an unstarted or shut down node in +elasticsearch.yml+. + # Updates made with this API can be persistent, which apply across cluster restarts, or transient, which reset after a cluster restart. + # You can also reset transient or persistent settings by assigning them a null value. + # If you configure the same setting using multiple methods, Elasticsearch applies the settings in following order of precedence: 1) Transient setting; 2) Persistent setting; 3) +elasticsearch.yml+ setting; 4) Default setting value. + # For example, you can apply a transient setting to override a persistent setting or +elasticsearch.yml+ setting. + # However, a change to an +elasticsearch.yml+ setting will not override a defined transient or persistent setting. + # TIP: In Elastic Cloud, use the user settings feature to configure all cluster settings. This method automatically rejects unsafe settings that could break your cluster. + # If you run Elasticsearch on your own hardware, use this API to configure dynamic cluster settings. + # Only use +elasticsearch.yml+ for static cluster settings and node settings. + # The API doesn’t require a restart and ensures a setting’s value is the same on all nodes. + # WARNING: Transient cluster settings are no longer recommended. Use persistent cluster settings instead. + # If a cluster becomes unstable, transient settings can clear unexpectedly, resulting in a potentially undesired cluster configuration. # # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node Server default: 30s. + # @option arguments [Time] :timeout Explicit operation timeout Server default: 30s. # @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*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings # def put_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.put_settings' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) || {} + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_PUT - path = "_cluster/settings" + path = '_cluster/settings' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/remote_info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/remote_info.rb index 1aadcdae48..a04ecc1dcf 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/remote_info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/remote_info.rb @@ -15,31 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Returns the information about configured remote clusters. + # Get remote cluster information. + # Get information about configured remote clusters. + # The API returns connection and endpoint information keyed by the configured remote cluster alias. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-remote-info.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-remote-info # def remote_info(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.remote_info' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_remote/info" + path = '_remote/info' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb index 753ada1994..dd24a9608d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/reroute.rb @@ -15,38 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Allows to manually change the allocation of individual shards in the cluster. + # Reroute the cluster. + # Manually change the allocation of individual shards in the cluster. + # For example, a shard can be moved from one node to another explicitly, an allocation can be canceled, and an unassigned shard can be explicitly allocated to a specific node. + # It is important to note that after processing any reroute commands Elasticsearch will perform rebalancing as normal (respecting the values of settings such as +cluster.routing.rebalance.enable+) in order to remain in a balanced state. + # For example, if the requested allocation includes moving a shard from node1 to node2 then this may cause a shard to be moved from node2 back to node1 to even things out. + # The cluster can be set to disable allocations using the +cluster.routing.allocation.enable+ setting. + # If allocations are disabled then the only allocations that will be performed are explicit ones given using the reroute command, and consequent allocations due to rebalancing. + # The cluster will attempt to allocate a shard a maximum of +index.allocation.max_retries+ times in a row (defaults to +5+), before giving up and leaving the shard unallocated. + # This scenario can be caused by structural problems such as having an analyzer which refers to a stopwords file which doesn’t exist on all nodes. + # Once the problem has been corrected, allocation can be manually retried by calling the reroute API with the +?retry_failed+ URI query parameter, which will attempt a single retry round for these shards. # - # @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, none, routing_table, master_node, version) - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [Boolean] :dry_run If true, then the request simulates the operation. + # It will calculate the result of applying the commands to the current cluster state and return the resulting cluster state after the commands (and rebalancing) have been applied; it will not actually perform the requested changes. + # @option arguments [Boolean] :explain If true, then the response contains an explanation of why the commands can or cannot run. + # @option arguments [String, Array] :metric Limits the information returned to the specified metrics. Server default: all. + # @option arguments [Boolean] :retry_failed If true, then retries allocation of shards that are blocked due to too many subsequent allocation failures. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The definition of `commands` to perform (`move`, `cancel`, `allocate`) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-reroute # def reroute(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.reroute' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) || {} + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_cluster/reroute" + path = '_cluster/reroute' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/state.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/state.rb index 56b0f07647..e242fde3e0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/state.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/state.rb @@ -15,30 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Returns a comprehensive information about the state of the cluster. + # Get the cluster state. + # Get comprehensive information about the state of the cluster. + # The cluster state is an internal data structure which keeps track of a variety of information needed by every node, including the identity and attributes of the other nodes in the cluster; cluster-wide settings; index metadata, including the mapping and settings for each index; the location and status of every shard copy in the cluster. + # The elected master node ensures that every node in the cluster has a copy of the same cluster state. + # This API lets you retrieve a representation of this internal state for debugging or diagnostic purposes. + # You may need to consult the Elasticsearch source code to determine the precise meaning of the response. + # By default the API will route requests to the elected master node since this node is the authoritative source of cluster states. + # You can also retrieve the cluster state held on the node handling the API request by adding the +?local=true+ query parameter. + # Elasticsearch may need to expend significant effort to compute a response to this API in larger clusters, and the response may comprise a very large quantity of data. + # If you use this API repeatedly, your cluster may become unstable. + # WARNING: The response is a representation of an internal data structure. + # Its format is not subject to the same compatibility guarantees as other more stable APIs and may change from version to version. + # Do not query this API using external monitoring tools. + # Instead, obtain the information you require using other more stable cluster APIs. # - # @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 master node (default: false) - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [String, Array] :metric Limit the information returned to the specified metrics + # @option arguments [String, Array] :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) Server default: true. + # @option arguments [String, Array] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. # @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 [Boolean] :local Return local information, do not retrieve the state from master node (default: false) + # @option arguments [Time] :master_timeout Specify timeout for connection to master Server default: 30s. + # @option arguments [Integer] :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 [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-state # def state(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.state' } + + defined_params = [:metric, :index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -50,16 +70,16 @@ def state(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _metric && _index - "_cluster/state/#{Utils.__listify(_metric)}/#{Utils.__listify(_index)}" + "_cluster/state/#{Utils.listify(_metric)}/#{Utils.listify(_index)}" elsif _metric - "_cluster/state/#{Utils.__listify(_metric)}" + "_cluster/state/#{Utils.listify(_metric)}" else - "_cluster/state" + '_cluster/state' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/stats.rb index abb3424046..fa07c366fa 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cluster/stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cluster/stats.rb @@ -15,23 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Cluster module Actions - # Returns high-level overview of cluster statistics. + # Get cluster statistics. + # Get basic index metrics (shard numbers, store size, memory usage) and information about the current nodes that form the cluster (number, roles, os, jvm versions, memory usage, cpu and installed plugins). # - # @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 [String, Array] :node_id Comma-separated list of node filters used to limit returned information. Defaults to all nodes in the cluster. + # @option arguments [Boolean] :include_remotes Include remote cluster data into the response + # @option arguments [Time] :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 arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-stats # def stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'cluster.stats' } + + defined_params = [:node_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +51,14 @@ def stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _node_id - "_cluster/stats/nodes/#{Utils.__listify(_node_id)}" + "_cluster/stats/nodes/#{Utils.listify(_node_id)}" else - "_cluster/stats" + '_cluster/stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/check_in.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/check_in.rb new file mode 100644 index 0000000000..6211600bbe --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/check_in.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Check in a connector. + # Update the +last_seen+ field in the connector and set it to the current timestamp. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_id The unique identifier of the connector to be checked in (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-check-in + # + def check_in(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.check_in' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_check_in" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/delete.rb new file mode 100644 index 0000000000..c060a3bcff --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/delete.rb @@ -0,0 +1,70 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Delete a connector. + # Removes a connector and associated sync jobs. + # This is a destructive action that is not recoverable. + # NOTE: This action doesn’t delete any API keys, ingest pipelines, or data indices associated with the connector. + # These need to be removed manually. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be deleted (*Required*) + # @option arguments [Boolean] :delete_sync_jobs A flag indicating if associated sync jobs should be also removed. Defaults to false. + # @option arguments [Boolean] :hard A flag indicating if the connector should be hard deleted. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-delete + # + def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.delete' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_connector/#{Utils.listify(_connector_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/get.rb new file mode 100644 index 0000000000..8b195f2435 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/get.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Get a connector. + # Get the details about a connector. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector (*Required*) + # @option arguments [Boolean] :include_deleted A flag to indicate if the desired connector should be fetched, even if it was soft-deleted. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-get + # + def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.get' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_GET + path = "_connector/#{Utils.listify(_connector_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/list.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/list.rb new file mode 100644 index 0000000000..ffa9214b01 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/list.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Get all connectors. + # Get information about all connectors. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [Integer] :from Starting offset (default: 0) + # @option arguments [Integer] :size Specifies a max number of results to get + # @option arguments [String, Array] :index_name A comma-separated list of connector index names to fetch connector documents for + # @option arguments [String, Array] :connector_name A comma-separated list of connector names to fetch connector documents for + # @option arguments [String, Array] :service_type A comma-separated list of connector service types to fetch connector documents for + # @option arguments [Boolean] :include_deleted A flag to indicate if the desired connector should be fetched, even if it was soft-deleted. + # @option arguments [String] :query A wildcard query string that filters connectors with matching name, description or index name + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-list + # + def list(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.list' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_connector' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/post.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/post.rb new file mode 100644 index 0000000000..b67330c469 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/post.rb @@ -0,0 +1,58 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Create a connector. + # Connectors are Elasticsearch integrations that bring content from third-party data sources, which can be deployed on Elastic Cloud or hosted on your own infrastructure. + # Elastic managed connectors (Native connectors) are a managed service on Elastic Cloud. + # Self-managed connectors (Connector clients) are self-managed on your infrastructure. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-put + # + def post(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.post' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_connector' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/put.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/put.rb new file mode 100644 index 0000000000..18790b593b --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/put.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Create or update a connector. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be created or updated. ID is auto-generated if not provided. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-put + # + def put(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.put' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = if _connector_id + "_connector/#{Utils.listify(_connector_id)}" + else + '_connector' + end + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_cancel.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_cancel.rb new file mode 100644 index 0000000000..78b8b46990 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_cancel.rb @@ -0,0 +1,69 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Cancel a connector sync job. + # Cancel a connector sync job, which sets the status to cancelling and updates +cancellation_requested_at+ to the current time. + # The connector service is then responsible for setting the status of connector sync jobs to cancelled. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_sync_job_id The unique identifier of the connector sync job (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-cancel + # + def sync_job_cancel(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_cancel' } + + defined_params = [:connector_sync_job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + unless arguments[:connector_sync_job_id] + raise ArgumentError, + "Required argument 'connector_sync_job_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _connector_sync_job_id = arguments.delete(:connector_sync_job_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/_sync_job/#{Utils.listify(_connector_sync_job_id)}/_cancel" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_check_in.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_check_in.rb new file mode 100644 index 0000000000..8d1fa84500 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_check_in.rb @@ -0,0 +1,70 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Check in a connector sync job. + # Check in a connector sync job and set the +last_seen+ field to the current time before updating it in the internal index. + # To sync data using self-managed connectors, you need to deploy the Elastic connector service on your own infrastructure. + # This service runs automatically on Elastic Cloud for Elastic managed connectors. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_sync_job_id The unique identifier of the connector sync job to be checked in. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-check-in + # + def sync_job_check_in(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_check_in' } + + defined_params = [:connector_sync_job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + unless arguments[:connector_sync_job_id] + raise ArgumentError, + "Required argument 'connector_sync_job_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _connector_sync_job_id = arguments.delete(:connector_sync_job_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/_sync_job/#{Utils.listify(_connector_sync_job_id)}/_check_in" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_claim.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_claim.rb new file mode 100644 index 0000000000..bfd4ec791b --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_claim.rb @@ -0,0 +1,76 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Claim a connector sync job. + # This action updates the job status to +in_progress+ and sets the +last_seen+ and +started_at+ timestamps to the current time. + # Additionally, it can set the +sync_cursor+ property for the sync job. + # This API is not intended for direct connector management by users. + # It supports the implementation of services that utilize the connector protocol to communicate with Elasticsearch. + # To sync data using self-managed connectors, you need to deploy the Elastic connector service on your own infrastructure. + # This service runs automatically on Elastic Cloud for Elastic managed connectors. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_sync_job_id The unique identifier of the connector sync job. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-claim + # + def sync_job_claim(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_claim' } + + defined_params = [:connector_sync_job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + unless arguments[:connector_sync_job_id] + raise ArgumentError, + "Required argument 'connector_sync_job_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_sync_job_id = arguments.delete(:connector_sync_job_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/_sync_job/#{Utils.listify(_connector_sync_job_id)}/_claim" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_delete.rb new file mode 100644 index 0000000000..d71580b6a0 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_delete.rb @@ -0,0 +1,69 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Delete a connector sync job. + # Remove a connector sync job and its associated data. + # This is a destructive action that is not recoverable. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_sync_job_id The unique identifier of the connector sync job to be deleted (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-delete + # + def sync_job_delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_delete' } + + defined_params = [:connector_sync_job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + unless arguments[:connector_sync_job_id] + raise ArgumentError, + "Required argument 'connector_sync_job_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _connector_sync_job_id = arguments.delete(:connector_sync_job_id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_connector/_sync_job/#{Utils.listify(_connector_sync_job_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_error.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_error.rb new file mode 100644 index 0000000000..f1ac042d4c --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_error.rb @@ -0,0 +1,73 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Set a connector sync job error. + # Set the +error+ field for a connector sync job and set its +status+ to +error+. + # To sync data using self-managed connectors, you need to deploy the Elastic connector service on your own infrastructure. + # This service runs automatically on Elastic Cloud for Elastic managed connectors. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_sync_job_id The unique identifier for the connector sync job. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-error + # + def sync_job_error(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_error' } + + defined_params = [:connector_sync_job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + unless arguments[:connector_sync_job_id] + raise ArgumentError, + "Required argument 'connector_sync_job_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_sync_job_id = arguments.delete(:connector_sync_job_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/_sync_job/#{Utils.listify(_connector_sync_job_id)}/_error" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_get.rb new file mode 100644 index 0000000000..48168ac0aa --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_get.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Get a connector sync job. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_sync_job_id The unique identifier of the connector sync job (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-get + # + def sync_job_get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_get' } + + defined_params = [:connector_sync_job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + unless arguments[:connector_sync_job_id] + raise ArgumentError, + "Required argument 'connector_sync_job_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _connector_sync_job_id = arguments.delete(:connector_sync_job_id) + + method = Elasticsearch::API::HTTP_GET + path = "_connector/_sync_job/#{Utils.listify(_connector_sync_job_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_list.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_list.rb new file mode 100644 index 0000000000..0e054905bd --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_list.rb @@ -0,0 +1,60 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Get all connector sync jobs. + # Get information about all stored connector sync jobs listed by their creation date in ascending order. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [Integer] :from Starting offset (default: 0) + # @option arguments [Integer] :size Specifies a max number of results to get + # @option arguments [String] :status A sync job status to fetch connector sync jobs for + # @option arguments [String] :connector_id A connector id to fetch connector sync jobs for + # @option arguments [Syncjobtype] :job_type A comma-separated list of job types to fetch the sync jobs for + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-list + # + def sync_job_list(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_list' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_connector/_sync_job' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_post.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_post.rb new file mode 100644 index 0000000000..64440d13a0 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_post.rb @@ -0,0 +1,58 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Create a connector sync job. + # Create a connector sync job document in the internal index and initialize its counters and timestamps with default values. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-post + # + def sync_job_post(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_post' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_connector/_sync_job' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_update_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_update_stats.rb new file mode 100644 index 0000000000..ede9d35e74 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/sync_job_update_stats.rb @@ -0,0 +1,75 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Set the connector sync job stats. + # Stats include: +deleted_document_count+, +indexed_document_count+, +indexed_document_volume+, and +total_document_count+. + # You can also update +last_seen+. + # This API is mainly used by the connector service for updating sync job information. + # To sync data using self-managed connectors, you need to deploy the Elastic connector service on your own infrastructure. + # This service runs automatically on Elastic Cloud for Elastic managed connectors. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_sync_job_id The unique identifier of the connector sync job. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-sync-job-update-stats + # + def sync_job_update_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.sync_job_update_stats' } + + defined_params = [:connector_sync_job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + unless arguments[:connector_sync_job_id] + raise ArgumentError, + "Required argument 'connector_sync_job_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_sync_job_id = arguments.delete(:connector_sync_job_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/_sync_job/#{Utils.listify(_connector_sync_job_id)}/_stats" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_active_filtering.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_active_filtering.rb new file mode 100644 index 0000000000..3f9e15887c --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_active_filtering.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Activate the connector draft filter. + # Activates the valid draft filtering for a connector. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-filtering + # + def update_active_filtering(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_active_filtering' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_filtering/_activate" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_api_key_id.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_api_key_id.rb new file mode 100644 index 0000000000..4f02552408 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_api_key_id.rb @@ -0,0 +1,70 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector API key ID. + # Update the +api_key_id+ and +api_key_secret_id+ fields of a connector. + # You can specify the ID of the API key used for authorization and the ID of the connector secret where the API key is stored. + # The connector secret ID is required only for Elastic managed (native) connectors. + # Self-managed connectors (connector clients) do not use this field. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-api-key-id + # + def update_api_key_id(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_api_key_id' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_api_key_id" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_configuration.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_configuration.rb new file mode 100644 index 0000000000..c546b9918f --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_configuration.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector configuration. + # Update the configuration field in the connector document. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-configuration + # + def update_configuration(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_configuration' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_configuration" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_error.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_error.rb new file mode 100644 index 0000000000..bbc3739934 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_error.rb @@ -0,0 +1,69 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector error field. + # Set the error field for the connector. + # If the error provided in the request body is non-null, the connector’s status is updated to error. + # Otherwise, if the error is reset to null, the connector status is updated to connected. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-error + # + def update_error(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_error' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_error" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_features.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_features.rb new file mode 100644 index 0000000000..ae99d9707b --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_features.rb @@ -0,0 +1,76 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector features. + # Update the connector features in the connector document. + # This API can be used to control the following aspects of a connector: + # * document-level security + # * incremental syncs + # * advanced sync rules + # * basic sync rules + # Normally, the running connector service automatically manages these features. + # However, you can use this API to override the default behavior. + # To sync data using self-managed connectors, you need to deploy the Elastic connector service on your own infrastructure. + # This service runs automatically on Elastic Cloud for Elastic managed connectors. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_id The unique identifier of the connector to be updated. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-features + # + def update_features(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_features' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_features" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_filtering.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_filtering.rb new file mode 100644 index 0000000000..0a60fae3bf --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_filtering.rb @@ -0,0 +1,69 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector filtering. + # Update the draft filtering configuration of a connector and marks the draft validation state as edited. + # The filtering draft is activated once validated by the running Elastic connector service. + # The filtering property is used to configure sync rules (both basic and advanced) for a connector. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-filtering + # + def update_filtering(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_filtering' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_filtering" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_filtering_validation.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_filtering_validation.rb new file mode 100644 index 0000000000..24f0cb02ed --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_filtering_validation.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector draft filtering validation. + # Update the draft filtering validation info for a connector. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-filtering-validation + # + def update_filtering_validation(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_filtering_validation' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_filtering/_validation" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_index_name.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_index_name.rb new file mode 100644 index 0000000000..0b9d9df6b5 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_index_name.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector index name. + # Update the +index_name+ field of a connector, specifying the index where the data ingested by the connector is stored. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-index-name + # + def update_index_name(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_index_name' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_index_name" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_name.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_name.rb new file mode 100644 index 0000000000..6172403ae1 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_name.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector name and description. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-name + # + def update_name(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_name' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_name" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_native.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_native.rb new file mode 100644 index 0000000000..198da2fa76 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_native.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector is_native flag. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-native + # + def update_native(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_native' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_native" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_pipeline.rb new file mode 100644 index 0000000000..8b983849f0 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_pipeline.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector pipeline. + # When you create a new connector, the configuration of an ingest pipeline is populated with default settings. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-pipeline + # + def update_pipeline(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_pipeline' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_pipeline" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_scheduling.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_scheduling.rb new file mode 100644 index 0000000000..960f89eaea --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_scheduling.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector scheduling. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-scheduling + # + def update_scheduling(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_scheduling' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_scheduling" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_service_type.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_service_type.rb new file mode 100644 index 0000000000..e13e597747 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_service_type.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector service type. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + # + # @option arguments [String] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-service-type + # + def update_service_type(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_service_type' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_service_type" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_status.rb new file mode 100644 index 0000000000..89098f8323 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/connector/update_status.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Connector + module Actions + # Update the connector status. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :connector_id The unique identifier of the connector to be updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-status + # + def update_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'connector.update_status' } + + defined_params = [:connector_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'connector_id' missing" unless arguments[:connector_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _connector_id = arguments.delete(:connector_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_connector/#{Utils.listify(_connector_id)}/_status" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/count.rb b/elasticsearch-api/lib/elasticsearch/api/actions/count.rb index 7c66173d03..5600a3b1d3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/count.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/count.rb @@ -15,39 +15,70 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns number of documents matching a query. + # Count search results. + # Get the number of documents matching a query. + # The query can be provided either by using a simple query string as a parameter, or by defining Query DSL within the request body. + # The query is optional. When no query is provided, the API uses +match_all+ to count all the documents. + # The count API supports multi-target syntax. You can run a single count API search across multiple data streams and indices. + # The operation is broadcast across all shards. + # For each shard ID group, a replica is chosen and the search is run against it. + # This means that replicas increase the scalability of the count. # - # @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 [String, Array] :index A comma-separated list of data streams, indices, and aliases to search. + # It supports wildcards (+*+). + # To search all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. + # @option arguments [String] :analyzer The analyzer to use for the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [Boolean] :analyze_wildcard If +true+, wildcard and prefix queries are analyzed. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [String] :default_operator The default operator for query string query: +AND+ or +OR+. + # This parameter can be used only when the +q+ query string parameter is specified. Server default: OR. + # @option arguments [String] :df The field to use as a default when no field prefix is given in the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [String, Array] :expand_wildcards The 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. + # It supports comma-separated values, such as +open,hidden+. Server default: open. + # @option arguments [Boolean] :ignore_throttled If +true+, concrete, expanded, or aliased indices are ignored when frozen. Server default: true. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [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 be used only when the +q+ query string parameter is specified. + # @option arguments [Float] :min_score The minimum +_score+ value that documents must have to be included in the result. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # By default, it is random. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Integer] :terminate_after The maximum number of documents to collect for each shard. + # If a query reaches this limit, Elasticsearch terminates the query early. + # Elasticsearch collects documents before sorting.IMPORTANT: Use with caution. + # Elasticsearch applies this parameter to each shard handling the request. + # When possible, let Elasticsearch perform early termination automatically. + # Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + # @option arguments [String] :q The query in Lucene query string syntax. This parameter cannot be used with a request body. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body A query to restrict the results specified with the Query DSL (optional) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-count # def count(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'count' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -58,14 +89,14 @@ def count(arguments = {}) end path = if _index - "#{Utils.__listify(_index)}/_count" + "#{Utils.listify(_index)}/_count" else - "_count" + '_count' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/create.rb b/elasticsearch-api/lib/elasticsearch/api/actions/create.rb index d4f3676fdb..d631a1bba9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/create.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/create.rb @@ -15,36 +15,131 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch 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. + # Create a new document in the index. + # You can index a new JSON document with the +//_doc/+ or +//_create/<_id>+ APIs + # Using +_create+ guarantees that the document is indexed only if it does not already exist. + # It returns a 409 response when a document with a same ID already exists in the index. + # To update an existing document, you must use the +//_doc/+ API. + # If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias: + # * To add a document using the +PUT //_create/<_id>+ or +POST //_create/<_id>+ request formats, you must have the +create_doc+, +create+, +index+, or +write+ index privilege. + # * To automatically create a data stream or index with this API request, you must have the +auto_configure+, +create_index+, or +manage+ index privilege. + # Automatic data stream creation requires a matching index template with data stream enabled. + # **Automatically create data streams and indices** + # If the request's target doesn't exist and matches an index template with a +data_stream+ definition, the index operation automatically creates the data stream. + # If the target doesn't exist and doesn't match a data stream template, the operation automatically creates the index and applies any matching index templates. + # NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation. + # If no mapping exists, the index operation creates a dynamic mapping. + # By default, new fields and objects are automatically added to the mapping if needed. + # Automatic index creation is controlled by the +action.auto_create_index+ setting. + # If it is +true+, any index can be created automatically. + # You can modify this setting to explicitly allow or block automatic creation of indices that match specified patterns or set it to +false+ to turn off automatic index creation entirely. + # Specify a comma-separated list of patterns you want to allow or prefix each pattern with +++ or +-+ to indicate whether it should be allowed or blocked. + # When a list is specified, the default behaviour is to disallow. + # NOTE: The +action.auto_create_index+ setting affects the automatic creation of indices only. + # It does not affect the creation of data streams. + # **Routing** + # By default, shard placement — or routing — is controlled by using a hash of the document's ID value. + # For more explicit control, the value fed into the hash function used by the router can be directly specified on a per-operation basis using the +routing+ parameter. + # When setting up explicit mapping, you can also use the +_routing+ field to direct the index operation to extract the routing value from the document itself. + # This does come at the (very minimal) cost of an additional document parsing pass. + # If the +_routing+ mapping is defined and set to be required, the index operation will fail if no routing value is provided or extracted. + # NOTE: Data streams do not support custom routing unless they were created with the +allow_custom_routing+ setting enabled in the template. + # **Distributed** + # The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard. + # After the primary shard completes the operation, if needed, the update is distributed to applicable replicas. + # **Active shards** + # To improve the resiliency of writes to the system, indexing operations can be configured to wait for a certain number of active shard copies before proceeding with the operation. + # If the requisite number of active shard copies are not available, then the write operation must wait and retry, until either the requisite shard copies have started or a timeout occurs. + # By default, write operations only wait for the primary shards to be active before proceeding (that is to say +wait_for_active_shards+ is +1+). + # This default can be overridden in the index settings dynamically by setting +index.write.wait_for_active_shards+. + # To alter this behavior per operation, use the +wait_for_active_shards request+ parameter. + # Valid values are all or any positive integer up to the total number of configured copies per shard in the index (which is +number_of_replicas++1). + # Specifying a negative value or a number greater than the number of shard copies will throw an error. + # For example, suppose you have a cluster of three nodes, A, B, and C and you create an index index with the number of replicas set to 3 (resulting in 4 shard copies, one more copy than there are nodes). + # If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding. + # This means that even if B and C went down and A hosted the primary shard copies, the indexing operation would still proceed with only one copy of the data. + # If +wait_for_active_shards+ is set on the request to +3+ (and all three nodes are up), the indexing operation will require 3 active shard copies before proceeding. + # This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard. + # However, if you set +wait_for_active_shards+ to +all+ (or to +4+, which is the same in this situation), the indexing operation will not proceed as you do not have all 4 copies of each shard active in the index. + # The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard. + # It is important to note that this setting greatly reduces the chances of the write operation not writing to the requisite number of shard copies, but it does not completely eliminate the possibility, because this check occurs before the write operation starts. + # After the write operation is underway, it is still possible for replication to fail on any number of shard copies but still succeed on the primary. + # The +_shards+ section of the API response reveals the number of shard copies on which replication succeeded and failed. # - # @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 [String] :id A unique identifier for the document. + # To automatically generate a document ID, use the +POST //_doc/+ request format. (*Required*) + # @option arguments [String] :index The 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. (*Required*) + # @option arguments [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option arguments [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option arguments [Boolean] :include_source_on_error True or false if to include the document source in the error message in case of parsing errors. Server default: true. + # @option arguments [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. + # The behavior is the same as using the +/_create+ endpoint. + # If a document ID is specified, this paramater defaults to +index+. + # Otherwise, it defaults to +create+. + # If the request targets a data stream, an +op_type+ of +create+ is required. + # @option arguments [String] :pipeline The ID of the pipeline to use to preprocess incoming documents. + # If the index has a default ingest pipeline specified, setting the value to +_none+ turns off 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 arguments [String] :refresh If +true+, Elasticsearch refreshes the affected shards to make this operation visible to search. + # If +wait_for+, it waits for a refresh to make this operation visible to search. + # If +false+, it does nothing with refreshes. Server default: false. + # @option arguments [Boolean] :require_alias If +true+, the destination must be an index alias. + # @option arguments [Boolean] :require_data_stream If +true+, the request's actions must target a data stream (existing or to be created). + # @option arguments [String] :routing A custom value that is used to route operations to a specific shard. + # @option arguments [Time] :timeout The period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. + # Elasticsearch waits for at least the specified timeout period before failing. + # The actual wait time could be longer, particularly when multiple waits occur.This parameter is useful for situations where the primary shard assigned to perform the operation might not be available when the operation runs. + # Some reasons for this might be that the primary shard is currently recovering from a gateway or undergoing relocation. + # By default, the operation will wait on the primary shard to become available for at least 1 minute before failing and responding with an error. + # The actual wait time could be longer, particularly when multiple waits occur. Server default: 1m. + # @option arguments [Integer] :version The explicit version number for concurrency control. + # It must be a non-negative long number. + # @option arguments [String] :version_type The version type. + # @option arguments [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. + # You can set it to +all+ or any positive integer up to the total number of shards in the index (+number_of_replicas+1+). + # The default value of +1+ means it waits for each primary shard to be active. Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The document (*Required*) + # @option arguments [Hash] :body document # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-create # def create(arguments = {}) - if arguments[:id] - index arguments.update op_type: 'create' - else - index arguments + request_opts = { endpoint: arguments[:endpoint] || 'create' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + 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] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _id = arguments.delete(:id) + + _index = arguments.delete(:index) + + method = Elasticsearch::API::HTTP_PUT + path = "#{Utils.listify(_index)}/_create/#{Utils.listify(_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/delete_auto_follow_pattern.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/delete_auto_follow_pattern.rb index 83fdb12e10..71289336eb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/delete_auto_follow_pattern.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/delete_auto_follow_pattern.rb @@ -15,21 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Deletes auto-follow patterns. + # Delete auto-follow patterns. + # Delete a collection of cross-cluster replication auto-follow patterns. # - # @option arguments [String] :name The name of the auto follow pattern. + # @option arguments [String] :name The auto-follow pattern collection to delete. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-delete-auto-follow-pattern # def delete_auto_follow_pattern(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.delete_auto_follow_pattern' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -40,11 +51,11 @@ def delete_auto_follow_pattern(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_ccr/auto_follow/#{Utils.__listify(_name)}" - params = {} + path = "_ccr/auto_follow/#{Utils.listify(_name)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow.rb index 4f276f904d..17321f77be 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow.rb @@ -15,39 +15,52 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Creates a new follower index configured to follow the referenced leader index. + # Create a follower. + # Create a cross-cluster replication follower index that follows a specific leader index. + # When the API returns, the follower index exists and cross-cluster replication starts replicating operations from the leader index to the follower index. # - # @option arguments [String] :index The name of the follower index - # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before returning. Defaults to 0. 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] :index The name of the follower index. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [Integer, String] :wait_for_active_shards Specifies the number of shards to wait on being active before responding. This defaults to waiting on none of the shards to be + # active. + # A shard must be restored from the leader index before being active. Restoring a follower shard requires transferring all the + # remote Lucene segment files to the follower index. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The name of the leader index and other optional ccr related parameters (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-follow # def follow(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.follow' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_ccr/follow" + path = "#{Utils.listify(_index)}/_ccr/follow" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow_info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow_info.rb index 8e79207d9e..97f99ecb4d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow_info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow_info.rb @@ -15,36 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Retrieves information about all follower indices, including parameters and status for each follower index + # Get follower information. + # Get information about all cross-cluster replication follower indices. + # For example, the results include follower index names, leader index names, replication options, and whether the follower indices are active or paused. # - # @option arguments [List] :index A comma-separated list of index patterns; use `_all` to perform the operation on all indices + # @option arguments [String, Array] :index A comma-delimited list of follower index patterns. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-follow-info # def follow_info(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.follow_info' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_ccr/info" - params = {} + path = "#{Utils.listify(_index)}/_ccr/info" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow_stats.rb index 26fb2c8718..3997b99c7b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/follow_stats.rb @@ -15,36 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices. + # Get follower stats. + # Get cross-cluster replication follower stats. + # The API returns shard-level stats about the "following tasks" associated with each shard for the specified indices. # - # @option arguments [List] :index A comma-separated list of index patterns; use `_all` to perform the operation on all indices + # @option arguments [String, Array] :index A comma-delimited list of index patterns. (*Required*) + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-follow-stats # def follow_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.follow_stats' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_ccr/stats" - params = {} + path = "#{Utils.listify(_index)}/_ccr/stats" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/forget_follower.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/forget_follower.rb index 89f2853ff7..0d5a49bfd7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/forget_follower.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/forget_follower.rb @@ -15,38 +15,55 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Removes the follower retention leases from the leader. + # Forget a follower. + # Remove the cross-cluster replication follower retention leases from the leader. + # A following index takes out retention leases on its leader index. + # These leases are used to increase the likelihood that the shards of the leader index retain the history of operations that the shards of the following index need to run replication. + # When a follower index is converted to a regular index by the unfollow API (either by directly calling the API or by index lifecycle management tasks), these leases are removed. + # However, removal of the leases can fail, for example when the remote cluster containing the leader index is unavailable. + # While the leases will eventually expire on their own, their extended existence can cause the leader index to hold more history than necessary and prevent index lifecycle management from performing some operations on the leader index. + # This API exists to enable manually removing the leases when the unfollow API is unable to do so. + # NOTE: This API does not stop replication by a following index. If you use this API with a follower index that is still actively following, the following index will add back retention leases on the leader. + # The only purpose of this API is to handle the case of failure to remove the following retention leases after the unfollow API is invoked. # - # @option arguments [String] :index the name of the leader index for which specified follower retention leases should be removed + # @option arguments [String] :index the name of the leader index for which specified follower retention leases should be removed (*Required*) + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-forget-follower.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-forget-follower # def forget_follower(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.forget_follower' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_ccr/forget_follower" - params = {} + path = "#{Utils.listify(_index)}/_ccr/forget_follower" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/get_auto_follow_pattern.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/get_auto_follow_pattern.rb index d6d2fb8b42..389006f732 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/get_auto_follow_pattern.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/get_auto_follow_pattern.rb @@ -15,21 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection. + # Get auto-follow patterns. + # Get cross-cluster replication auto-follow patterns. # - # @option arguments [String] :name The name of the auto follow pattern. + # @option arguments [String] :name The auto-follow pattern collection that you want to retrieve. + # If you do not specify a name, the API returns information for all collections. + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-get-auto-follow-pattern-1 # def get_auto_follow_pattern(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.get_auto_follow_pattern' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -39,14 +51,14 @@ def get_auto_follow_pattern(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_ccr/auto_follow/#{Utils.__listify(_name)}" + "_ccr/auto_follow/#{Utils.listify(_name)}" else - "_ccr/auto_follow" + '_ccr/auto_follow' end - params = {} + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/pause_auto_follow_pattern.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/pause_auto_follow_pattern.rb index 894c598491..ae3e7e1607 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/pause_auto_follow_pattern.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/pause_auto_follow_pattern.rb @@ -15,21 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Pauses an auto-follow pattern + # Pause an auto-follow pattern. + # Pause a cross-cluster replication auto-follow pattern. + # When the API returns, the auto-follow pattern is inactive. + # New indices that are created on the remote cluster and match the auto-follow patterns are ignored. + # You can resume auto-following with the resume auto-follow pattern API. + # When it resumes, the auto-follow pattern is active again and automatically configures follower indices for newly created indices on the remote cluster that match its patterns. + # Remote indices that were created while the pattern was paused will also be followed, unless they have been deleted or closed in the interim. # - # @option arguments [String] :name The name of the auto follow pattern that should pause discovering new indices to follow. + # @option arguments [String] :name The name of the auto-follow pattern to pause. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-pause-auto-follow-pattern # def pause_auto_follow_pattern(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.pause_auto_follow_pattern' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -40,11 +56,11 @@ def pause_auto_follow_pattern(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_POST - path = "_ccr/auto_follow/#{Utils.__listify(_name)}/pause" - params = {} + path = "_ccr/auto_follow/#{Utils.listify(_name)}/pause" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/pause_follow.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/pause_follow.rb index f4bbb1eb78..0e48a15183 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/pause_follow.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/pause_follow.rb @@ -15,36 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Pauses a follower index. The follower index will not fetch any additional operations from the leader index. + # Pause a follower. + # Pause a cross-cluster replication follower index. + # The follower index will not fetch any additional operations from the leader index. + # You can resume following with the resume follower API. + # You can pause and resume a follower index to change the configuration of the following task. # - # @option arguments [String] :index The name of the follower index that should pause following its leader index. + # @option arguments [String] :index The name of the follower index. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-pause-follow # def pause_follow(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.pause_follow' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_ccr/pause_follow" - params = {} + path = "#{Utils.listify(_index)}/_ccr/pause_follow" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/put_auto_follow_pattern.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/put_auto_follow_pattern.rb index dfa3b58798..92318b8ba2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/put_auto_follow_pattern.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/put_auto_follow_pattern.rb @@ -15,22 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Creates a new named collection of auto-follow patterns against a specified remote cluster. Newly created indices on the remote cluster matching any of the specified patterns will be automatically configured as follower indices. + # Create or update auto-follow patterns. + # Create a collection of cross-cluster replication auto-follow patterns for a remote cluster. + # Newly created indices on the remote cluster that match any of the patterns are automatically configured as follower indices. + # Indices on the remote cluster that were created before the auto-follow pattern was created will not be auto-followed even if they match the pattern. + # This API can also be used to update auto-follow patterns. + # NOTE: Follower indices that were configured automatically before updating an auto-follow pattern will remain unchanged even if they do not match against the new patterns. # - # @option arguments [String] :name The name of the auto follow pattern. + # @option arguments [String] :name The name of the collection of auto-follow patterns. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The specification of the auto follow pattern (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-put-auto-follow-pattern # def put_auto_follow_pattern(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.put_auto_follow_pattern' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -42,11 +55,11 @@ def put_auto_follow_pattern(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_ccr/auto_follow/#{Utils.__listify(_name)}" - params = {} + path = "_ccr/auto_follow/#{Utils.listify(_name)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/resume_auto_follow_pattern.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/resume_auto_follow_pattern.rb index e6b32f55bc..c2d10db56a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/resume_auto_follow_pattern.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/resume_auto_follow_pattern.rb @@ -15,21 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Resumes an auto-follow pattern that has been paused + # Resume an auto-follow pattern. + # Resume a cross-cluster replication auto-follow pattern that was paused. + # The auto-follow pattern will resume configuring following indices for newly created indices that match its patterns on the remote cluster. + # Remote indices created while the pattern was paused will also be followed unless they have been deleted or closed in the interim. # - # @option arguments [String] :name The name of the auto follow pattern to resume discovering new indices to follow. + # @option arguments [String] :name The name of the auto-follow pattern to resume. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-resume-auto-follow-pattern # def resume_auto_follow_pattern(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.resume_auto_follow_pattern' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -40,11 +53,11 @@ def resume_auto_follow_pattern(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_POST - path = "_ccr/auto_follow/#{Utils.__listify(_name)}/resume" - params = {} + path = "_ccr/auto_follow/#{Utils.listify(_name)}/resume" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/resume_follow.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/resume_follow.rb index 82357e2a5d..5f98010414 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/resume_follow.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/resume_follow.rb @@ -15,37 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Resumes a follower index that has been paused + # Resume a follower. + # Resume a cross-cluster replication follower index that was paused. + # The follower index could have been paused with the pause follower API. + # Alternatively it could be paused due to replication that cannot be retried due to failures during following tasks. + # When this API returns, the follower index will resume fetching operations from the leader index. # - # @option arguments [String] :index The name of the follow index to resume following. + # @option arguments [String] :index The name of the follow index to resume following. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The name of the leader index and other optional ccr related parameters + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-resume-follow # def resume_follow(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.resume_follow' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_ccr/resume_follow" - params = {} + path = "#{Utils.listify(_index)}/_ccr/resume_follow" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/stats.rb index 10ebac4884..c43c2431b2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/stats.rb @@ -15,31 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Gets all stats related to cross-cluster replication. + # Get cross-cluster replication stats. + # This API returns stats about auto-following and the same shard-level stats as the get follower stats API. # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-stats # def stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.stats' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_ccr/stats" - params = {} + path = '_ccr/stats' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/unfollow.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/unfollow.rb index 9c411d82bc..08d8fc3e02 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/unfollow.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cross_cluster_replication/unfollow.rb @@ -15,36 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module CrossClusterReplication module Actions - # Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication. + # Unfollow an index. + # Convert a cross-cluster replication follower index to a regular index. + # The API stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication. + # The follower index must be paused and closed before you call the unfollow API. # - # @option arguments [String] :index The name of the follower index that should be turned into a regular index. + # @option arguments [String] :index The name of the follower index. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-unfollow.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-unfollow # def unfollow(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ccr.unfollow' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_ccr/unfollow" - params = {} + path = "#{Utils.listify(_index)}/_ccr/unfollow" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb b/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb index 044a99de9f..e480bd03b1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb @@ -15,24 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module DanglingIndices module Actions - # Deletes the specified dangling index + # Delete a dangling index. + # If Elasticsearch encounters index data that is absent from the current cluster state, those indices are considered to be dangling. + # For example, this can happen if you delete more than +cluster.indices.tombstones.size+ indices while an Elasticsearch node is offline. # - # @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 [String] :index_uuid The UUID of the index to delete. Use the get dangling indices API to find the UUID. (*Required*) + # @option arguments [Boolean] :accept_data_loss This parameter must be set to true to acknowledge that it will no longer be possible to recove data from the dangling index. (*Required*) # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [Time] :timeout Explicit operation timeout # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway-dangling-indices.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-dangling-indices-delete-dangling-index # def delete_dangling_index(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'dangling_indices.delete_dangling_index' } + + defined_params = [:index_uuid].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index_uuid' missing" unless arguments[:index_uuid] arguments = arguments.clone @@ -43,11 +52,11 @@ def delete_dangling_index(arguments = {}) _index_uuid = arguments.delete(:index_uuid) method = Elasticsearch::API::HTTP_DELETE - path = "_dangling/#{Utils.__listify(_index_uuid)}" + path = "_dangling/#{Utils.listify(_index_uuid)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb b/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb index fb1c45a360..ff9ab687c8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb @@ -15,24 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module DanglingIndices module Actions - # Imports the specified dangling index + # Import a dangling index. + # If Elasticsearch encounters index data that is absent from the current cluster state, those indices are considered to be dangling. + # For example, this can happen if you delete more than +cluster.indices.tombstones.size+ indices while an Elasticsearch node is offline. # - # @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 [String] :index_uuid The UUID of the index to import. Use the get dangling indices API to locate the UUID. (*Required*) + # @option arguments [Boolean] :accept_data_loss This parameter must be set to true to import a dangling index. + # Because Elasticsearch cannot know where the dangling index data came from or determine which shard copies are fresh and which are stale, it cannot guarantee that the imported data represents the latest state of the index when it was last in the cluster. (*Required*) # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [Time] :timeout Explicit operation timeout # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway-dangling-indices.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-dangling-indices-import-dangling-index # def import_dangling_index(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'dangling_indices.import_dangling_index' } + + defined_params = [:index_uuid].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index_uuid' missing" unless arguments[:index_uuid] arguments = arguments.clone @@ -43,11 +53,11 @@ def import_dangling_index(arguments = {}) _index_uuid = arguments.delete(:index_uuid) method = Elasticsearch::API::HTTP_POST - path = "_dangling/#{Utils.__listify(_index_uuid)}" + path = "_dangling/#{Utils.listify(_index_uuid)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb b/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb index 57a11e424a..18cf82e5f4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb @@ -15,31 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module DanglingIndices module Actions - # Returns all dangling indices. + # Get the dangling indices. + # If Elasticsearch encounters index data that is absent from the current cluster state, those indices are considered to be dangling. + # For example, this can happen if you delete more than +cluster.indices.tombstones.size+ indices while an Elasticsearch node is offline. + # Use this API to list dangling indices, which you can then import or delete. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway-dangling-indices.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-dangling-indices-list-dangling-indices # def list_dangling_indices(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'dangling_indices.list_dangling_indices' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_dangling" + path = '_dangling' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/delete.rb index 692ff9438d..37367fe4c4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/delete.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/delete.rb @@ -15,29 +15,67 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Removes a document from the index. + # Delete a document. + # Remove a JSON document from the specified index. + # NOTE: You cannot send deletion requests directly to a data stream. + # To delete a document in a data stream, you must target the backing index containing the document. + # **Optimistic concurrency control** + # Delete operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the +if_seq_no+ and +if_primary_term+ parameters. + # If a mismatch is detected, the operation will result in a +VersionConflictException+ and a status code of +409+. + # **Versioning** + # Each document indexed is versioned. + # When deleting a document, the version can be specified to make sure the relevant document you are trying to delete is actually being deleted and it has not changed in the meantime. + # Every write operation run on a document, deletes included, causes its version to be incremented. + # The version number of a deleted document remains available for a short time after deletion to allow for control of concurrent operations. + # The length of time for which a deleted document's version remains available is determined by the +index.gc_deletes+ index setting. + # **Routing** + # If routing is used during indexing, the routing value also needs to be specified to delete a document. + # If the +_routing+ mapping is set to +required+ and no routing value is specified, the delete API throws a +RoutingMissingException+ and rejects the request. + # For example: + # + + # DELETE /my-index-000001/_doc/1?routing=shard-1 + # + + # This request deletes the document with ID 1, but it is routed based on the user. + # The document is not deleted if the correct routing is not specified. + # **Distributed** + # The delete operation gets hashed into a specific shard ID. + # It then gets redirected into the primary shard within that ID group and replicated (if needed) to shard replicas within that ID group. # - # @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) + # @option arguments [String] :id A unique identifier for the document. (*Required*) + # @option arguments [String] :index The name of the target index. (*Required*) + # @option arguments [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option arguments [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option arguments [String] :refresh If +true+, Elasticsearch refreshes the affected shards to make this operation visible to search. + # If +wait_for+, it waits for a refresh to make this operation visible to search. + # If +false+, it does nothing with refreshes. Server default: false. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Time] :timeout The period to wait for active shards.This parameter is useful for situations where the primary shard assigned to perform the delete operation might not be available when the delete operation runs. + # Some reasons for this might be that the primary shard is currently recovering from a store or undergoing relocation. + # By default, the delete operation will wait on the primary shard to become available for up to 1 minute before failing and responding with an error. Server default: 1m. + # @option arguments [Integer] :version An explicit version number for concurrency control. + # It must match the current version of the document for the request to succeed. + # @option arguments [String] :version_type The version type. + # @option arguments [Integer, String] :wait_for_active_shards The minimum number of shard copies that must be active before proceeding with the operation. + # You can set it to +all+ or any positive integer up to the total number of shards in the index (+number_of_replicas+1+). + # The default value of +1+ means it waits for each primary shard to be active. Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete # def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'delete' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -51,18 +89,18 @@ def delete(arguments = {}) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_DELETE - path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" + path = "#{Utils.listify(_index)}/_doc/#{Utils.listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb index 00ab16999e..c7489af433 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb @@ -15,66 +15,155 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Deletes documents matching the provided query. + # Delete documents. + # Deletes documents that match the specified query. + # If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias: + # * +read+ + # * +delete+ or +write+ + # You can specify the query criteria in the request URI or the request body using the same syntax as the search API. + # When you submit a delete by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and deletes matching documents using internal versioning. + # If a document changes between the time that the snapshot is taken and the delete operation is processed, it results in a version conflict and the delete operation fails. + # NOTE: Documents with a version equal to 0 cannot be deleted using delete by query because internal versioning does not support 0 as a valid version number. + # While processing a delete by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents to delete. + # A bulk delete request is performed for each batch of matching documents. + # If a search or bulk request is rejected, the requests are retried up to 10 times, with exponential back off. + # If the maximum retry limit is reached, processing halts and all failed requests are returned in the response. + # Any delete requests that completed successfully still stick, they are not rolled back. + # You can opt to count version conflicts instead of halting and returning by setting +conflicts+ to +proceed+. + # Note that if you opt to count version conflicts the operation could attempt to delete more documents from the source than +max_docs+ until it has successfully deleted +max_docs documents+, or it has gone through every document in the source query. + # **Throttling delete requests** + # To control the rate at which delete by query issues batches of delete operations, you can set +requests_per_second+ to any positive decimal number. + # This pads each batch with a wait time to throttle the rate. + # Set +requests_per_second+ to +-1+ to disable throttling. + # Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account. + # The padding time is the difference between the batch size divided by the +requests_per_second+ and the time spent writing. + # By default the batch size is +1000+, so if +requests_per_second+ is set to +500+: + # + + # target_time = 1000 / 500 per second = 2 seconds + # wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds + # + + # Since the batch is issued as a single +_bulk+ request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set. + # This is "bursty" instead of "smooth". + # **Slicing** + # Delete by query supports sliced scroll to parallelize the delete process. + # This can improve efficiency and provide a convenient way to break the request down into smaller parts. + # Setting +slices+ to +auto+ lets Elasticsearch choose the number of slices to use. + # This setting will use one slice per shard, up to a certain limit. + # If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards. + # Adding slices to the delete by query operation creates sub-requests which means it has some quirks: + # * You can see these requests in the tasks APIs. These sub-requests are "child" tasks of the task for the request with slices. + # * Fetching the status of the task for the request with slices only contains the status of completed slices. + # * These sub-requests are individually addressable for things like cancellation and rethrottling. + # * Rethrottling the request with +slices+ will rethrottle the unfinished sub-request proportionally. + # * Canceling the request with +slices+ will cancel each sub-request. + # * Due to the nature of +slices+ each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution. + # * Parameters like +requests_per_second+ and +max_docs+ on a request with +slices+ are distributed proportionally to each sub-request. Combine that with the earlier point about distribution being uneven and you should conclude that using +max_docs+ with +slices+ might not result in exactly +max_docs+ documents being deleted. + # * Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time. + # If you're slicing manually or otherwise tuning automatic slicing, keep in mind that: + # * Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many +slices+ hurts performance. Setting +slices+ higher than the number of shards generally does not improve efficiency and adds overhead. + # * Delete performance scales linearly across available resources with the number of slices. + # Whether query or delete performance dominates the runtime depends on the documents being reindexed and cluster resources. + # **Cancel a delete by query operation** + # Any delete by query can be canceled using the task cancel API. For example: + # + + # POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel + # + + # The task ID can be found by using the get tasks API. + # Cancellation should happen quickly but might take a few seconds. + # The get task status API will continue to list the delete by query task until this task checks that it has been cancelled and terminates itself. # - # @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 [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] :max_docs Maximum number of documents to process (default: all documents) - # @option arguments [List] :sort A comma-separated list of : pairs - # @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 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 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 [String, Array] :index A comma-separated list of data streams, indices, and aliases to search. + # It supports wildcards (+*+). + # To search all data streams or indices, omit this parameter or use +*+ or +_all+. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. + # @option arguments [String] :analyzer Analyzer to use for the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [Boolean] :analyze_wildcard If +true+, wildcard and prefix queries are analyzed. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [String] :conflicts What to do if delete by query hits version conflicts: +abort+ or +proceed+. Server default: abort. + # @option arguments [String] :default_operator The default operator for query string query: +AND+ or +OR+. + # This parameter can be used only when the +q+ query string parameter is specified. Server default: OR. + # @option arguments [String] :df The field to use as default where no field prefix is given in the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [String, Array] :expand_wildcards The 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. + # It supports comma-separated values, such as +open,hidden+. Server default: open. + # @option arguments [Integer] :from Skips the specified number of documents. Server default: 0. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [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 be used only when the +q+ query string parameter is specified. + # @option arguments [Integer] :max_docs The maximum number of documents to process. + # Defaults to all documents. + # When set to a value less then or equal to +scroll_size+, a scroll will not be used to retrieve the results for the operation. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # It is random by default. + # @option arguments [Boolean] :refresh If +true+, Elasticsearch refreshes all shards involved in the delete by query after the request completes. + # This is different than the delete API's +refresh+ parameter, which causes just the shard that received the delete request to be refreshed. + # Unlike the delete API, it does not support +wait_for+. + # @option arguments [Boolean] :request_cache If +true+, the request cache is used for this request. + # Defaults to the index-level setting. + # @option arguments [Float] :requests_per_second The throttle for this request in sub-requests per second. Server default: -1. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [String] :q A query in the Lucene query string syntax. + # @option arguments [Time] :scroll The period to retain the search context for scrolling. + # @option arguments [Integer] :scroll_size The size of the scroll request that powers the operation. Server default: 1000. + # @option arguments [Time] :search_timeout The explicit timeout for each search request. + # It defaults to no timeout. + # @option arguments [String] :search_type The type of the search operation. + # Available options include +query_then_fetch+ and +dfs_query_then_fetch+. + # @option arguments [Integer, String] :slices The number of slices this task should be divided into. Server default: 1. + # @option arguments [Array] :sort A comma-separated list of +:+ pairs. + # @option arguments [Array] :stats The specific +tag+ of the request for logging and statistical purposes. + # @option arguments [Integer] :terminate_after The maximum number of documents to collect for each shard. + # If a query reaches this limit, Elasticsearch terminates the query early. + # Elasticsearch collects documents before sorting.Use with caution. + # Elasticsearch applies this parameter to each shard handling the request. + # When possible, let Elasticsearch perform early termination automatically. + # Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + # @option arguments [Time] :timeout The period each deletion request waits for active shards. Server default: 1m. + # @option arguments [Boolean] :version If +true+, returns the document version as part of a hit. + # @option arguments [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+). + # The +timeout+ value controls how long each write request waits for unavailable shards to become available. Server default: 1. + # @option arguments [Boolean] :wait_for_completion If +true+, the request blocks until the operation is complete. + # If +false+, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to cancel or get the status of the task. Elasticsearch creates a record of this task as a document at +.tasks/task/${taskId}+. When you are done with a task, you should delete the task document so Elasticsearch can reclaim the space. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-by-query # def delete_by_query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'delete_by_query' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_delete_by_query" + path = "#{Utils.listify(_index)}/_delete_by_query" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb index e7a43cdd19..b22377cca1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Changes the number of requests per second for a particular Delete By Query operation. + # Throttle a delete by query operation. + # Change the number of requests per second for a particular delete by query operation. + # Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts. # - # @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 [String, Integer] :task_id The ID for the task. (*Required*) + # @option arguments [Float] :requests_per_second The throttle for this request in sub-requests per second. + # To disable throttling, set it to +-1+. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-by-query-rethrottle # def delete_by_query_rethrottle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'delete_by_query_rethrottle' } + + defined_params = [:task_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone @@ -40,11 +50,11 @@ def delete_by_query_rethrottle(arguments = {}) _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST - path = "_delete_by_query/#{Utils.__listify(_task_id)}/_rethrottle" + path = "_delete_by_query/#{Utils.listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/delete_script.rb b/elasticsearch-api/lib/elasticsearch/api/actions/delete_script.rb index 0484619902..f224d397f3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/delete_script.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/delete_script.rb @@ -15,22 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Deletes a script. + # Delete a script or search template. + # Deletes a stored script or search template. # - # @option arguments [String] :id Script ID - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [String] :id The identifier for the stored script or search template. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-script # def delete_script(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'delete_script' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -41,11 +53,11 @@ def delete_script(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE - path = "_scripts/#{Utils.__listify(_id)}" + path = "_scripts/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/delete_policy.rb b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/delete_policy.rb index 8d2ea05fb5..cad74d11e4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/delete_policy.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/delete_policy.rb @@ -15,21 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Enrich module Actions + # Delete an enrich policy. # Deletes an existing enrich policy and its enrich index. # - # @option arguments [String] :name The name of the enrich policy + # @option arguments [String] :name Enrich policy to delete. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-enrich-policy-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-delete-policy # def delete_policy(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'enrich.delete_policy' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -40,11 +49,11 @@ def delete_policy(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_enrich/policy/#{Utils.__listify(_name)}" - params = {} + path = "_enrich/policy/#{Utils.listify(_name)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/execute_policy.rb b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/execute_policy.rb index b90e1f98b7..e37f8e2dc3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/execute_policy.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/execute_policy.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Enrich module Actions - # Creates the enrich index for an existing enrich policy. + # Run an enrich policy. + # Create the enrich index for an existing enrich policy. # - # @option arguments [String] :name The name of the enrich policy - # @option arguments [Boolean] :wait_for_completion Should the request should block until the execution is complete. + # @option arguments [String] :name Enrich policy to execute. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [Boolean] :wait_for_completion If +true+, the request blocks other enrich policy execution requests until complete. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/execute-enrich-policy-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-execute-policy # def execute_policy(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'enrich.execute_policy' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -41,11 +50,11 @@ def execute_policy(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_enrich/policy/#{Utils.__listify(_name)}/_execute" + path = "_enrich/policy/#{Utils.listify(_name)}/_execute" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/get_policy.rb b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/get_policy.rb index 273dda7de6..5e81c61c3b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/get_policy.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/get_policy.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Enrich module Actions - # Gets information about an enrich policy. + # Get an enrich policy. + # Returns information about an enrich policy. # - # @option arguments [List] :name A comma-separated list of enrich policy names + # @option arguments [String, Array] :name Comma-separated list of enrich policy names used to limit the request. + # To return information for all enrich policies, omit this parameter. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-enrich-policy-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-get-policy # def get_policy(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'enrich.get_policy' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -39,14 +49,14 @@ def get_policy(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_enrich/policy/#{Utils.__listify(_name)}" + "_enrich/policy/#{Utils.listify(_name)}" else - "_enrich/policy" + '_enrich/policy' end - params = {} + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/put_policy.rb b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/put_policy.rb index 3ced98f637..191d5d1990 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/put_policy.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/put_policy.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Enrich module Actions - # Creates a new enrich policy. + # Create an enrich policy. + # Creates an enrich policy. # - # @option arguments [String] :name The name of the enrich policy + # @option arguments [String] :name Name of the enrich policy to create or update. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The enrich policy to register (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-enrich-policy-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-put-policy # def put_policy(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'enrich.put_policy' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -42,11 +51,11 @@ def put_policy(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_enrich/policy/#{Utils.__listify(_name)}" - params = {} + path = "_enrich/policy/#{Utils.listify(_name)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/stats.rb index 22828fa7b4..357638b8c1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/enrich/stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/enrich/stats.rb @@ -15,31 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Enrich module Actions - # Gets enrich coordinator statistics and information about enrich policies that are currently executing. + # Get enrich stats. + # Returns enrich coordinator statistics and information about enrich policies that are currently executing. # + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-stats # def stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'enrich.stats' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_enrich/_stats" - params = {} + path = '_enrich/_stats' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/eql/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/eql/delete.rb index f793fcc5e9..64d344296b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/eql/delete.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/eql/delete.rb @@ -15,21 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Eql module Actions - # Deletes an async EQL search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. + # Delete an async EQL search. + # Delete an async EQL search or a stored synchronous EQL search. + # The API also deletes results for the search. # - # @option arguments [String] :id The async search ID + # @option arguments [String] :id Identifier for the search to delete. + # A search ID is provided in the EQL search API's response for an async search. + # A search ID is also provided if the request’s +keep_on_completion+ parameter is +true+. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-delete # def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'eql.delete' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +51,11 @@ def delete(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE - path = "_eql/search/#{Utils.__listify(_id)}" + path = "_eql/search/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/eql/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/eql/get.rb index a13ff1ec19..e80ef5cf1a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/eql/get.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/eql/get.rb @@ -15,23 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Eql module Actions - # Returns async results from previously executed Event Query Language (EQL) search + # Get async EQL search results. + # Get the current status and available results for an async EQL search or a stored synchronous EQL search. # - # @option arguments [String] :id The async search ID - # @option arguments [Time] :wait_for_completion_timeout Specify the time that the request should block waiting for the final response - # @option arguments [Time] :keep_alive Update the time interval in which the results (partial or final) for this search will be available + # @option arguments [String] :id Identifier for the search. (*Required*) + # @option arguments [Time] :keep_alive Period for which the search and its results are stored on the cluster. + # Defaults to the keep_alive value set by the search’s EQL search API request. + # @option arguments [Time] :wait_for_completion_timeout Timeout duration to wait for the request to finish. + # Defaults to no timeout, meaning the request waits for complete search results. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-get # def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'eql.get' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -42,11 +52,11 @@ def get(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET - path = "_eql/search/#{Utils.__listify(_id)}" + path = "_eql/search/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/eql/get_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/eql/get_status.rb index 14eff8b8a6..284943b157 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/eql/get_status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/eql/get_status.rb @@ -15,21 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Eql module Actions - # Returns the status of a previously submitted async or stored Event Query Language (EQL) search + # Get the async EQL status. + # Get the current status for an async EQL search or a stored synchronous EQL search without returning results. # - # @option arguments [String] :id The async search ID + # @option arguments [String] :id Identifier for the search. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-get-status # def get_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'eql.get_status' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +48,11 @@ def get_status(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET - path = "_eql/search/status/#{Utils.__listify(_id)}" + path = "_eql/search/status/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/eql/search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/eql/search.rb index c4c34384d8..17cb3967e7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/eql/search.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/eql/search.rb @@ -15,41 +15,56 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Eql module Actions - # Returns results matching a query expressed in Event Query Language (EQL) + # Get EQL search results. + # Returns search results for an Event Query Language (EQL) query. + # EQL assumes each document in a data stream or index corresponds to an event. # - # @option arguments [String] :index The name of the index to scope the operation - # @option arguments [Time] :wait_for_completion_timeout Specify the time that the request should block waiting for the final response - # @option arguments [Boolean] :keep_on_completion Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - # @option arguments [Time] :keep_alive Update the time interval in which the results (partial or final) for this search will be available + # @option arguments [String, Array] :index The name of the index to scope the operation (*Required*) + # @option arguments [Boolean] :allow_no_indices [TODO] Server default: true. + # @option arguments [Boolean] :allow_partial_search_results If true, returns partial results if there are shard failures. If false, returns an error with no partial results. Server default: true. + # @option arguments [Boolean] :allow_partial_sequence_results If true, sequence queries will return partial results in case of shard failures. If false, they will return no results at all. + # This flag has effect only if allow_partial_search_results is true. + # @option arguments [String, Array] :expand_wildcards [TODO] Server default: open. + # @option arguments [Boolean] :ignore_unavailable If true, missing or closed indices are not included in the response. Server default: true. + # @option arguments [Time] :keep_alive Period for which the search and its results are stored on the cluster. Server default: 5d. + # @option arguments [Boolean] :keep_on_completion If true, the search and its results are stored on the cluster. + # @option arguments [Time] :wait_for_completion_timeout Timeout duration to wait for the request to finish. Defaults to no timeout, meaning the request waits for complete search results. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Eql request body. Use the `query` to limit the query scope. (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-eql-search # def search(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'eql.search' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_eql/search" + path = "#{Utils.listify(_index)}/_eql/search" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query.rb new file mode 100644 index 0000000000..c6937e9b12 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query.rb @@ -0,0 +1,71 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Esql + module Actions + # Run an async ES|QL query. + # Asynchronously run an ES|QL (Elasticsearch query language) query, monitor its progress, and retrieve results when they become available. + # The API accepts the same parameters and request body as the synchronous query API, along with additional async related properties. + # + # @option arguments [Boolean] :allow_partial_results If +true+, partial results will be returned if there are shard failures, but the query can continue to execute on other clusters and shards. + # @option arguments [String] :delimiter The character to use between values within a CSV row. + # It is valid only for the CSV format. + # @option arguments [Boolean] :drop_null_columns Indicates whether columns that are entirely +null+ will be removed from the +columns+ and +values+ portion of the results. + # If +true+, the response will include an extra section under the name +all_columns+ which has the name of all the columns. + # @option arguments [String] :format A short version of the Accept header, for example +json+ or +yaml+. + # @option arguments [Time] :keep_alive The period for which the query and its results are stored in the cluster. + # The default period is five days. + # When this period expires, the query and its results are deleted, even if the query is still ongoing. + # If the +keep_on_completion+ parameter is false, Elasticsearch only stores async queries that do not complete within the period set by the +wait_for_completion_timeout+ parameter, regardless of this value. Server default: 5d. + # @option arguments [Boolean] :keep_on_completion Indicates whether the query and its results are stored in the cluster. + # If false, the query and its results are stored in the cluster only if the request does not complete during the period set by the +wait_for_completion_timeout+ parameter. + # @option arguments [Time] :wait_for_completion_timeout The period to wait for the request to finish. + # By default, the request waits for 1 second for the query results. + # If the query completes during this period, results are returned + # Otherwise, a query ID is returned that can later be used to retrieve the results. Server default: 1s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query + # + def async_query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.async_query' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_query/async' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_delete.rb new file mode 100644 index 0000000000..baaece9b87 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_delete.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Esql + module Actions + # Delete an async ES|QL query. + # If the query is still running, it is cancelled. + # Otherwise, the stored results are deleted. + # If the Elasticsearch security features are enabled, only the following users can use this API to delete a query: + # * The authenticated user that submitted the original query request + # * Users with the +cancel_task+ cluster privilege + # + # @option arguments [String] :id The unique identifier of the query. + # A query ID is provided in the ES|QL async query API response for a query that does not complete in the designated time. + # A query ID is also provided when the request was submitted with the +keep_on_completion+ parameter set to +true+. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-delete + # + def async_query_delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.async_query_delete' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_query/async/#{Utils.listify(_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_get.rb new file mode 100644 index 0000000000..481f3d093f --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_get.rb @@ -0,0 +1,72 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Esql + module Actions + # Get async ES|QL query results. + # Get the current status and available results or stored results for an ES|QL asynchronous query. + # If the Elasticsearch security features are enabled, only the user who first submitted the ES|QL query can retrieve the results using this API. + # + # @option arguments [String] :id The unique identifier of the query. + # A query ID is provided in the ES|QL async query API response for a query that does not complete in the designated time. + # A query ID is also provided when the request was submitted with the +keep_on_completion+ parameter set to +true+. (*Required*) + # @option arguments [Boolean] :drop_null_columns Indicates whether columns that are entirely +null+ will be removed from the +columns+ and +values+ portion of the results. + # If +true+, the response will include an extra section under the name +all_columns+ which has the name of all the columns. + # @option arguments [Time] :keep_alive The period for which the query and its results are stored in the cluster. + # When this period expires, the query and its results are deleted, even if the query is still ongoing. + # @option arguments [Time] :wait_for_completion_timeout The period to wait for the request to finish. + # By default, the request waits for complete query results. + # If the request completes during the period specified in this parameter, complete query results are returned. + # Otherwise, the response returns an +is_running+ value of +true+ and no results. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-get + # + def async_query_get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.async_query_get' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_GET + path = "_query/async/#{Utils.listify(_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_stop.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_stop.rb new file mode 100644 index 0000000000..56ad48971c --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query_stop.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Esql + module Actions + # Stop async ES|QL query. + # This API interrupts the query execution and returns the results so far. + # If the Elasticsearch security features are enabled, only the user who first submitted the ES|QL query can stop it. + # + # @option arguments [String] :id The unique identifier of the query. + # A query ID is provided in the ES|QL async query API response for a query that does not complete in the designated time. + # A query ID is also provided when the request was submitted with the +keep_on_completion+ parameter set to +true+. (*Required*) + # @option arguments [Boolean] :drop_null_columns Indicates whether columns that are entirely +null+ will be removed from the +columns+ and +values+ portion of the results. + # If +true+, the response will include an extra section under the name +all_columns+ which has the name of all the columns. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-stop + # + def async_query_stop(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.async_query_stop' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_POST + path = "_query/async/#{Utils.listify(_id)}/stop" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/get_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/get_query.rb new file mode 100644 index 0000000000..46b4e08792 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/get_query.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Esql + module Actions + # Get a specific running ES|QL query information. + # Returns an object extended information about a running ES|QL query. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :id The query ID (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see [TODO] + # + def get_query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.get_query' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_GET + path = "_query/queries/#{Utils.listify(_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/list_queries.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/list_queries.rb new file mode 100644 index 0000000000..22b804c0ec --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/list_queries.rb @@ -0,0 +1,55 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Esql + module Actions + # Get running ES|QL queries information. + # Returns an object containing IDs and other information about the running ES|QL queries. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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 + # + # @see [TODO] + # + def list_queries(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.list_queries' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_query/queries' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/query.rb new file mode 100644 index 0000000000..8bf8241cd7 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/query.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Esql + module Actions + # Run an ES|QL query. + # Get search results for an ES|QL (Elasticsearch query language) query. + # This functionality is subject to potential breaking changes within a + # minor version, meaning that your referencing code may break when this + # library is upgraded. + # + # @option arguments [String] :format A short version of the Accept header, e.g. json, yaml. + # @option arguments [String] :delimiter The character to use between values within a CSV row. Only valid for the CSV format. + # @option arguments [Boolean] :drop_null_columns Should columns that are entirely +null+ be removed from the +columns+ and +values+ portion of the results? + # Defaults to +false+. If +true+ then the response will include an extra section under the name +all_columns+ which has the name of all columns. + # @option arguments [Boolean] :allow_partial_results If +true+, partial results will be returned if there are shard failures, but the query can continue to execute on other clusters and shards. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/explore-analyze/query-filter/languages/esql-rest + # + def query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.query' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_query' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/exists.rb b/elasticsearch-api/lib/elasticsearch/api/actions/exists.rb index 8978685183..c1172382ee 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/exists.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/exists.rb @@ -15,31 +15,64 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns information about whether a document exists in an index. + # Check a document. + # Verify that a document exists. + # For example, check to see if a document with the +_id+ 0 exists: + # + + # HEAD my-index-000001/_doc/0 + # + + # If the document exists, the API returns a status code of +200 - OK+. + # If the document doesn’t exist, the API returns +404 - Not Found+. + # **Versioning support** + # You can use the +version+ parameter to check the document only if its current version is equal to the specified one. + # Internally, Elasticsearch has marked the old document as deleted and added an entirely new document. + # The old version of the document doesn't disappear immediately, although you won't be able to access it. + # Elasticsearch cleans up deleted documents in the background as you continue to index more data. # - # @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) + # @option arguments [String] :id A unique document identifier. (*Required*) + # @option arguments [String] :index A comma-separated list of data streams, indices, and aliases. + # It supports wildcards (+*+). (*Required*) + # @option arguments [String] :preference The node or shard the operation should be performed on. + # By default, the operation is randomized between the shard replicas.If it is set to +_local+, the operation will prefer to be run on a local allocated shard when possible. + # If it is set to a custom value, the value is used to guarantee that the same shards will be used for the same custom value. + # This can help with "jumping values" when hitting different shards in different refresh states. + # A sample value can be something like the web session ID or the user name. + # @option arguments [Boolean] :realtime If +true+, the request is real-time as opposed to near-real-time. Server default: true. + # @option arguments [Boolean] :refresh If +true+, the request refreshes the relevant shards before retrieving the document. + # Setting it to +true+ should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing). + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Boolean, String, Array] :_source Indicates whether to return the +_source+ field (+true+ or +false+) or lists the fields to return. + # @option arguments [String, Array] :_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 arguments [String, Array] :_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 arguments [String, Array] :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+. + # @option arguments [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 arguments [String] :version_type The version type. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get # def exists(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'exists' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -53,15 +86,15 @@ def exists(arguments = {}) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_HEAD - path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" + path = "#{Utils.listify(_index)}/_doc/#{Utils.listify(_id)}" params = Utils.process_params(arguments) - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 ? true : false + Utils.rescue_from_not_found do + perform_request(method, path, params, body, headers, request_opts).status == 200 end end - alias_method :exists?, :exists + alias exists? exists end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/exists_source.rb b/elasticsearch-api/lib/elasticsearch/api/actions/exists_source.rb index bfd168146b..f7932922e5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/exists_source.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/exists_source.rb @@ -15,30 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns information about whether a document source exists in an index. + # Check for a document source. + # Check whether a document source exists in an index. + # For example: + # + + # HEAD my-index-000001/_source/1 + # + + # A document's source is not available if it is disabled in the mapping. # - # @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) + # @option arguments [String] :id A unique identifier for the document. (*Required*) + # @option arguments [String] :index A comma-separated list of data streams, indices, and aliases. + # It supports wildcards (+*+). (*Required*) + # @option arguments [String] :preference The node or shard the operation should be performed on. + # By default, the operation is randomized between the shard replicas. + # @option arguments [Boolean] :realtime If +true+, the request is real-time as opposed to near-real-time. Server default: true. + # @option arguments [Boolean] :refresh If +true+, the request refreshes the relevant shards before retrieving the document. + # Setting it to +true+ should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing). + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Boolean, String, Array] :_source Indicates whether to return the +_source+ field (+true+ or +false+) or lists the fields to return. + # @option arguments [String, Array] :_source_excludes A comma-separated list of source fields to exclude in the response. + # @option arguments [String, Array] :_source_includes A comma-separated list of source fields to include in the response. + # @option arguments [Integer] :version The version number for concurrency control. + # It must match the current version of the document for the request to succeed. + # @option arguments [String] :version_type The version type. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get # def exists_source(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'exists_source' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -52,15 +69,15 @@ def exists_source(arguments = {}) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_HEAD - path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}" + path = "#{Utils.listify(_index)}/_source/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end - alias_method :exists_source?, :exists_source + alias exists_source? exists_source end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb b/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb index 6509cad3ce..735bc41728 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/explain.rb @@ -15,34 +15,55 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns information about why a specific matches (or doesn't match) a query. + # Explain a document match result. + # Get information about why a specific document matches, or doesn't match, a query. + # It computes a score explanation for a query and a specific document. # - # @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 [String] :id The document identifier. (*Required*) + # @option arguments [String] :index Index names that are used to limit the request. + # Only a single index name can be provided to this parameter. (*Required*) + # @option arguments [String] :analyzer The analyzer to use for the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [Boolean] :analyze_wildcard If +true+, wildcard and prefix queries are analyzed. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [String] :default_operator The default operator for query string query: +AND+ or +OR+. + # This parameter can be used only when the +q+ query string parameter is specified. Server default: OR. + # @option arguments [String] :df The field to use as default where no field prefix is given in the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [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 be used only when the +q+ query string parameter is specified. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # It is random by default. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Boolean, String, Array] :_source +True+ or +false+ to return the +_source+ field or not or a list of fields to return. + # @option arguments [String, Array] :_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 arguments [String, Array] :_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 arguments [String, Array] :stored_fields A comma-separated list of stored fields to return in the response. + # @option arguments [String] :q The query in the Lucene query string syntax. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The query definition using the Query DSL + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-explain # def explain(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'explain' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -61,11 +82,11 @@ def explain(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}" + path = "#{Utils.listify(_index)}/_explain/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/features/get_features.rb b/elasticsearch-api/lib/elasticsearch/api/actions/features/get_features.rb index 661c93ef45..75eb2a5bb1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/features/get_features.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/features/get_features.rb @@ -15,32 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch 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 + # Get the features. + # Get a list of features that can be included in snapshots using the +feature_states+ field when creating a snapshot. + # You can use this API to determine which feature states to include when taking a snapshot. + # By default, all feature states are included in a snapshot if that snapshot includes the global state, or none if it does not. + # A feature state includes one or more system indices necessary for a given feature to function. + # In order to ensure data integrity, all system indices that comprise a feature state are snapshotted and restored together. + # The features listed by this API are a combination of built-in features and features defined by plugins. + # In order for a feature state to be listed in this API and recognized as a valid feature state by the create snapshot API, the plugin that defines that feature must be installed on the master node. # - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-features-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-features-get-features # def get_features(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'features.get_features' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_features" + path = '_features' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/features/reset_features.rb b/elasticsearch-api/lib/elasticsearch/api/actions/features/reset_features.rb index 922eb32bf2..8679c4b159 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/features/reset_features.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/features/reset_features.rb @@ -15,35 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Features module Actions - # Resets the internal state of features, usually by deleting system indices + # Reset the features. + # Clear all of the state information stored in system indices by Elasticsearch features, including the security and machine learning indices. + # WARNING: Intended for development and testing use only. Do not reset features on a production cluster. + # Return a cluster to the same state as a new installation by resetting the feature state for all Elasticsearch features. + # This deletes all state information stored in system indices. + # The response code is HTTP 200 if the state is successfully reset for all features. + # It is HTTP 500 if the reset operation failed for any feature. + # Note that select features might provide a way to reset particular system indices. + # Using this API resets all features, both those that are built-in and implemented as plugins. + # To list the features that will be affected, use the get features API. + # IMPORTANT: The features installed on the node you submit this request to are the features that will be reset. Run on the master node if you have any doubts about which plugins are installed on individual nodes. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-features-reset-features # def reset_features(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'features.reset_features' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_features/_reset" - params = {} + path = '_features/_reset' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/field_caps.rb b/elasticsearch-api/lib/elasticsearch/api/actions/field_caps.rb index 7ecb73e4bd..2f0de68202 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/field_caps.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/field_caps.rb @@ -15,32 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns the information about the capabilities of fields among multiple indices. + # Get the field capabilities. + # Get information about the capabilities of fields among multiple indices. + # For data streams, the API returns field capabilities among the stream’s backing indices. + # It returns runtime fields like any other field. + # For example, a runtime field with a type of keyword is returned the same as any other field that belongs to the +keyword+ family. # - # @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 [List] :filters An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent - # @option arguments [List] :types Only return results for fields that have one of the types in the list + # @option arguments [String, Array] :index A comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all. + # @option arguments [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 indices. This behavior applies even if the request targets other open indices. For example, a request + # targeting +foo*,bar*+ returns an error if an index starts with foo but no index starts with bar. Server default: true. + # @option arguments [String, Array] :expand_wildcards The 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+. Server default: open. + # @option arguments [String, Array] :fields A comma-separated list of fields to retrieve capabilities for. Wildcard (+*+) expressions are supported. + # @option arguments [Boolean] :ignore_unavailable If +true+, missing or closed indices are not included in the response. + # @option arguments [Boolean] :include_unmapped If true, unmapped fields are included in the response. + # @option arguments [String] :filters A comma-separated list of filters to apply to the response. + # @option arguments [Array] :types A comma-separated list of field types to include. + # Any fields that do not match one of these types will be excluded from the results. + # It defaults to empty, meaning that all field types are returned. + # @option arguments [Boolean] :include_empty_fields If false, empty fields are not included in the response. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body An index filter specified with the Query DSL + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-field-caps # def field_caps(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'field_caps' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -51,14 +67,14 @@ def field_caps(arguments = {}) end path = if _index - "#{Utils.__listify(_index)}/_field_caps" + "#{Utils.listify(_index)}/_field_caps" else - "_field_caps" + '_field_caps' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/global_checkpoints.rb b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/global_checkpoints.rb index 8130b9721c..1163f0d4e5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/global_checkpoints.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/global_checkpoints.rb @@ -15,40 +15,53 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Fleet module Actions - # Returns the current global checkpoints for an index. This API is design for internal use by the fleet server project. + # Get global checkpoints. + # Get the current global checkpoints for an index. + # This API is designed for internal use by the Fleet server project. # - # @option arguments [String] :index The name of the index. - # @option arguments [Boolean] :wait_for_advance Whether to wait for the global checkpoint to advance past the specified current checkpoints - # @option arguments [Boolean] :wait_for_index Whether to wait for the target index to exist and all primary shards be active - # @option arguments [List] :checkpoints Comma separated list of checkpoints - # @option arguments [Time] :timeout Timeout to wait for global checkpoint to advance + # @option arguments [Indexname, Indexalias] :index A single index or index alias that resolves to a single index. (*Required*) + # @option arguments [Boolean] :wait_for_advance A boolean value which controls whether to wait (until the timeout) for the global checkpoints + # to advance past the provided +checkpoints+. + # @option arguments [Boolean] :wait_for_index A boolean value which controls whether to wait (until the timeout) for the target index to exist + # and all primary shards be active. Can only be true when +wait_for_advance+ is true. + # @option arguments [Array] :checkpoints A comma separated list of previous global checkpoints. When used in combination with +wait_for_advance+, + # the API will only return once the global checkpoints advances past the checkpoints. Providing an empty list + # will cause Elasticsearch to immediately return the current global checkpoints. Server default: []. + # @option arguments [Time] :timeout Period to wait for a global checkpoints to advance past +checkpoints+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-global-checkpoints.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-fleet # def global_checkpoints(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'fleet.global_checkpoints' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_fleet/global_checkpoints" + path = "#{Utils.listify(_index)}/_fleet/global_checkpoints" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/msearch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/msearch.rb index 86fd9ac0ca..4d75a5549f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/msearch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/msearch.rb @@ -15,68 +15,93 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Fleet module Actions - # Multi Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project. + # Run multiple Fleet searches. + # Run several Fleet searches with a single API request. + # The API follows the same structure as the multi search API. + # However, similar to the Fleet search API, it supports the +wait_for_checkpoints+ parameter. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 The index name to use as the default + # @option arguments [Indexname, Indexalias] :index A single target to search. If the target is an index alias, it must resolve to a single index. + # @option arguments [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 indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. + # @option arguments [Boolean] :ccs_minimize_roundtrips If true, network roundtrips between the coordinating node and remote clusters are minimized for cross-cluster search requests. Server default: true. + # @option arguments [String, Array] :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. + # @option arguments [Boolean] :ignore_throttled If true, concrete, expanded or aliased indices are ignored when frozen. + # @option arguments [Boolean] :ignore_unavailable If true, missing or closed indices are not included in the response. + # @option arguments [Integer] :max_concurrent_searches Maximum number of concurrent searches the multi search API can execute. + # @option arguments [Integer] :max_concurrent_shard_requests Maximum number of concurrent shard requests that each sub-search request executes per node. Server default: 5. + # @option arguments [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 arguments [String] :search_type Indicates whether global term and document frequencies should be used when scoring returned documents. + # @option arguments [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 arguments [Boolean] :typed_keys Specifies whether aggregation and suggester names should be prefixed by their respective types in the response. + # @option arguments [Array] :wait_for_checkpoints A comma separated list of checkpoints. When configured, the search API will only be executed on a shard + # after the relevant checkpoint has become visible for search. Defaults to an empty list which will cause + # Elasticsearch to immediately execute the search. Server default: []. + # @option arguments [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. + # Defaults to the configured cluster setting +search.default_allow_partial_results+, which is true by default. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request definitions (metadata-fleet search request definition pairs), separated by newlines (*Required*) + # @option arguments [Hash] :body searches # - # @see [TODO] + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-fleet-msearch # def msearch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'fleet.msearch' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_fleet/_fleet_msearch" + "#{Utils.listify(_index)}/_fleet/_fleet_msearch" else - "_fleet/_fleet_msearch" + '_fleet/_fleet_msearch' end - params = {} + params = Utils.process_params(arguments) - case - when body.is_a?(Array) && body.any? { |d| d.has_key? :search } - payload = body - .inject([]) do |sum, item| - meta = item - data = meta.delete(:search) + 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 - sum - end - .map { |item| Elasticsearch::API.serializer.dump(item) } - payload << "" unless payload.empty? + sum << meta + sum << data + end.map { |item| Elasticsearch::API.serializer.dump(item) } + payload << '' unless payload.empty? payload = payload.join("\n") - when body.is_a?(Array) + elsif body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) } - payload << "" unless payload.empty? + payload << '' unless payload.empty? payload = payload.join("\n") else payload = body end - headers.merge!("Content-Type" => "application/x-ndjson") + headers.merge!({ + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + }) Elasticsearch::API::Response.new( - perform_request(method, path, params, payload, headers) + perform_request(method, path, params, payload, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/search.rb index 4f260bc66b..a2189664a0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/search.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/search.rb @@ -15,35 +15,88 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Fleet module Actions - # Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project. + # Run a Fleet search. + # The purpose of the Fleet search API is to provide an API where the search will be run only + # after the provided checkpoint has been processed and is visible for searches inside of Elasticsearch. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 The index name to search. - # @option arguments [List] :wait_for_checkpoints Comma separated list of checkpoints, one per shard - # @option arguments [Time] :wait_for_checkpoints_timeout Explicit wait_for_checkpoints timeout - # @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 [Indexname, Indexalias] :index A single target to search. If the target is an index alias, it must resolve to a single index. (*Required*) + # @option arguments [Boolean] :allow_no_indices [TODO] + # @option arguments [String] :analyzer [TODO] + # @option arguments [Boolean] :analyze_wildcard [TODO] + # @option arguments [Integer] :batched_reduce_size [TODO] + # @option arguments [Boolean] :ccs_minimize_roundtrips [TODO] + # @option arguments [String] :default_operator [TODO] + # @option arguments [String] :df [TODO] + # @option arguments [String, Array] :docvalue_fields [TODO] + # @option arguments [String, Array] :expand_wildcards [TODO] + # @option arguments [Boolean] :explain [TODO] + # @option arguments [Boolean] :ignore_throttled [TODO] + # @option arguments [Boolean] :ignore_unavailable [TODO] + # @option arguments [Boolean] :lenient [TODO] + # @option arguments [Integer] :max_concurrent_shard_requests [TODO] + # @option arguments [String] :preference [TODO] + # @option arguments [Integer] :pre_filter_shard_size [TODO] + # @option arguments [Boolean] :request_cache [TODO] + # @option arguments [String] :routing [TODO] + # @option arguments [Time] :scroll [TODO] + # @option arguments [String] :search_type [TODO] + # @option arguments [Array] :stats [TODO] + # @option arguments [String, Array] :stored_fields [TODO] + # @option arguments [String] :suggest_field Specifies which field to use for suggestions. + # @option arguments [String] :suggest_mode [TODO] + # @option arguments [Integer] :suggest_size [TODO] + # @option arguments [String] :suggest_text The source text for which the suggestions should be returned. + # @option arguments [Integer] :terminate_after [TODO] + # @option arguments [Time] :timeout [TODO] + # @option arguments [Boolean, Integer] :track_total_hits [TODO] + # @option arguments [Boolean] :track_scores [TODO] + # @option arguments [Boolean] :typed_keys [TODO] + # @option arguments [Boolean] :rest_total_hits_as_int [TODO] + # @option arguments [Boolean] :version [TODO] + # @option arguments [Boolean, String, Array] :_source [TODO] + # @option arguments [String, Array] :_source_excludes [TODO] + # @option arguments [String, Array] :_source_includes [TODO] + # @option arguments [Boolean] :seq_no_primary_term [TODO] + # @option arguments [String] :q [TODO] + # @option arguments [Integer] :size [TODO] + # @option arguments [Integer] :from [TODO] + # @option arguments [String] :sort [TODO] + # @option arguments [Array] :wait_for_checkpoints A comma separated list of checkpoints. When configured, the search API will only be executed on a shard + # after the relevant checkpoint has become visible for search. Defaults to an empty list which will cause + # Elasticsearch to immediately execute the search. Server default: []. + # @option arguments [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. + # Defaults to the configured cluster setting +search.default_allow_partial_results+, which is true by default. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL + # @option arguments [Hash] :body request body # - # @see [TODO] + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-fleet-search # def search(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'fleet.search' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -53,11 +106,11 @@ def search(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "#{Utils.__listify(_index)}/_fleet/_fleet_search" + path = "#{Utils.listify(_index)}/_fleet/_fleet_search" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/get.rb index fcf8c65e21..22e6b397eb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/get.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/get.rb @@ -15,32 +15,95 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns a document. + # Get a document by its ID. + # Get a document and its source or stored fields from an index. + # By default, this API is realtime and is not affected by the refresh rate of the index (when data will become visible for search). + # In the case where stored fields are requested with the +stored_fields+ parameter and the document has been updated but is not yet refreshed, the API will have to parse and analyze the source to extract the stored fields. + # To turn off realtime behavior, set the +realtime+ parameter to false. + # **Source filtering** + # By default, the API returns the contents of the +_source+ field unless you have used the +stored_fields+ parameter or the +_source+ field is turned off. + # You can turn off +_source+ retrieval by using the +_source+ parameter: + # + + # GET my-index-000001/_doc/0?_source=false + # + + # If you only need one or two fields from the +_source+, use the +_source_includes+ or +_source_excludes+ parameters to include or filter out particular fields. + # This can be helpful with large documents where partial retrieval can save on network overhead + # Both parameters take a comma separated list of fields or wildcard expressions. + # For example: + # + + # GET my-index-000001/_doc/0?_source_includes=*.id&_source_excludes=entities + # + + # If you only want to specify includes, you can use a shorter notation: + # + + # GET my-index-000001/_doc/0?_source=*.id + # + + # **Routing** + # If routing is used during indexing, the routing value also needs to be specified to retrieve a document. + # For example: + # + + # GET my-index-000001/_doc/2?routing=user1 + # + + # This request gets the document with ID 2, but it is routed based on the user. + # The document is not fetched if the correct routing is not specified. + # **Distributed** + # The GET operation is hashed into a specific shard ID. + # It is then redirected to one of the replicas within that shard ID and returns the result. + # The replicas are the primary shard and its replicas within that shard ID group. + # This means that the more replicas you have, the better your GET scaling will be. + # **Versioning support** + # You can use the +version+ parameter to retrieve the document only if its current version is equal to the specified one. + # Internally, Elasticsearch has marked the old document as deleted and added an entirely new document. + # The old version of the document doesn't disappear immediately, although you won't be able to access it. + # Elasticsearch cleans up deleted documents in the background as you continue to index more data. # - # @option arguments [String] :id The document ID - # @option arguments [String] :index The name of the index - # @option arguments [Boolean] :force_synthetic_source Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in 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) + # @option arguments [String] :id A unique document identifier. (*Required*) + # @option arguments [String] :index The name of the index that contains the document. (*Required*) + # @option arguments [Boolean] :force_synthetic_source Indicates whether the request forces synthetic +_source+. + # Use this paramater to test if the mapping supports synthetic +_source+ and to get a sense of the worst case performance. + # Fetches with this parameter enabled will be slower than enabling synthetic source natively in the index. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # By default, the operation is randomized between the shard replicas.If it is set to +_local+, the operation will prefer to be run on a local allocated shard when possible. + # If it is set to a custom value, the value is used to guarantee that the same shards will be used for the same custom value. + # This can help with "jumping values" when hitting different shards in different refresh states. + # A sample value can be something like the web session ID or the user name. + # @option arguments [Boolean] :realtime If +true+, the request is real-time as opposed to near-real-time. Server default: true. + # @option arguments [Boolean] :refresh If +true+, the request refreshes the relevant shards before retrieving the document. + # Setting it to +true+ should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing). + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Boolean, String, Array] :_source Indicates whether to return the +_source+ field (+true+ or +false+) or lists the fields to return. + # @option arguments [String, Array] :_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 arguments [String, Array] :_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 arguments [String, Array] :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+. + # Only leaf fields can be retrieved with the +stored_field+ option. + # Object fields can't be returned;​if specified, the request fails. + # @option arguments [Integer] :version The version number for concurrency control. + # It must match the current version of the document for the request to succeed. + # @option arguments [String] :version_type The version type. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get # def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'get' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -54,18 +117,18 @@ def get(arguments = {}) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" + path = "#{Utils.listify(_index)}/_doc/#{Utils.listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/get_script.rb b/elasticsearch-api/lib/elasticsearch/api/actions/get_script.rb index 871d9b0972..d2109ac11e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/get_script.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/get_script.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns a script. + # Get a script or search template. + # Retrieves a stored script or search template. # - # @option arguments [String] :id Script ID - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [String] :id The identifier for the stored script or search template. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: . # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get-script # def get_script(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'get_script' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +50,11 @@ def get_script(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET - path = "_scripts/#{Utils.__listify(_id)}" + path = "_scripts/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/get_script_context.rb b/elasticsearch-api/lib/elasticsearch/api/actions/get_script_context.rb index b76598d65e..e3e0b582b2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/get_script_context.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/get_script_context.rb @@ -15,30 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns all script contexts. + # Get script contexts. + # Get a list of supported script contexts and their methods. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-contexts.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get-script-context # def get_script_context(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'get_script_context' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_script_context" + path = '_script_context' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/get_script_languages.rb b/elasticsearch-api/lib/elasticsearch/api/actions/get_script_languages.rb index 0a835aff70..e2462b2ff6 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/get_script_languages.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/get_script_languages.rb @@ -15,30 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns available script types, languages and contexts + # Get script languages. + # Get a list of available script types, languages, and contexts. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get-script-languages # def get_script_languages(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'get_script_languages' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_script_language" + path = '_script_language' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/get_source.rb b/elasticsearch-api/lib/elasticsearch/api/actions/get_source.rb index c2f645ca3f..086754c9df 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/get_source.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/get_source.rb @@ -15,30 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns the source of a document. + # Get a document's source. + # Get the source of a document. + # For example: + # + + # GET my-index-000001/_source/1 + # + + # You can use the source filtering parameters to control which parts of the +_source+ are returned: + # + + # GET my-index-000001/_source/1/?_source_includes=*.id&_source_excludes=entities + # + # - # @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) + # @option arguments [String] :id A unique document identifier. (*Required*) + # @option arguments [String] :index The name of the index that contains the document. (*Required*) + # @option arguments [String] :preference The node or shard the operation should be performed on. + # By default, the operation is randomized between the shard replicas. + # @option arguments [Boolean] :realtime If +true+, the request is real-time as opposed to near-real-time. Server default: true. + # @option arguments [Boolean] :refresh If +true+, the request refreshes the relevant shards before retrieving the document. + # Setting it to +true+ should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing). + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Boolean, String, Array] :_source Indicates whether to return the +_source+ field (+true+ or +false+) or lists the fields to return. + # @option arguments [String, Array] :_source_excludes A comma-separated list of source fields to exclude in the response. + # @option arguments [String, Array] :_source_includes A comma-separated list of source fields to include in the response. + # @option arguments [String, Array] :stored_fields A comma-separated list of stored fields to return as part of a hit. + # @option arguments [Integer] :version The version number for concurrency control. + # It must match the current version of the document for the request to succeed. + # @option arguments [String] :version_type The version type. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get # def get_source(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'get_source' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -52,11 +72,11 @@ def get_source(arguments = {}) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}" + path = "#{Utils.listify(_index)}/_source/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/graph/explore.rb b/elasticsearch-api/lib/elasticsearch/api/actions/graph/explore.rb index f9c8187e39..4edfda5d6f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/graph/explore.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/graph/explore.rb @@ -15,30 +15,44 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Graph module Actions - # Explore extracted and summarized information about the documents and terms in an index. + # Explore graph analytics. + # Extract and summarize information about the documents and terms in an Elasticsearch data stream or index. + # The easiest way to understand the behavior of this API is to use the Graph UI to explore connections. + # An initial request to the +_explore+ API contains a seed query that identifies the documents of interest and specifies the fields that define the vertices and connections you want to include in the graph. + # Subsequent requests enable you to spider out from one more vertices of interest. + # You can exclude vertices that have already been returned. # - # @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] :routing Specific routing value - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [String, Array] :index Name of the index. (*Required*) + # @option arguments [String] :routing Custom value used to route operations to a specific shard. + # @option arguments [Time] :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. + # Defaults to no timeout. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Graph Query DSL + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-graph # def explore(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'graph.explore' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -48,11 +62,11 @@ def explore(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "#{Utils.__listify(_index)}/_graph/explore" + path = "#{Utils.listify(_index)}/_graph/explore" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/health_report.rb b/elasticsearch-api/lib/elasticsearch/api/actions/health_report.rb index 48293f7b6d..a91afc21ea 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/health_report.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/health_report.rb @@ -15,23 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns the health of the cluster. + # Get the cluster health. + # Get a report with the health status of an Elasticsearch cluster. + # The report contains a list of indicators that compose Elasticsearch functionality. + # Each indicator has a health status of: green, unknown, yellow or red. + # The indicator will provide an explanation and metadata describing the reason for its current health status. + # The cluster’s status is controlled by the worst indicator status. + # In the event that an indicator’s status is non-green, a list of impacts may be present in the indicator result which detail the functionalities that are negatively affected by the health issue. + # Each impact carries with it a severity level, an area of the system that is affected, and a simple description of the impact on the system. + # Some health indicators can determine the root cause of a health problem and prescribe a set of steps that can be performed in order to improve the health of the system. + # The root cause and remediation steps are encapsulated in a diagnosis. + # A diagnosis contains a cause detailing a root cause analysis, an action containing a brief description of the steps to take to fix the problem, the list of affected resources (if applicable), and a detailed step-by-step troubleshooting guide to fix the diagnosed problem. + # NOTE: The health indicators perform root cause analysis of non-green health statuses. This can be computationally expensive when called frequently. + # When setting up automated polling of the API for health status, set verbose to false to disable the more expensive analysis logic. # - # @option arguments [String] :feature A feature of the cluster, as returned by the top-level health API - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :verbose Opt in for more information about the health of the system - # @option arguments [Integer] :size Limit the number of affected resources the health API returns + # @option arguments [String] :feature A feature of the cluster, as returned by the top-level health report API. + # @option arguments [Time] :timeout Explicit operation timeout. + # @option arguments [Boolean] :verbose Opt-in for more information about the health of the system. Server default: true. + # @option arguments [Integer] :size Limit the number of affected resources the health report API returns. Server default: 1000. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/health-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-health-report # def health_report(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'health_report' } + + defined_params = [:feature].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +60,14 @@ def health_report(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _feature - "_health_report/#{Utils.__listify(_feature)}" + "_health_report/#{Utils.listify(_feature)}" else - "_health_report" + '_health_report' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index.rb index f4a90f1416..3d19167f59 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index.rb @@ -15,33 +15,142 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Creates or updates a document in an index. + # Create or update a document in an index. + # Add a JSON document to the specified data stream or index and make it searchable. + # If the target is an index and the document already exists, the request updates the document and increments its version. + # NOTE: You cannot use this API to send update requests for existing documents in a data stream. + # If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias: + # * To add or overwrite a document using the +PUT //_doc/<_id>+ request format, you must have the +create+, +index+, or +write+ index privilege. + # * To add a document using the +POST //_doc/+ request format, you must have the +create_doc+, +create+, +index+, or +write+ index privilege. + # * To automatically create a data stream or index with this API request, you must have the +auto_configure+, +create_index+, or +manage+ index privilege. + # Automatic data stream creation requires a matching index template with data stream enabled. + # NOTE: Replica shards might not all be started when an indexing operation returns successfully. + # By default, only the primary is required. Set +wait_for_active_shards+ to change this default behavior. + # **Automatically create data streams and indices** + # If the request's target doesn't exist and matches an index template with a +data_stream+ definition, the index operation automatically creates the data stream. + # If the target doesn't exist and doesn't match a data stream template, the operation automatically creates the index and applies any matching index templates. + # NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation. + # If no mapping exists, the index operation creates a dynamic mapping. + # By default, new fields and objects are automatically added to the mapping if needed. + # Automatic index creation is controlled by the +action.auto_create_index+ setting. + # If it is +true+, any index can be created automatically. + # You can modify this setting to explicitly allow or block automatic creation of indices that match specified patterns or set it to +false+ to turn off automatic index creation entirely. + # Specify a comma-separated list of patterns you want to allow or prefix each pattern with +++ or +-+ to indicate whether it should be allowed or blocked. + # When a list is specified, the default behaviour is to disallow. + # NOTE: The +action.auto_create_index+ setting affects the automatic creation of indices only. + # It does not affect the creation of data streams. + # **Optimistic concurrency control** + # Index operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the +if_seq_no+ and +if_primary_term+ parameters. + # If a mismatch is detected, the operation will result in a +VersionConflictException+ and a status code of +409+. + # **Routing** + # By default, shard placement — or routing — is controlled by using a hash of the document's ID value. + # For more explicit control, the value fed into the hash function used by the router can be directly specified on a per-operation basis using the +routing+ parameter. + # When setting up explicit mapping, you can also use the +_routing+ field to direct the index operation to extract the routing value from the document itself. + # This does come at the (very minimal) cost of an additional document parsing pass. + # If the +_routing+ mapping is defined and set to be required, the index operation will fail if no routing value is provided or extracted. + # NOTE: Data streams do not support custom routing unless they were created with the +allow_custom_routing+ setting enabled in the template. + # **Distributed** + # The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard. + # After the primary shard completes the operation, if needed, the update is distributed to applicable replicas. + # **Active shards** + # To improve the resiliency of writes to the system, indexing operations can be configured to wait for a certain number of active shard copies before proceeding with the operation. + # If the requisite number of active shard copies are not available, then the write operation must wait and retry, until either the requisite shard copies have started or a timeout occurs. + # By default, write operations only wait for the primary shards to be active before proceeding (that is to say +wait_for_active_shards+ is +1+). + # This default can be overridden in the index settings dynamically by setting +index.write.wait_for_active_shards+. + # To alter this behavior per operation, use the +wait_for_active_shards request+ parameter. + # Valid values are all or any positive integer up to the total number of configured copies per shard in the index (which is +number_of_replicas++1). + # Specifying a negative value or a number greater than the number of shard copies will throw an error. + # For example, suppose you have a cluster of three nodes, A, B, and C and you create an index index with the number of replicas set to 3 (resulting in 4 shard copies, one more copy than there are nodes). + # If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding. + # This means that even if B and C went down and A hosted the primary shard copies, the indexing operation would still proceed with only one copy of the data. + # If +wait_for_active_shards+ is set on the request to +3+ (and all three nodes are up), the indexing operation will require 3 active shard copies before proceeding. + # This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard. + # However, if you set +wait_for_active_shards+ to +all+ (or to +4+, which is the same in this situation), the indexing operation will not proceed as you do not have all 4 copies of each shard active in the index. + # The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard. + # It is important to note that this setting greatly reduces the chances of the write operation not writing to the requisite number of shard copies, but it does not completely eliminate the possibility, because this check occurs before the write operation starts. + # After the write operation is underway, it is still possible for replication to fail on any number of shard copies but still succeed on the primary. + # The +_shards+ section of the API response reveals the number of shard copies on which replication succeeded and failed. + # **No operation (noop) updates** + # When updating a document by using this API, a new version of the document is always created even if the document hasn't changed. + # If this isn't acceptable use the +_update+ API with +detect_noop+ set to +true+. + # The +detect_noop+ option isn't available on this API because it doesn’t fetch the old source and isn't able to compare it against the new source. + # There isn't a definitive rule for when noop updates aren't acceptable. + # It's a combination of lots of factors like how frequently your data source sends updates that are actually noops and how many queries per second Elasticsearch runs on the shard receiving the updates. + # **Versioning** + # Each indexed document is given a version number. + # By default, internal versioning is used that starts at 1 and increments with each update, deletes included. + # Optionally, the version number can be set to an external value (for example, if maintained in a database). + # To enable this functionality, +version_type+ should be set to +external+. + # The value provided must be a numeric, long value greater than or equal to 0, and less than around +9.2e+18+. + # NOTE: Versioning is completely real time, and is not affected by the near real time aspects of search operations. + # If no version is provided, the operation runs without any version checks. + # When using the external version type, the system checks to see if the version number passed to the index request is greater than the version of the currently stored document. + # If true, the document will be indexed and the new version number used. + # If the value provided is less than or equal to the stored document's version number, a version conflict will occur and the index operation will fail. For example: + # ``` + # PUT my-index-000001/_doc/1?version=2&version_type=external + # { + # "user": { + # "id": "elkbee" + # } + # } + # In this example, the operation will succeed since the supplied version of 2 is higher than the current document version of 1. + # If the document was already updated and its version was set to 2 or higher, the indexing command will fail and result in a conflict (409 HTTP status code). + # A nice side effect is that there is no need to maintain strict ordering of async indexing operations run as a result of changes to a source database, as long as version numbers from the source database are used. + # Even the simple case of updating the Elasticsearch index using data from a database is simplified if external versioning is used, as only the latest version will be used if the index operations arrive out of order. # - # @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 [String] :id A unique identifier for the document. + # To automatically generate a document ID, use the +POST //_doc/+ request format and omit this parameter. + # @option arguments [String] :index The 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. + # You can check for existing targets with the resolve index API. (*Required*) + # @option arguments [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option arguments [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option arguments [Boolean] :include_source_on_error True or false if to include the document source in the error message in case of parsing errors. Server default: true. + # @option arguments [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. + # The behavior is the same as using the +/_create+ endpoint. + # If a document ID is specified, this paramater defaults to +index+. + # Otherwise, it defaults to +create+. + # If the request targets a data stream, an +op_type+ of +create+ is required. + # @option arguments [String] :pipeline The 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 arguments [String] :refresh If +true+, Elasticsearch refreshes the affected shards to make this operation visible to search. + # If +wait_for+, it waits for a refresh to make this operation visible to search. + # If +false+, it does nothing with refreshes. Server default: false. + # @option arguments [String] :routing A custom value that is used to route operations to a specific shard. + # @option arguments [Time] :timeout The period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.This parameter is useful for situations where the primary shard assigned to perform the operation might not be available when the operation runs. + # Some reasons for this might be that the primary shard is currently recovering from a gateway or undergoing relocation. + # By default, the operation will wait on the primary shard to become available for at least 1 minute before failing and responding with an error. + # The actual wait time could be longer, particularly when multiple waits occur. Server default: 1m. + # @option arguments [Integer] :version An explicit version number for concurrency control. + # It must be a non-negative long number. + # @option arguments [String] :version_type The version type. + # @option arguments [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. + # You can set it to +all+ or any positive integer up to the total number of shards in the index (+number_of_replicas+1+). + # The default value of +1+ means it waits for each primary shard to be active. Server default: 1. + # @option arguments [Boolean] :require_alias If +true+, the destination must be an index alias. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The document (*Required*) + # @option arguments [Hash] :body document # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-create # def index(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'index' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] @@ -56,14 +165,14 @@ def index(arguments = {}) method = _id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST path = if _index && _id - "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" + "#{Utils.listify(_index)}/_doc/#{Utils.listify(_id)}" else - "#{Utils.__listify(_index)}/_doc" + "#{Utils.listify(_index)}/_doc" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/delete_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/delete_lifecycle.rb index 2c2a8c89f3..9bc116f8ca 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/delete_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/delete_lifecycle.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Deletes the specified lifecycle policy definition. A currently used policy cannot be deleted. + # Delete a lifecycle policy. + # You cannot delete policies that are currently in use. If the policy is being used to manage any indices, the request fails and returns an error. # - # @option arguments [String] :policy The name of the index lifecycle policy + # @option arguments [String] :policy Identifier for the policy. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-delete-lifecycle # def delete_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.delete_lifecycle' } + + defined_params = [:policy].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'policy' missing" unless arguments[:policy] arguments = arguments.clone @@ -40,11 +50,11 @@ def delete_lifecycle(arguments = {}) _policy = arguments.delete(:policy) method = Elasticsearch::API::HTTP_DELETE - path = "_ilm/policy/#{Utils.__listify(_policy)}" - params = {} + path = "_ilm/policy/#{Utils.listify(_policy)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/explain_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/explain_lifecycle.rb index e789cd2447..d593ac122b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/explain_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/explain_lifecycle.rb @@ -15,38 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Retrieves information about the index's current lifecycle state, such as the currently executing phase, action, and step. + # Explain the lifecycle state. + # Get the current lifecycle status for one or more indices. + # For data streams, the API retrieves the current lifecycle status for the stream's backing indices. + # The response indicates when the index entered each lifecycle state, provides the definition of the running phase, and information about any failures. # - # @option arguments [String] :index The name of the index to explain - # @option arguments [Boolean] :only_managed filters the indices included in the response to ones managed by ILM - # @option arguments [Boolean] :only_errors filters the indices included in the response to ones in an ILM error state, implies only_managed + # @option arguments [String] :index Comma-separated list of data streams, indices, and aliases to target. Supports wildcards (+*+). + # To target all data streams and indices, use +*+ or +_all+. (*Required*) + # @option arguments [Boolean] :only_errors Filters the returned indices to only indices that are managed by ILM and are in an error state, either due to an encountering an error while executing the policy, or attempting to use a policy that does not exist. + # @option arguments [Boolean] :only_managed Filters the returned indices to only indices that are managed by ILM. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-explain-lifecycle # def explain_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.explain_lifecycle' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_ilm/explain" + path = "#{Utils.listify(_index)}/_ilm/explain" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/get_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/get_lifecycle.rb index cf2ba111cf..cff53ddc53 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/get_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/get_lifecycle.rb @@ -15,21 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Returns the specified policy definition. Includes the policy version and last modified date. + # Get lifecycle policies. # - # @option arguments [String] :policy The name of the index lifecycle policy + # @option arguments [String] :policy Identifier for the policy. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-get-lifecycle # def get_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.get_lifecycle' } + + defined_params = [:policy].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -39,14 +48,14 @@ def get_lifecycle(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _policy - "_ilm/policy/#{Utils.__listify(_policy)}" + "_ilm/policy/#{Utils.listify(_policy)}" else - "_ilm/policy" + '_ilm/policy' end - params = {} + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/get_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/get_status.rb index 1d237cbde1..e9baf3a82c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/get_status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/get_status.rb @@ -15,31 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Retrieves the current index lifecycle management (ILM) status. + # Get the ILM status. + # Get the current index lifecycle management status. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-get-status # def get_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.get_status' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_ilm/status" + path = '_ilm/status' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers.rb index 29b806142d..684a057125 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers.rb @@ -15,33 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Migrates the indices and ILM policies away from custom node attribute allocation routing to data tiers routing + # Migrate to data tiers routing. + # Switch the indices, ILM policies, and legacy, composable, and component templates from using custom node attributes and attribute-based allocation filters to using data tiers. + # Optionally, delete one legacy index template. + # Using node roles enables ILM to automatically move the indices between data tiers. + # Migrating away from custom node attributes routing can be manually performed. + # This API provides an automated way of performing three out of the four manual steps listed in the migration guide: + # 1. Stop setting the custom hot attribute on new indices. + # 1. Remove custom allocation settings from existing ILM policies. + # 1. Replace custom allocation settings from existing indices with the corresponding tier preference. + # ILM must be stopped before performing the migration. + # Use the stop ILM and get ILM status APIs to wait until the reported operation mode is +STOPPED+. # - # @option arguments [Boolean] :dry_run If set to true it will simulate the migration, providing a way to retrieve the ILM policies and indices that need to be migrated. The default is false + # @option arguments [Boolean] :dry_run If true, simulates the migration from node attributes based allocation filters to data tiers, but does not perform the migration. + # This provides a way to retrieve the indices and ILM policies that need to be migrated. + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Optionally specify a legacy index template name to delete and optionally specify a node attribute name used for index shard routing (defaults to "data") + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-migrate-to-data-tiers.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-migrate-to-data-tiers # def migrate_to_data_tiers(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.migrate_to_data_tiers' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_ilm/migrate_to_data_tiers" + path = '_ilm/migrate_to_data_tiers' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb index 04e398b5d6..f9527f34dc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/move_to_step.rb @@ -15,37 +15,54 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Manually moves an index into the specified step and executes that step. + # Move to a lifecycle step. + # Manually move an index into a specific step in the lifecycle policy and run that step. + # WARNING: This operation can result in the loss of data. Manually moving an index into a specific step runs that step even if it has already been performed. This is a potentially destructive action and this should be considered an expert level API. + # You must specify both the current step and the step to be executed in the body of the request. + # The request will fail if the current step does not match the step currently running for the index + # This is to prevent the index from being moved from an unexpected step into the next step. + # When specifying the target (+next_step+) to which the index will be moved, either the name or both the action and name fields are optional. + # If only the phase is specified, the index will move to the first step of the first action in the target phase. + # If the phase and action are specified, the index will move to the first step of the specified action in the specified phase. + # Only actions specified in the ILM policy are considered valid. + # An index cannot move to a step that is not part of its policy. # - # @option arguments [String] :index The name of the index whose lifecycle step is to change + # @option arguments [String] :index The name of the index whose lifecycle step is to change (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The new lifecycle step to move to + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-move-to-step # def move_to_step(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.move_to_step' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "_ilm/move/#{Utils.__listify(_index)}" + path = "_ilm/move/#{Utils.listify(_index)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb index 89c3fc8adc..1f1cf79e72 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/put_lifecycle.rb @@ -15,22 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Creates a lifecycle policy + # Create or update a lifecycle policy. + # If the specified policy exists, it is replaced and the policy version is incremented. + # NOTE: Only the latest version of the policy is stored, you cannot revert to previous versions. # - # @option arguments [String] :policy The name of the index lifecycle policy + # @option arguments [String] :policy Identifier for the policy. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The lifecycle policy definition to register + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-put-lifecycle # def put_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.put_lifecycle' } + + defined_params = [:policy].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'policy' missing" unless arguments[:policy] arguments = arguments.clone @@ -41,11 +52,11 @@ def put_lifecycle(arguments = {}) _policy = arguments.delete(:policy) method = Elasticsearch::API::HTTP_PUT - path = "_ilm/policy/#{Utils.__listify(_policy)}" - params = {} + path = "_ilm/policy/#{Utils.listify(_policy)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/remove_policy.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/remove_policy.rb index 3949503e61..f67eb6364d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/remove_policy.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/remove_policy.rb @@ -15,36 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Removes the assigned lifecycle policy and stops managing the specified index + # Remove policies from an index. + # Remove the assigned lifecycle policies from an index or a data stream's backing indices. + # It also stops managing the indices. # - # @option arguments [String] :index The name of the index to remove policy on + # @option arguments [String] :index The name of the index to remove policy on (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-remove-policy # def remove_policy(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.remove_policy' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_ilm/remove" + path = "#{Utils.listify(_index)}/_ilm/remove" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/retry.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/retry.rb index 5f307f3687..c347d1cd45 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/retry.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/retry.rb @@ -15,36 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Retries executing the policy for an index that is in the ERROR step. + # Retry a policy. + # Retry running the lifecycle policy for an index that is in the ERROR step. + # The API sets the policy back to the step where the error occurred and runs the step. + # Use the explain lifecycle state API to determine whether an index is in the ERROR step. # - # @option arguments [String] :index The name of the indices (comma-separated) whose failed lifecycle step is to be retry + # @option arguments [String] :index The name of the indices (comma-separated) whose failed lifecycle step is to be retry (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-retry # def retry(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.retry' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_ilm/retry" + path = "#{Utils.listify(_index)}/_ilm/retry" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/start.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/start.rb index 2db6b015b6..7d03cc34bd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/start.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/start.rb @@ -15,31 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Start the index lifecycle management (ILM) plugin. + # Start the ILM plugin. + # Start the index lifecycle management plugin if it is currently stopped. + # ILM is started automatically when the cluster is formed. + # Restarting ILM is necessary only when it has been stopped using the stop ILM API. # + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-start # def start(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.start' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_ilm/start" - params = {} + path = '_ilm/start' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/stop.rb b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/stop.rb index 994a8dea19..405751a109 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/stop.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/index_lifecycle_management/stop.rb @@ -15,31 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module IndexLifecycleManagement module Actions - # Halts all lifecycle management operations and stops the index lifecycle management (ILM) plugin + # Stop the ILM plugin. + # Halt all lifecycle management operations and stop the index lifecycle management plugin. + # This is useful when you are performing maintenance on the cluster and need to prevent ILM from performing any actions on your indices. + # The API returns as soon as the stop request has been acknowledged, but the plugin might continue to run until in-progress operations complete and the plugin can be safely stopped. + # Use the get ILM status API to check whether ILM is running. # + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-stop # def stop(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ilm.stop' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_ilm/stop" - params = {} + path = '_ilm/stop' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/add_block.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/add_block.rb index dbc424a3a4..ee9133da0c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/add_block.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/add_block.rb @@ -15,45 +15,65 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Adds a block to an index. + # Add an index block. + # Add an index block to an index. + # Index blocks limit the operations allowed on an index by blocking specific operation types. # - # @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 Specify timeout for connection to master - # @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] :index A comma-separated list or wildcard expression of index names used to limit the request. + # By default, you must explicitly name the indices you are adding blocks to. + # To allow the adding of blocks to indices with +_all+, +*+, or other wildcard expressions, change the +action.destructive_requires_name+ setting to +false+. + # You can update this setting in the +elasticsearch.yml+ file or by using the cluster update settings API. (*Required*) + # @option arguments [String] :block The block type to add to the index. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. + # @option arguments [String, Array] :expand_wildcards The 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. + # It supports comma-separated values, such as +open,hidden+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. + # If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-blocks.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-add-block # def add_block(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.add_block' } + + defined_params = [:index, :block].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'block' missing" unless arguments[:block] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) _block = arguments.delete(:block) method = Elasticsearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_block/#{Utils.__listify(_block)}" + path = "#{Utils.listify(_index)}/_block/#{Utils.listify(_block)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb index d4a922ef32..c7f6ffe3f5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb @@ -15,26 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Performs the analysis process on a text and return the tokens breakdown of the text. + # Get tokens from text analysis. + # The analyze API performs analysis on a text string and returns the resulting tokens. + # Generating excessive amount of tokens may cause a node to run out of memory. + # The +index.analyze.max_token_count+ setting enables you to limit the number of tokens that can be produced. + # If more than this limit of tokens gets generated, an error occurs. + # The +_analyze+ endpoint without a specified index will always use +10000+ as its limit. # - # @option arguments [String] :index The name of the index to scope the operation + # @option arguments [String] :index Index used to derive the analyzer. + # If specified, the +analyzer+ or field parameter overrides this value. + # If no index is specified or the index does not have a default analyzer, the analyze API uses the standard analyzer. # @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 + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-analyze # def analyze(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.analyze' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -45,14 +59,14 @@ def analyze(arguments = {}) end path = if _index - "#{Utils.__listify(_index)}/_analyze" + "#{Utils.listify(_index)}/_analyze" else - "_analyze" + '_analyze' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/cancel_migrate_reindex.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/cancel_migrate_reindex.rb new file mode 100644 index 0000000000..384ed76ba7 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/cancel_migrate_reindex.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Indices + module Actions + # Cancel a migration reindex operation. + # Cancel a migration reindex attempt for a data stream or index. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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, Array] :index The index or data stream name (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-cancel-migrate-reindex + # + def cancel_migrate_reindex(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.cancel_migrate_reindex' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _index = arguments.delete(:index) + + method = Elasticsearch::API::HTTP_POST + path = "_migration/reindex/#{Utils.listify(_index)}/_cancel" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/clear_cache.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/clear_cache.rb index 6d1e5d4431..25666554fb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/clear_cache.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/clear_cache.rb @@ -15,45 +15,64 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Clears all or specific caches for one or more indices. + # Clear the cache. + # Clear the cache of one or more indices. + # For data streams, the API clears the caches of the stream's backing indices. + # By default, the clear cache API clears all caches. + # To clear only specific caches, use the +fielddata+, +query+, or +request+ parameters. + # To clear the cache only of specific fields, use the +fields+ parameter. # - # @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 [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :fielddata If +true+, clears the fields cache. + # Use the +fields+ parameter to clear the cache of specific fields only. + # @option arguments [String, Array] :fields Comma-separated list of field names used to limit the +fielddata+ parameter. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :query If +true+, clears the query cache. + # @option arguments [Boolean] :request If +true+, clears the request cache. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-clear-cache # def clear_cache(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.clear_cache' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_cache/clear" + "#{Utils.listify(_index)}/_cache/clear" else - "_cache/clear" + '_cache/clear' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/clone.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/clone.rb index d81382ac55..61f761be3c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/clone.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/clone.rb @@ -15,44 +15,84 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Clones an index + # Clone an index. + # Clone an existing index into a new index. + # Each original primary shard is cloned into a new primary shard in the new index. + # IMPORTANT: Elasticsearch does not apply index templates to the resulting index. + # The API also does not copy index metadata from the original index. + # Index metadata includes aliases, index lifecycle management phase definitions, and cross-cluster replication (CCR) follower information. + # For example, if you clone a CCR follower index, the resulting clone will not be a follower index. + # The clone API copies most index settings from the source index to the resulting index, with the exception of +index.number_of_replicas+ and +index.auto_expand_replicas+. + # To set the number of replicas in the resulting index, configure these settings in the clone request. + # Cloning works as follows: + # * First, it creates a new target index with the same definition as the source index. + # * Then it hard-links segments from the source index into the target index. If the file system does not support hard-linking, all segments are copied into the new index, which is a much more time consuming process. + # * Finally, it recovers the target index as though it were a closed index which had just been re-opened. + # IMPORTANT: Indices can only be cloned if they meet the following requirements: + # * The index must be marked as read-only and have a cluster health status of green. + # * The target index must not exist. + # * The source index must have the same number of primary shards as the target index. + # * The node handling the clone process must have sufficient free disk space to accommodate a second copy of the existing index. + # The current write index on a data stream cannot be cloned. + # In order to clone the current write index, the data stream must first be rolled over so that a new write index is created and then the previous write index can be cloned. + # NOTE: Mappings cannot be specified in the +_clone+ request. The mappings of the source index will be used for the target index. + # **Monitor the cloning process** + # The cloning process can be monitored with the cat recovery API or the cluster health API can be used to wait until all primary shards have been allocated by setting the +wait_for_status+ parameter to +yellow+. + # The +_clone+ API returns as soon as the target index has been added to the cluster state, before any shards have been allocated. + # At this point, all shards are in the state unassigned. + # If, for any reason, the target index can't be allocated, its primary shard will remain unassigned until it can be allocated on that node. + # Once the primary shard is allocated, it moves to state initializing, and the clone process begins. + # When the clone operation completes, the shard will become active. + # At that point, Elasticsearch will try to allocate any replicas and may decide to relocate the primary shard to another node. + # **Wait for active shards** + # Because the clone operation creates a new index to clone the shards to, the wait for active shards setting on index creation applies to the clone index action as well. # - # @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 Specify timeout for connection to master - # @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 [String] :index Name of the source index to clone. (*Required*) + # @option arguments [String] :target Name of the target index to create. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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+). Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clone-index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-clone # def clone(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.clone' } + + defined_params = [:index, :target].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) _target = arguments.delete(:target) method = Elasticsearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_clone/#{Utils.__listify(_target)}" + path = "#{Utils.listify(_index)}/_clone/#{Utils.listify(_target)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/close.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/close.rb index 98f72f6c66..0b406803bb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/close.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/close.rb @@ -15,42 +15,69 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Closes an index. + # Close an index. + # A closed index is blocked for read or write operations and does not allow all operations that opened indices allow. + # It is not possible to index documents or to search for documents in a closed index. + # Closed indices do not have to maintain internal data structures for indexing or searching documents, which results in a smaller overhead on the cluster. + # When opening or closing an index, the master node is responsible for restarting the index shards to reflect the new state of the index. + # The shards will then go through the normal recovery process. + # The data of opened and closed indices is automatically replicated by the cluster to ensure that enough shard copies are safely kept around at all times. + # You can open and close multiple indices. + # An error is thrown if the request explicitly refers to a missing index. + # This behaviour can be turned off using the +ignore_unavailable=true+ parameter. + # By default, you must explicitly name the indices you are opening or closing. + # To open or close indices with +_all+, +*+, or other wildcard expressions, change the+action.destructive_requires_name+ setting to +false+. This setting can also be changed with the cluster update settings API. + # Closed indices consume a significant amount of disk-space which can cause problems in managed environments. + # Closing indices can be turned off with the cluster settings API by setting +cluster.indices.close.enable+ to +false+. # - # @option arguments [List] :index A comma separated list of indices to close - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master - # @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 [String, Array] :index Comma-separated list or wildcard expression of index names used to limit the request. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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+). Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-close # def close(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.close' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_close" + path = "#{Utils.listify(_index)}/_close" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb index 82f098841a..6c893494be 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create.rb @@ -15,40 +15,65 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Creates an index with optional settings and mappings. + # Create an index. + # You can use the create index API to add a new index to an Elasticsearch cluster. + # When creating an index, you can specify the following: + # * Settings for the index. + # * Mappings for fields in the index. + # * Index aliases + # **Wait for active shards** + # By default, index creation will only return a response to the client when the primary copies of each shard have been started, or the request times out. + # The index creation response will indicate what happened. + # For example, +acknowledged+ indicates whether the index was successfully created in the cluster, +while shards_acknowledged+ indicates whether the requisite number of shard copies were started for each shard in the index before timing out. + # Note that it is still possible for either +acknowledged+ or +shards_acknowledged+ to be +false+, but for the index creation to be successful. + # These values simply indicate whether the operation completed before the timeout. + # If +acknowledged+ is false, the request timed out before the cluster state was updated with the newly created index, but it probably will be created sometime soon. + # If +shards_acknowledged+ is false, then the request timed out before the requisite number of shards were started (by default just the primaries), even if the cluster state was successfully updated to reflect the newly created index (that is to say, +acknowledged+ is +true+). + # You can change the default of only waiting for the primary shards to start through the index setting +index.write.wait_for_active_shards+. + # Note that changing this setting will also affect the +wait_for_active_shards+ value on all subsequent write operations. # - # @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 Specify timeout for connection to master + # @option arguments [String] :index Name of the index you wish to create. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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+). Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The configuration for the index (`settings` and `mappings`) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create # def create(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.create' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}" + path = Utils.listify(_index).to_s params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create_data_stream.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create_data_stream.rb index 8a297a522b..7492c972f7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create_data_stream.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create_data_stream.rb @@ -15,21 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Creates a data stream + # Create a data stream. + # You must have a matching index template with data stream enabled. # - # @option arguments [String] :name The name of the data stream + # @option arguments [String] :name 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. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create-data-stream # def create_data_stream(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.create_data_stream' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -40,11 +55,11 @@ def create_data_stream(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_data_stream/#{Utils.__listify(_name)}" - params = {} + path = "_data_stream/#{Utils.listify(_name)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/create_from.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create_from.rb new file mode 100644 index 0000000000..87a90e8d21 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/create_from.rb @@ -0,0 +1,71 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Indices + module Actions + # Create an index from a source index. + # Copy the mappings and settings from the source index to a destination index while allowing request settings and mappings to override the source values. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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] :source The source index or data stream name (*Required*) + # @option arguments [String] :dest The destination index or data stream name (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body create_from + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create-from + # + def create_from(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.create_from' } + + defined_params = [:source, :dest].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'source' missing" unless arguments[:source] + raise ArgumentError, "Required argument 'dest' missing" unless arguments[:dest] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _source = arguments.delete(:source) + + _dest = arguments.delete(:dest) + + method = Elasticsearch::API::HTTP_PUT + path = "_create_from/#{Utils.listify(_source)}/#{Utils.listify(_dest)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/data_streams_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/data_streams_stats.rb index c5089eca6c..390865889c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/data_streams_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/data_streams_stats.rb @@ -15,21 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Provides statistics on operations happening in a data stream. + # Get data stream stats. + # Get statistics for one or more data streams. # - # @option arguments [List] :name A comma-separated list of data stream names; use `_all` or empty string to perform the operation on all data streams + # @option arguments [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 +*+. + # @option arguments [String, Array] :expand_wildcards Type of data stream that wildcard patterns can match. + # Supports comma-separated values, such as +open,hidden+. Server default: open. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-data-streams-stats-1 # def data_streams_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.data_streams_stats' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -39,14 +51,14 @@ def data_streams_stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_data_stream/#{Utils.__listify(_name)}/_stats" + "_data_stream/#{Utils.listify(_name)}/_stats" else - "_data_stream/_stats" + '_data_stream/_stats' end - params = {} + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete.rb index cbfc13369e..f896e8e0d5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete.rb @@ -15,48 +15,69 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Deletes an index. + # Delete indices. + # Deleting an index deletes its documents, shards, and metadata. + # It does not delete related Kibana components, such as data views, visualizations, or dashboards. + # You cannot delete the current write index of a data stream. + # To delete the index, you must roll over the data stream so a new write index is created. + # You can then use the delete index API to delete the previous write 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 Specify timeout for connection to master - # @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, closed, or hidden indices (options: open, closed, hidden, none, all) + # @option arguments [String, Array] :index Comma-separated list of indices 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+. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete # def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.delete' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_DELETE - path = "#{Utils.__listify(_index)}" + path = Utils.listify(_index).to_s params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_alias.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_alias.rb index 948c3512fd..4e19211bfc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_alias.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_alias.rb @@ -15,44 +15,54 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Deletes an alias. + # Delete an alias. + # Removes a data stream or index from 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 Specify timeout for connection to master + # @option arguments [String, Array] :index Comma-separated list of data streams or indices used to limit the request. + # Supports wildcards (+*+). (*Required*) + # @option arguments [String, Array] :name Comma-separated list of aliases to remove. + # Supports wildcards (+*+). To remove all aliases, use +*+ or +_all+. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-alias # def delete_alias(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.delete_alias' } + + defined_params = [:index, :name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = if _index && _name - "#{Utils.__listify(_index)}/_aliases/#{Utils.__listify(_name)}" - end + path = ("#{Utils.listify(_index)}/_aliases/#{Utils.listify(_name)}" if _index && _name) params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_data_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_data_lifecycle.rb index 0aff6ea866..80154e61dd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_data_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_data_lifecycle.rb @@ -15,28 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Deletes the data stream lifecycle of the selected data streams. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Delete data stream lifecycles. + # Removes the data stream lifecycle from a data stream, rendering it not managed by the data stream lifecycle. # - # @option arguments [List] :name A comma-separated list of data streams of which the data stream lifecycle will be deleted; use `*` to get all data streams - # @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 [Time] :timeout Explicit timestamp for the document + # @option arguments [String, Array] :name A comma-separated list of data streams of which the data stream lifecycle will be deleted; use +*+ to get all data streams (*Required*) + # @option arguments [String, Array] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [Time] :timeout Explicit timestamp for the document # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-delete-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-data-lifecycle # def delete_data_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.delete_data_lifecycle' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -47,11 +51,11 @@ def delete_data_lifecycle(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_data_stream/#{Utils.__listify(_name)}/_lifecycle" + path = "_data_stream/#{Utils.listify(_name)}/_lifecycle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_data_stream.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_data_stream.rb index c46183e3a9..b99a604d4d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_data_stream.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_data_stream.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Deletes a data stream. + # Delete data streams. + # Deletes one or more data streams and their backing indices. # - # @option arguments [List] :name A comma-separated list of data streams to delete; use `*` to delete all data streams - # @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 [String, Array] :name Comma-separated list of data streams to delete. Wildcard (+*+) expressions are supported. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [String, Array] :expand_wildcards Type of data stream that wildcard patterns can match. Supports comma-separated values,such as +open,hidden+. Server default: open. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-data-stream # def delete_data_stream(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.delete_data_stream' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -41,11 +50,11 @@ def delete_data_stream(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_data_stream/#{Utils.__listify(_name)}" + path = "_data_stream/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_index_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_index_template.rb index 9f6072b96f..a3e30d135d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_index_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_index_template.rb @@ -15,23 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Deletes an index template. + # Delete an index template. + # The provided may contain multiple template names separated by a comma. If multiple template + # names are specified then there is no wildcard support and the provided names should match completely with + # existing templates. # - # @option arguments [String] :name The name of the template - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [String, Array] :name Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-index-template # def delete_index_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.delete_index_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -42,11 +52,11 @@ def delete_index_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_index_template/#{Utils.__listify(_name)}" + path = "_index_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_template.rb index 608efd6d4f..5619eb22c3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/delete_template.rb @@ -15,23 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Deletes an index template. + # Delete a legacy index template. # - # @option arguments [String] :name The name of the template - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [String] :name The name of the legacy index template to delete. + # Wildcard (+*+) expressions are supported. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-delete-template # def delete_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.delete_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -42,18 +52,18 @@ def delete_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_template/#{Utils.__listify(_name)}" + path = "_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/disk_usage.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/disk_usage.rb index b93645a48c..27df7026e7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/disk_usage.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/disk_usage.rb @@ -15,45 +15,65 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Analyzes the disk usage of each field of an index or data stream + # Analyze the index disk usage. + # Analyze the disk usage of each field of an index or data stream. + # This API might not support indices created in previous Elasticsearch versions. + # The result of a small index can be inaccurate as some parts of an index might not be analyzed by the API. + # NOTE: The total size of fields of the analyzed shards of the index in the response is usually smaller than the index +store_size+ value because some small metadata files are ignored and some parts of data files might not be scanned by the API. + # Since stored fields are stored together in a compressed format, the sizes of stored fields are also estimates and can be inaccurate. + # The stored size of the +_id+ field is likely underestimated while the +_source+ field is overestimated. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # It’s recommended to execute this API with a single index (or the latest backing index of a data stream) as the API consumes resources significantly. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :flush If +true+, the API performs a flush before analysis. + # If +false+, the response may not include uncommitted data. Server default: true. + # @option arguments [Boolean] :ignore_unavailable If +true+, missing or closed indices are not included in the response. + # @option arguments [Boolean] :run_expensive_tasks Analyzing field disk usage is resource-intensive. + # To use the API, this parameter must be set to +true+. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-disk-usage.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-disk-usage # def disk_usage(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.disk_usage' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_disk_usage" + path = "#{Utils.listify(_index)}/_disk_usage" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/downsample.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/downsample.rb index 687b99fd07..4a33d4f837 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/downsample.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/downsample.rb @@ -15,27 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Downsample an index + # Downsample an index. + # Aggregate a time series (TSDS) index and store pre-computed statistical summaries (+min+, +max+, +sum+, +value_count+ and +avg+) for each metric field grouped by a configured time interval. + # For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index. + # All documents within an hour interval are summarized and stored as a single document in the downsample index. + # NOTE: Only indices in a time series data stream are supported. + # Neither field nor document level security can be defined on the source index. + # The source index must be read only (+index.blocks.write: true+). # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 The index to downsample (*Required*) - # @option arguments [String] :target_index The name of the target index to store downsampled data (*Required*) + # @option arguments [String] :index Name of the time series index to downsample. (*Required*) + # @option arguments [String] :target_index Name of the index to create. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The downsampling configuration (*Required*) + # @option arguments [Hash] :body config # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-rollup.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-downsample # def downsample(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.downsample' } + + defined_params = [:index, :target_index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'target_index' missing" unless arguments[:target_index] @@ -43,18 +56,18 @@ def downsample(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) _target_index = arguments.delete(:target_index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_downsample/#{Utils.__listify(_target_index)}" + path = "#{Utils.listify(_index)}/_downsample/#{Utils.listify(_target_index)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists.rb index b244d86513..e9396806df 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists.rb @@ -15,46 +15,58 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns information about whether a particular index exists. + # Check indices. + # Check if one or more indices, index aliases, or data streams exist. # - # @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 [String, Array] :index Comma-separated list of data streams, indices, and aliases. Supports wildcards (+*+). (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :flat_settings If +true+, returns settings in flat format. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :include_defaults If +true+, return all default settings in the response. + # @option arguments [Boolean] :local If +true+, the request retrieves information from the local node only. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-exists # def exists(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.exists' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_HEAD - path = "#{Utils.__listify(_index)}" + path = Utils.listify(_index).to_s params = Utils.process_params(arguments) - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 ? true : false + Utils.rescue_from_not_found do + perform_request(method, path, params, body, headers, request_opts).status == 200 end end - alias_method :exists?, :exists + alias exists? exists end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_alias.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_alias.rb index e52f4575e7..b80dffa533 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_alias.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_alias.rb @@ -15,26 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns information about whether a particular alias exists. + # Check aliases. + # Check if one or more data stream or index aliases exist. # - # @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 [String, Array] :name Comma-separated list of aliases to check. Supports wildcards (+*+). (*Required*) + # @option arguments [String, Array] :index Comma-separated list of data streams or indices used to limit the request. Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, requests that include a missing data stream or index in the target indices or data streams return an error. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-exists-alias # def exists_alias(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.exists_alias' } + + defined_params = [:name, :index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -48,18 +62,18 @@ def exists_alias(arguments = {}) method = Elasticsearch::API::HTTP_HEAD path = if _index && _name - "#{Utils.__listify(_index)}/_alias/#{Utils.__listify(_name)}" + "#{Utils.listify(_index)}/_alias/#{Utils.listify(_name)}" else - "_alias/#{Utils.__listify(_name)}" + "_alias/#{Utils.listify(_name)}" end params = Utils.process_params(arguments) - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 ? true : false + Utils.rescue_from_not_found do + perform_request(method, path, params, body, headers, request_opts).status == 200 end end - alias_method :exists_alias?, :exists_alias + alias exists_alias? exists_alias end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_index_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_index_template.rb index 9f87f17404..56034a89bb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_index_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_index_template.rb @@ -15,24 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns information about whether a particular index template exists. + # Check index templates. + # Check whether index templates exist. # - # @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 Explicit operation timeout for connection to master node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) + # @option arguments [String] :name Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. (*Required*) + # @option arguments [Boolean] :local If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node. + # @option arguments [Boolean] :flat_settings If true, returns settings in flat format. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-exists-index-template # def exists_index_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.exists_index_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -43,15 +51,15 @@ def exists_index_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_HEAD - path = "_index_template/#{Utils.__listify(_name)}" + path = "_index_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end - alias_method :exists_index_template?, :exists_index_template + alias exists_index_template? exists_index_template end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_template.rb index d9fbb5c235..2c755ef89e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_template.rb @@ -15,24 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns information about whether a particular index template exists. + # Check existence of index templates. + # Get information about whether index templates exist. + # Index templates define settings, mappings, and aliases that can be applied automatically to new indices. + # IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8. # - # @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 Explicit operation timeout for connection to master node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) + # @option arguments [String, Array] :name A comma-separated list of index template names used to limit the request. + # Wildcard (+*+) expressions are supported. (*Required*) + # @option arguments [Boolean] :flat_settings Indicates whether to use a flat format for the response. + # @option arguments [Boolean] :local Indicates whether to get information from the local node only. + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-exists-template # def exists_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.exists_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -43,15 +56,15 @@ def exists_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_HEAD - path = "_template/#{Utils.__listify(_name)}" + path = "_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) - Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 ? true : false + Utils.rescue_from_not_found do + perform_request(method, path, params, body, headers, request_opts).status == 200 end end - alias_method :exists_template?, :exists_template + alias exists_template? exists_template end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/explain_data_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/explain_data_lifecycle.rb index b508521434..8016903a31 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/explain_data_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/explain_data_lifecycle.rb @@ -15,42 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Retrieves information about the index's current data stream lifecycle, such as any potential encountered error, time since creation etc. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Get the status for a data stream lifecycle. + # Get information about an index or data stream's current data stream lifecycle status, such as time since index creation, time since rollover, the lifecycle configuration managing the index, or any errors encountered during lifecycle execution. # - # @option arguments [String] :index The name of the index to explain + # @option arguments [String, Array] :index The name of the index to explain (*Required*) # @option arguments [Boolean] :include_defaults indicates if the API should return the default values the system uses for the index's lifecycle # @option arguments [Time] :master_timeout Specify timeout for connection to master # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-explain-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-explain-data-lifecycle # def explain_data_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.explain_data_lifecycle' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_lifecycle/explain" + path = "#{Utils.listify(_index)}/_lifecycle/explain" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb index 265b064caf..8c9285caa9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb @@ -15,44 +15,60 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns the field usage stats for each field of an index + # Get field usage stats. + # Get field usage information for each shard and field of an index. + # Field usage statistics are automatically captured when queries are running on a cluster. + # A shard-level search request that accesses a given field, even if multiple times during that request, is counted as a single use. + # The response body reports the per-shard usage count of the data structures that back the fields in the index. + # A given request will increment each count by a maximum value of 1, even if the request accesses the same field multiple times. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 [String, Array] :index Comma-separated list or wildcard expression of index names used to limit the request. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. + # @option arguments [String, Array] :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 arguments [Boolean] :ignore_unavailable If +true+, missing or closed indices are not included in the response. + # @option arguments [String, Array] :fields Comma-separated list or wildcard expressions of fields to include in the statistics. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/field-usage-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-field-usage-stats # def field_usage_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.field_usage_stats' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_field_usage_stats" + path = "#{Utils.listify(_index)}/_field_usage_stats" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/flush.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/flush.rb index 92c77705e0..cd4e96d82e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/flush.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/flush.rb @@ -15,43 +15,65 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Performs the flush operation on one or more indices. + # Flush data streams or indices. + # Flushing a data stream or index is the process of making sure that any data that is currently only stored in the transaction log is also permanently stored in the Lucene index. + # When restarting, Elasticsearch replays any unflushed operations from the transaction log into the Lucene index to bring it back into the state that it was in before the restart. + # Elasticsearch automatically triggers flushes as needed, using heuristics that trade off the size of the unflushed transaction log against the cost of performing each flush. + # After each operation has been flushed it is permanently stored in the Lucene index. + # This may mean that there is no need to maintain an additional copy of it in the transaction log. + # The transaction log is made up of multiple files, called generations, and Elasticsearch will delete any generation files when they are no longer needed, freeing up disk space. + # It is also possible to trigger a flush on one or more indices using the flush API, although it is rare for users to need to call this API directly. + # If you call the flush API after indexing some documents then a successful response indicates that Elasticsearch has flushed all the documents that were indexed before the flush API was called. # - # @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 [String, Array] :index Comma-separated list of data streams, indices, and aliases to flush. + # Supports wildcards (+*+). + # To flush all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :force If +true+, the request forces a flush even if there are no changes to commit to the index. Server default: true. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :wait_if_ongoing If +true+, the flush operation blocks until execution when another flush operation is running. + # If +false+, Elasticsearch returns an error if you request a flush when another flush operation is running. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-flush # def flush(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.flush' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_flush" + "#{Utils.listify(_index)}/_flush" else - "_flush" + '_flush' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/forcemerge.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/forcemerge.rb index 674d155040..7a30c2d2e0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/forcemerge.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/forcemerge.rb @@ -15,45 +15,90 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Performs the force merge operation on one or more indices. + # Force a merge. + # Perform the force merge operation on the shards of one or more indices. + # For data streams, the API forces a merge on the shards of the stream's backing indices. + # Merging reduces the number of segments in each shard by merging some of them together and also frees up the space used by deleted documents. + # Merging normally happens automatically, but sometimes it is useful to trigger a merge manually. + # WARNING: We recommend force merging only a read-only index (meaning the index is no longer receiving writes). + # When documents are updated or deleted, the old version is not immediately removed but instead soft-deleted and marked with a "tombstone". + # These soft-deleted documents are automatically cleaned up during regular segment merges. + # But force merge can cause very large (greater than 5 GB) segments to be produced, which are not eligible for regular merges. + # So the number of soft-deleted documents can then grow rapidly, resulting in higher disk usage and worse search performance. + # If you regularly force merge an index receiving writes, this can also make snapshots more expensive, since the new documents can't be backed up incrementally. + # **Blocks during a force merge** + # Calls to this API block until the merge is complete (unless request contains +wait_for_completion=false+). + # If the client connection is lost before completion then the force merge process will continue in the background. + # Any new requests to force merge the same indices will also block until the ongoing force merge is complete. + # **Running force merge asynchronously** + # If the request contains +wait_for_completion=false+, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to get the status of the task. + # However, you can not cancel this task as the force merge task is not cancelable. + # Elasticsearch creates a record of this task as a document at +_tasks/+. + # When you are done with a task, you should delete the task document so Elasticsearch can reclaim the space. + # **Force merging multiple indices** + # You can force merge multiple indices with a single request by targeting: + # * One or more data streams that contain multiple backing indices + # * Multiple indices + # * One or more aliases + # * All data streams and indices in a cluster + # Each targeted shard is force-merged separately using the force_merge threadpool. + # By default each node only has a single +force_merge+ thread which means that the shards on that node are force-merged one at a time. + # If you expand the +force_merge+ threadpool on a node then it will force merge its shards in parallel + # Force merge makes the storage for the shard being merged temporarily increase, as it may require free space up to triple its size in case +max_num_segments parameter+ is set to +1+, to rewrite all segments into a new one. + # **Data streams and time-based indices** + # Force-merging is useful for managing a data stream's older backing indices and other time-based indices, particularly after a rollover. + # In these cases, each index only receives indexing traffic for a certain period of time. + # Once an index receive no more writes, its shards can be force-merged to a single segment. + # This can be a good idea because single-segment shards can sometimes use simpler and more efficient data structures to perform searches. + # For example: + # + + # POST /.ds-my-data-stream-2099.03.07-000001/_forcemerge?max_num_segments=1 + # + # - # @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 [String, Array] :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, Array] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. # @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 [Integer] :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 [Boolean] :wait_for_completion Should the request wait until the force merge is completed. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-forcemerge # def forcemerge(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.forcemerge' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_forcemerge" + "#{Utils.listify(_index)}/_forcemerge" else - "_forcemerge" + '_forcemerge' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get.rb index b9abcde2d1..074ea2a3d8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get.rb @@ -15,44 +15,58 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns information about one or more indices. + # Get index information. + # Get information about one or more indices. For data streams, the API returns information about the + # stream’s backing 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 [String] :features Return only information on specified index features (options: aliases, mappings, settings) - # @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 Specify timeout for connection to master + # @option arguments [String, Array] :index Comma-separated list of data streams, indices, and index aliases used to limit the request. + # Wildcard expressions (*) are supported. (*Required*) + # @option arguments [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 indices. This behavior applies even if the request targets other open indices. For example, + # a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. Server default: true. + # @option arguments [String, Array] :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. Server default: open. + # @option arguments [Boolean] :flat_settings If true, returns settings in flat format. + # @option arguments [Boolean] :ignore_unavailable If false, requests that target a missing index return an error. + # @option arguments [Boolean] :include_defaults If true, return all default settings in the response. + # @option arguments [Boolean] :local If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [String, Array] :features Return only information on specified index features Server default: ['aliases', 'mappings', 'settings']. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get # def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}" + path = Utils.listify(_index).to_s params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_alias.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_alias.rb index 90a6b25cfc..7f54b919bb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_alias.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_alias.rb @@ -15,26 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns an alias. + # Get aliases. + # Retrieves information for one or more data stream or index aliases. # - # @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 [String, Array] :name Comma-separated list of aliases to retrieve. + # Supports wildcards (+*+). + # To retrieve all aliases, omit this parameter or use +*+ or +_all+. + # @option arguments [String, Array] :index Comma-separated list of data streams or indices used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-alias # def get_alias(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_alias' } + + defined_params = [:name, :index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -46,18 +63,18 @@ def get_alias(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _index && _name - "#{Utils.__listify(_index)}/_alias/#{Utils.__listify(_name)}" + "#{Utils.listify(_index)}/_alias/#{Utils.listify(_name)}" elsif _index - "#{Utils.__listify(_index)}/_alias" + "#{Utils.listify(_index)}/_alias" elsif _name - "_alias/#{Utils.__listify(_name)}" + "_alias/#{Utils.listify(_name)}" else - "_alias" + '_alias' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_lifecycle.rb index 3d3e45314e..d4e33ecb01 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_lifecycle.rb @@ -15,27 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns the data stream lifecycle of the selected data streams. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Get data stream lifecycles. + # Get the data stream lifecycle configuration of one or more data streams. # - # @option arguments [List] :name A comma-separated list of data streams to get; use `*` to get all data streams - # @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] :include_defaults Return all relevant default configurations for the data stream (default: false) + # @option arguments [String, Array] :name Comma-separated list of data streams to limit the request. + # Supports wildcards (+*+). + # To target all data streams, omit this parameter or use +*+ or +_all+. (*Required*) + # @option arguments [String, Array] :expand_wildcards Type of data stream that wildcard patterns can match. + # Supports comma-separated values, such as +open,hidden+. + # Valid values are: +all+, +open+, +closed+, +hidden+, +none+. Server default: open. + # @option arguments [Boolean] :include_defaults If +true+, return all default settings in the response. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-get-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-lifecycle # def get_data_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_data_lifecycle' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -46,11 +55,11 @@ def get_data_lifecycle(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_GET - path = "_data_stream/#{Utils.__listify(_name)}/_lifecycle" + path = "_data_stream/#{Utils.listify(_name)}/_lifecycle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_lifecycle_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_lifecycle_stats.rb new file mode 100644 index 0000000000..a9bc9af528 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_lifecycle_stats.rb @@ -0,0 +1,51 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Indices + module Actions + # Get data stream lifecycle stats. + # Get statistics about the data streams that are managed by a data stream lifecycle. + # + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-lifecycle-stats + # + def get_data_lifecycle_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_data_lifecycle_stats' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_lifecycle/stats' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_stream.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_stream.rb index 6bf54b2e28..3e35d02f68 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_stream.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_data_stream.rb @@ -15,23 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns data streams. + # Get data streams. + # Get information about one or more data streams. # - # @option arguments [List] :name A comma-separated list of data streams to get; use `*` to get all data streams - # @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] :include_defaults Return all relevant default configurations for the data stream (default: false) + # @option arguments [String, Array] :name Comma-separated list of data stream names used to limit the request. + # Wildcard (+*+) expressions are supported. If omitted, all data streams are returned. + # @option arguments [String, Array] :expand_wildcards Type of data stream that wildcard patterns can match. + # Supports comma-separated values, such as +open,hidden+. Server default: open. + # @option arguments [Boolean] :include_defaults If true, returns all relevant default configurations for the index template. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Boolean] :verbose Whether the maximum timestamp for each data stream should be calculated and returned. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-data-stream # def get_data_stream(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_data_stream' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +53,14 @@ def get_data_stream(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_data_stream/#{Utils.__listify(_name)}" + "_data_stream/#{Utils.listify(_name)}" else - "_data_stream" + '_data_stream' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_field_mapping.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_field_mapping.rb index 6f67efdc66..c16b6cd2c0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_field_mapping.rb @@ -15,47 +15,64 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns mapping for one or more fields. + # Get mapping definitions. + # Retrieves mapping definitions for one or more fields. + # For data streams, the API retrieves field mappings for the stream’s backing indices. + # This API is useful if you don't need a complete mapping or if an index mapping contains a large number of 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 [String, Array] :fields Comma-separated list or wildcard expression of fields used to limit returned information. + # Supports wildcards (+*+). (*Required*) + # @option arguments [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :include_defaults If +true+, return all default settings in the response. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-mapping # def get_field_mapping(arguments = {}) - arguments = arguments.clone - _fields = arguments.delete(:field) || arguments.delete(:fields) - raise ArgumentError, "Required argument 'field' missing" unless _fields + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_field_mapping' } + + defined_params = [:fields, :index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'fields' missing" unless arguments[:fields] + + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil + + _fields = arguments.delete(:fields) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index && _fields - "#{Utils.__listify(_index)}/_mapping/field/#{Utils.__listify(_fields)}" + "#{Utils.listify(_index)}/_mapping/field/#{Utils.listify(_fields)}" else - "_mapping/field/#{Utils.__listify(_fields)}" + "_mapping/field/#{Utils.listify(_fields)}" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_index_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_index_template.rb index b5541104af..4cfcd8f3f0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_index_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_index_template.rb @@ -15,25 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns an index template. + # Get index templates. + # Get information about one or more index templates. # - # @option arguments [String] :name A pattern that returned template names must match - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Boolean] :include_defaults Return all relevant default configurations for the index template (default: false) + # @option arguments [String] :name Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. + # @option arguments [Boolean] :local If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node. + # @option arguments [Boolean] :flat_settings If true, returns settings in flat format. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Boolean] :include_defaults If true, returns all relevant default configurations for the index template. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-index-template # def get_index_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_index_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -43,14 +51,14 @@ def get_index_template(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_index_template/#{Utils.__listify(_name)}" + "_index_template/#{Utils.listify(_name)}" else - "_index_template" + '_index_template' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_mapping.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_mapping.rb index 9ebf4590d0..067e4e7a5c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_mapping.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_mapping.rb @@ -15,43 +15,58 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns mappings for one or more indices. + # Get mapping definitions. + # For data streams, the API retrieves mappings for the stream’s backing 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 Specify timeout for connection to master - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) *Deprecated* + # @option arguments [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :local If +true+, the request retrieves information from the local node only. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-mapping # def get_mapping(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_mapping' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "#{Utils.__listify(_index)}/_mapping" + "#{Utils.listify(_index)}/_mapping" else - "_mapping" + '_mapping' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_migrate_reindex_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_migrate_reindex_status.rb new file mode 100644 index 0000000000..a2d6f3b4b6 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_migrate_reindex_status.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Indices + module Actions + # Get the migration reindexing status. + # Get the status of a migration reindex attempt for a data stream or index. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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, Array] :index The index or data stream name. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-migration + # + def get_migrate_reindex_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_migrate_reindex_status' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _index = arguments.delete(:index) + + method = Elasticsearch::API::HTTP_GET + path = "_migration/reindex/#{Utils.listify(_index)}/_status" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_settings.rb index 2c8a123d94..2d8dc4dc06 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_settings.rb @@ -15,33 +15,53 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns settings for one or more indices. + # Get index settings. + # Get setting information for one or more indices. + # For data streams, it returns setting information for the stream's backing 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 Specify timeout for connection to master - # @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 [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit + # the request. Supports wildcards (+*+). To target all data streams and + # indices, omit this parameter or use +*+ or +_all+. + # @option arguments [String, Array] :name Comma-separated list or wildcard expression of settings to retrieve. + # @option arguments [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 indices. This + # behavior applies even if the request targets other open indices. For + # example, a request targeting +foo*,bar*+ returns an error if an index + # starts with foo but no index starts with +bar+. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :flat_settings If +true+, returns settings in flat format. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :include_defaults If +true+, return all default settings in the response. + # @option arguments [Boolean] :local If +true+, the request retrieves information from the local node only. If + # +false+, information is retrieved from the master node. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is + # received before the timeout expires, the request fails and returns an + # error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-settings # def get_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_settings' } + + defined_params = [:index, :name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) @@ -49,18 +69,18 @@ def get_settings(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _index && _name - "#{Utils.__listify(_index)}/_settings/#{Utils.__listify(_name)}" + "#{Utils.listify(_index)}/_settings/#{Utils.listify(_name)}" elsif _index - "#{Utils.__listify(_index)}/_settings" + "#{Utils.listify(_index)}/_settings" elsif _name - "_settings/#{Utils.__listify(_name)}" + "_settings/#{Utils.listify(_name)}" else - "_settings" + '_settings' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_template.rb index 1e2c4a76ce..2f8e1b7319 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/get_template.rb @@ -15,24 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns an index template. + # Get index templates. + # Get information about one or more index templates. + # IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8. # - # @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 Explicit operation timeout for connection to master node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) + # @option arguments [String, Array] :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 +*+. + # @option arguments [Boolean] :flat_settings If +true+, returns settings in flat format. + # @option arguments [Boolean] :local If +true+, the request retrieves information from the local node only. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-get-template # def get_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.get_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -42,14 +54,14 @@ def get_template(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_template/#{Utils.__listify(_name)}" + "_template/#{Utils.listify(_name)}" else - "_template" + '_template' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/migrate_reindex.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/migrate_reindex.rb new file mode 100644 index 0000000000..65f4f0ebf3 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/migrate_reindex.rb @@ -0,0 +1,60 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Indices + module Actions + # Reindex legacy backing indices. + # Reindex all legacy backing indices for a data stream. + # This operation occurs in a persistent task. + # The persistent task ID is returned immediately and the reindexing work is completed in that task. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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 reindex + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-migrate-reindex + # + def migrate_reindex(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.migrate_reindex' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_migration/reindex' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/migrate_to_data_stream.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/migrate_to_data_stream.rb index c6a4a4ba95..eac8dc5102 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/migrate_to_data_stream.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/migrate_to_data_stream.rb @@ -15,21 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Migrates an alias to a data stream + # Convert an index alias to a data stream. + # Converts an index alias to a data stream. + # You must have a matching index template that is data stream enabled. + # The alias must meet the following criteria: + # The alias must have a write index; + # All indices for the alias must have a +@timestamp+ field mapping of a +date+ or +date_nanos+ field type; + # The alias must not have any filters; + # The alias must not use custom routing. + # If successful, the request removes the alias and creates a data stream with the same name. + # The indices for the alias become hidden backing indices for the stream. + # The write index for the alias becomes the write index for the stream. # - # @option arguments [String] :name The name of the alias to migrate + # @option arguments [String] :name Name of the index alias to convert to a data stream. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-migrate-to-data-stream # def migrate_to_data_stream(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.migrate_to_data_stream' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -40,11 +59,11 @@ def migrate_to_data_stream(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_POST - path = "_data_stream/_migrate/#{Utils.__listify(_name)}" - params = {} + path = "_data_stream/_migrate/#{Utils.listify(_name)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/modify_data_stream.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/modify_data_stream.rb index 709b7e98ef..cd21d2aff8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/modify_data_stream.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/modify_data_stream.rb @@ -15,34 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Modifies a data stream + # Update data streams. + # Performs one or more data stream modification actions in a single atomic operation. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The data stream modifications (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-modify-data-stream # def modify_data_stream(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.modify_data_stream' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_data_stream/_modify" + path = '_data_stream/_modify' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/open.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/open.rb index fe9619cbfc..477f5c1ff3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/open.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/open.rb @@ -15,42 +15,76 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Opens an index. + # Open a closed index. + # For data streams, the API opens any closed backing indices. + # A closed index is blocked for read/write operations and does not allow all operations that opened indices allow. + # It is not possible to index documents or to search for documents in a closed index. + # This allows closed indices to not have to maintain internal data structures for indexing or searching documents, resulting in a smaller overhead on the cluster. + # When opening or closing an index, the master is responsible for restarting the index shards to reflect the new state of the index. + # The shards will then go through the normal recovery process. + # The data of opened or closed indices is automatically replicated by the cluster to ensure that enough shard copies are safely kept around at all times. + # You can open and close multiple indices. + # An error is thrown if the request explicitly refers to a missing index. + # This behavior can be turned off by using the +ignore_unavailable=true+ parameter. + # By default, you must explicitly name the indices you are opening or closing. + # To open or close indices with +_all+, +*+, or other wildcard expressions, change the +action.destructive_requires_name+ setting to +false+. + # This setting can also be changed with the cluster update settings API. + # Closed indices consume a significant amount of disk-space which can cause problems in managed environments. + # Closing indices can be turned off with the cluster settings API by setting +cluster.indices.close.enable+ to +false+. + # Because opening or closing an index allocates its shards, the +wait_for_active_shards+ setting on index creation applies to the +_open+ and +_close+ index actions as well. # - # @option arguments [List] :index A comma separated list of indices to open - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master - # @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 [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # By default, you must explicitly name the indices 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 +elasticsearch.yml+ file or using the cluster update settings API. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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+). Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-open # def open(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.open' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_open" + path = "#{Utils.listify(_index)}/_open" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/promote_data_stream.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/promote_data_stream.rb index c93174a286..923a127df0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/promote_data_stream.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/promote_data_stream.rb @@ -15,21 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Promotes a data stream from a replicated data stream managed by CCR to a regular data stream + # Promote a data stream. + # Promote a data stream from a replicated data stream managed by cross-cluster replication (CCR) to a regular data stream. + # With CCR auto following, a data stream from a remote cluster can be replicated to the local cluster. + # These data streams can't be rolled over in the local cluster. + # These replicated data streams roll over only if the upstream data stream rolls over. + # In the event that the remote cluster is no longer available, the data stream in the local cluster can be promoted to a regular data stream, which allows these data streams to be rolled over in the local cluster. + # NOTE: When promoting a data stream, ensure the local cluster has a data stream enabled index template that matches the data stream. + # If this is missing, the data stream will not be able to roll over until a matching index template is created. + # This will affect the lifecycle management of the data stream and interfere with the data stream size and retention. # - # @option arguments [String] :name The name of the data stream + # @option arguments [String] :name The name of the data stream (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-promote-data-stream # def promote_data_stream(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.promote_data_stream' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -40,11 +56,11 @@ def promote_data_stream(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_POST - path = "_data_stream/_promote/#{Utils.__listify(_name)}" - params = {} + path = "_data_stream/_promote/#{Utils.listify(_name)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_alias.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_alias.rb index 135b6b5513..6a97a06dea 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_alias.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_alias.rb @@ -15,45 +15,57 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Creates or updates an alias. + # Create or update an alias. + # Adds a data stream or index to 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 Specify timeout for connection to master + # @option arguments [String, Array] :index Comma-separated list of data streams or indices to add. + # Supports wildcards (+*+). + # Wildcard patterns that match both data streams and indices return an error. (*Required*) + # @option arguments [String] :name Alias to update. + # If the alias doesn’t exist, the request creates it. + # Index alias names support date math. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The settings for the alias, such as `routing` or `filter` + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-alias # def put_alias(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.put_alias' } + + defined_params = [:index, :name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = if _index && _name - "#{Utils.__listify(_index)}/_aliases/#{Utils.__listify(_name)}" - end + path = ("#{Utils.listify(_index)}/_aliases/#{Utils.listify(_name)}" if _index && _name) params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_lifecycle.rb index f0d851299c..ef432677f4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_data_lifecycle.rb @@ -15,29 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Updates the data stream lifecycle of the selected data streams. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Update data stream lifecycles. + # Update the data stream lifecycle of the specified data streams. # - # @option arguments [List] :name A comma-separated list of data streams whose lifecycle will be updated; use `*` to set the lifecycle to all data streams - # @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 [Time] :timeout Explicit timestamp for the document - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [String, Array] :name Comma-separated list of data streams used to limit the request. + # Supports wildcards (+*+). + # To target all data streams use +*+ or +_all+. (*Required*) + # @option arguments [String, Array] :expand_wildcards Type of data stream that wildcard patterns can match. + # Supports comma-separated values, such as +open,hidden+. + # Valid values are: +all+, +hidden+, +open+, +closed+, +none+. Server default: open. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is + # received before the timeout expires, the request fails and returns an + # error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The data stream lifecycle configuration that consist of the data retention + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-put-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-data-lifecycle # def put_data_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.put_data_lifecycle' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -48,11 +59,11 @@ def put_data_lifecycle(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_data_stream/#{Utils.__listify(_name)}/_lifecycle" + path = "_data_stream/#{Utils.listify(_name)}/_lifecycle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_index_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_index_template.rb index da71539e38..07324e2b01 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_index_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_index_template.rb @@ -15,25 +15,53 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Creates or updates an index template. + # Create or update an index template. + # Index templates define settings, mappings, and aliases that can be applied automatically to new indices. + # Elasticsearch applies templates to new indices based on an wildcard pattern that matches the index name. + # Index templates are applied during data stream or index creation. + # For data streams, these settings and mappings are applied when the stream's backing indices are created. + # Settings and mappings specified in a create index API request override any settings or mappings specified in an index template. + # Changes to index templates do not affect existing indices, including the existing backing indices of a data stream. + # You can use C-style +/* *\/+ block comments in index templates. + # You can include comments anywhere in the request body, except before the opening curly bracket. + # **Multiple matching templates** + # If multiple index templates match the name of a new index or data stream, the template with the highest priority is used. + # Multiple templates with overlapping index patterns at the same priority are not allowed and an error will be thrown when attempting to create a template matching an existing index template at identical priorities. + # **Composing aliases, mappings, and settings** + # When multiple component templates are specified in the +composed_of+ field for an index template, they are merged in the order specified, meaning that later component templates override earlier component templates. + # Any mappings, settings, or aliases from the parent index template are merged in next. + # Finally, any configuration on the index request itself is merged. + # Mapping definitions are merged recursively, which means that later mapping components can introduce new field mappings and update the mapping configuration. + # If a field mapping is already contained in an earlier component, its definition will be completely overwritten by the later one. + # This recursive merging strategy applies not only to field mappings, but also root options like +dynamic_templates+ and +meta+. + # If an earlier component contains a +dynamic_templates+ block, then by default new +dynamic_templates+ entries are appended onto the end. + # If an entry already exists with the same key, then it is overwritten by the new definition. # - # @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] :name Index or template name (*Required*) + # @option arguments [Boolean] :create If +true+, this request cannot replace or update existing index templates. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [String] :cause User defined reason for creating/updating the index template - # @option arguments [Time] :master_timeout Specify timeout for connection to master # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The template definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-index-template # def put_index_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.put_index_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -45,11 +73,11 @@ def put_index_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_index_template/#{Utils.__listify(_name)}" + path = "_index_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_mapping.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_mapping.rb index fdfb26aa63..339b61f807 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_mapping.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_mapping.rb @@ -15,44 +15,76 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Updates the index mappings. + # Update field mappings. + # Add new fields to an existing data stream or index. + # You can also use this API to change the search settings of existing fields and add new properties to existing object fields. + # For data streams, these changes are applied to all backing indices by default. + # **Add multi-fields to an existing field** + # Multi-fields let you index the same field in different ways. + # You can use this API to update the fields mapping parameter and enable multi-fields for an existing field. + # WARNING: If an index (or data stream) contains documents when you add a multi-field, those documents will not have values for the new multi-field. + # You can populate the new multi-field with the update by query API. + # **Change supported mapping parameters for an existing field** + # The documentation for each mapping parameter indicates whether you can update it for an existing field using this API. + # For example, you can use the update mapping API to update the +ignore_above+ parameter. + # **Change the mapping of an existing field** + # Except for supported mapping parameters, you can't change the mapping or field type of an existing field. + # Changing an existing field could invalidate data that's already indexed. + # If you need to change the mapping of a field in a data stream's backing indices, refer to documentation about modifying data streams. + # If you need to change the mapping of a field in other indices, create a new index with the correct mapping and reindex your data into that index. + # **Rename a field** + # Renaming a field would invalidate data already indexed under the old field name. + # Instead, add an alias field to create an alternate field name. # - # @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 Specify timeout for connection to master - # @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 [String, Array] :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. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Boolean] :write_index_only If +true+, the mappings are applied only to the current write index for the target. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The mapping definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping # def put_mapping(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.put_mapping' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_mapping" + path = "#{Utils.listify(_index)}/_mapping" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb index a5a48e4b21..9357527324 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb @@ -15,48 +15,83 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Updates the index settings. + # Update index settings. + # Changes dynamic index settings in real time. + # For data streams, index setting changes are applied to all backing indices by default. + # To revert a setting to the default value, use a null value. + # The list of per-index settings that can be updated dynamically on live indices can be found in index module documentation. + # To preserve existing settings from being updated, set the +preserve_existing+ parameter to +true+. + # NOTE: You can only define new analyzers on closed indices. + # To add an analyzer, you must close the index, define the analyzer, and reopen the index. + # You cannot close the write index of a data stream. + # To update the analyzer for a data stream's write index and future backing indices, update the analyzer in the index template used by the stream. + # Then roll over the data stream to apply the new analyzer to the stream's write index and future backing indices. + # This affects searches and any new data added to the stream after the rollover. + # However, it does not affect the data stream's backing indices or their existing data. + # To change the analyzer for existing backing indices, you must create a new data stream and reindex your data into it. # - # @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 Specify timeout for connection to master - # @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 [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit + # the request. Supports wildcards (+*+). To target all data streams and + # indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. This + # behavior applies even if the request targets other open indices. For + # example, a request targeting +foo*,bar*+ returns an error if an index + # starts with +foo+ but no index starts with +bar+. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :flat_settings If +true+, returns settings in flat format. + # @option arguments [Boolean] :ignore_unavailable If +true+, returns settings in flat format. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is + # received before the timeout expires, the request fails and returns an + # error. Server default: 30s. + # @option arguments [Boolean] :preserve_existing If +true+, existing index settings remain unchanged. + # @option arguments [Boolean] :reopen Whether to close and reopen the index to apply non-dynamic settings. + # If set to +true+ the indices to which the settings are being applied + # will be closed temporarily and then reopened in order to apply the changes. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the + # timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The index settings to be updated (*Required*) + # @option arguments [Hash] :body settings # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-settings # def put_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.put_settings' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_PUT path = if _index - "#{Utils.__listify(_index)}/_settings" + "#{Utils.listify(_index)}/_settings" else - "_settings" + '_settings' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_template.rb index cc08adb55f..c8069ff75b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_template.rb @@ -15,25 +15,50 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Creates or updates an index template. + # Create or update an index template. + # Index templates define settings, mappings, and aliases that can be applied automatically to new indices. + # Elasticsearch applies templates to new indices based on an index pattern that matches the index name. + # IMPORTANT: This documentation is about legacy index templates, which are deprecated and will be replaced by the composable templates introduced in Elasticsearch 7.8. + # Composable templates always take precedence over legacy templates. + # If no composable template matches a new index, matching legacy templates are applied according to their order. + # Index templates are only applied during index creation. + # Changes to index templates do not affect existing indices. + # Settings and mappings specified in create index API requests override any settings or mappings specified in an index template. + # You can use C-style +/* *\/+ block comments in index templates. + # You can include comments anywhere in the request body, except before the opening curly bracket. + # **Indices matching multiple templates** + # Multiple index templates can potentially match an index, in this case, both the settings and mappings are merged into the final configuration of the index. + # The order of the merging can be controlled using the order parameter, with lower order being applied first, and higher orders overriding them. + # NOTE: Multiple matching templates with the same order value will result in a non-deterministic merging order. # - # @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 Specify timeout for connection to master + # @option arguments [String] :name The name of the template (*Required*) + # @option arguments [Boolean] :create If true, this request cannot replace or update existing index templates. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is + # received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Integer] :order Order in which Elasticsearch 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 arguments [String] :cause User defined reason for creating/updating the index template # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The template definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-template # def put_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.put_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -45,11 +70,11 @@ def put_template(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_template/#{Utils.__listify(_name)}" + path = "_template/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/recovery.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/recovery.rb index 9076c02224..8734419c83 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/recovery.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/recovery.rb @@ -15,40 +15,65 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns information about ongoing index shard recoveries. + # Get index recovery information. + # Get information about ongoing and completed shard recoveries for one or more indices. + # For data streams, the API returns information for the stream's backing indices. + # All recoveries, whether ongoing or complete, are kept in the cluster state and may be reported on at any time. + # Shard recovery is the process of initializing a shard copy, such as restoring a primary shard from a snapshot or creating a replica shard from a primary shard. + # When a shard recovery completes, the recovered shard is available for search and indexing. + # Recovery automatically occurs during the following processes: + # * When creating an index for the first time. + # * When a node rejoins the cluster and starts up any missing primary shard copies using the data that it holds in its data path. + # * Creation of new replica shard copies from the primary. + # * Relocation of a shard copy to a different node in the same cluster. + # * A snapshot restore operation. + # * A clone, shrink, or split operation. + # You can determine the cause of a shard recovery using the recovery or cat recovery APIs. + # The index recovery API reports information about completed recoveries only for shard copies that currently exist in the cluster. + # It only reports the last recovery for each shard copy and does not report historical information about earlier recoveries, nor does it report information about the recoveries of shard copies that no longer exist. + # This means that if a shard copy completes a recovery and then Elasticsearch relocates it onto a different node then the information about the original recovery will not be shown in the recovery API. # - # @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 [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [Boolean] :active_only If +true+, the response only includes ongoing shard recoveries. + # @option arguments [Boolean] :detailed If +true+, the response includes detailed information about shard recoveries. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-recovery # def recovery(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.recovery' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "#{Utils.__listify(_index)}/_recovery" + "#{Utils.listify(_index)}/_recovery" else - "_recovery" + '_recovery' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/refresh.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/refresh.rb index aeb521327f..f08348c1cb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/refresh.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/refresh.rb @@ -15,41 +15,63 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Performs the refresh operation in one or more indices. + # Refresh an index. + # A refresh makes recent operations performed on one or more indices available for search. + # For data streams, the API runs the refresh operation on the stream’s backing indices. + # By default, Elasticsearch periodically refreshes indices every second, but only on indices that have received one search request or more in the last 30 seconds. + # You can change this default interval with the +index.refresh_interval+ setting. + # Refresh requests are synchronous and do not return a response until the refresh operation completes. + # Refreshes are resource-intensive. + # To ensure good cluster performance, it's recommended to wait for Elasticsearch's periodic refresh rather than performing an explicit refresh when possible. + # If your application workflow indexes documents and then runs a search to retrieve the indexed document, it's recommended to use the index API's +refresh=wait_for+ query parameter option. + # This option ensures the indexing operation waits for a periodic refresh before running the search. # - # @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 [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-refresh # def refresh(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.refresh' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_refresh" + "#{Utils.listify(_index)}/_refresh" else - "_refresh" + '_refresh' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/reload_search_analyzers.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/reload_search_analyzers.rb index 25b6f49645..8f57bf9584 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/reload_search_analyzers.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/reload_search_analyzers.rb @@ -15,40 +15,57 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Reloads an index's search analyzers and their resources. + # Reload search analyzers. + # Reload an index's search analyzers and their resources. + # For data streams, the API reloads search analyzers and resources for the stream's backing indices. + # IMPORTANT: After reloading the search analyzers you should clear the request cache to make sure it doesn't contain responses derived from the previous versions of the analyzer. + # You can use the reload search analyzers API to pick up changes to synonym files used in the +synonym_graph+ or +synonym+ token filter of a search analyzer. + # To be eligible, the token filter must have an +updateable+ flag of +true+ and only be used in search analyzers. + # NOTE: This API does not perform a reload for each shard of an index. + # Instead, it performs a reload for each node containing index shards. + # As a result, the total shard count returned by the API can differ from the number of index shards. + # Because reloading affects every node with an index shard, it is important to update the synonym file on every data node in the cluster--including nodes that don't contain a shard replica--before using this API. + # This ensures the synonym file is updated everywhere in the cluster in case shards are relocated in the future. # - # @option arguments [List] :index A comma-separated list of index names to reload analyzers for + # @option arguments [String, Array] :index A comma-separated list of index names to reload analyzers for (*Required*) + # @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, Array] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. # @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] :resource changed resource to reload analyzers from if applicable + # @option arguments [String] :resource Changed resource to reload analyzers from if applicable # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-reload-analyzers.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-reload-search-analyzers # def reload_search_analyzers(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.reload_search_analyzers' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_reload_search_analyzers" + path = "#{Utils.listify(_index)}/_reload_search_analyzers" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/resolve_cluster.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/resolve_cluster.rb new file mode 100644 index 0000000000..50dcf75310 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/resolve_cluster.rb @@ -0,0 +1,115 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Indices + module Actions + # Resolve the cluster. + # Resolve the specified index expressions to return information about each cluster, including the local "querying" cluster, if included. + # If no index expression is provided, the API will return information about all the remote clusters that are configured on the querying cluster. + # This endpoint is useful before doing a cross-cluster search in order to determine which remote clusters should be included in a search. + # You use the same index expression with this endpoint as you would for cross-cluster search. + # Index and cluster exclusions are also supported with this endpoint. + # For each cluster in the index expression, information is returned about: + # * Whether the querying ("local") cluster is currently connected to each remote cluster specified in the index expression. Note that this endpoint actively attempts to contact the remote clusters, unlike the +remote/info+ endpoint. + # * Whether each remote cluster is configured with +skip_unavailable+ as +true+ or +false+. + # * Whether there are any indices, aliases, or data streams on that cluster that match the index expression. + # * Whether the search is likely to have errors returned when you do the cross-cluster search (including any authorization errors if you do not have permission to query the index). + # * Cluster version information, including the Elasticsearch server version. + # For example, +GET /_resolve/cluster/my-index-*,cluster*:my-index-*+ returns information about the local cluster and all remotely configured clusters that start with the alias +cluster*+. + # Each cluster returns information about whether it has any indices, aliases or data streams that match +my-index-*+.The ability to query without an index expression was added in version 8.18, so when + # querying remote clusters older than that, the local cluster will send the index + # expression +dummy*+ to those remote clusters. Thus, if an errors occur, you may see a reference + # to that index expression even though you didn't request it. If it causes a problem, you can + # instead include an index expression like +*:*+ to bypass the issue.You may want to exclude a cluster or index from a search when: + # * A remote cluster is not currently connected and is configured with +skip_unavailable=false+. Running a cross-cluster search under those conditions will cause the entire search to fail. + # * A cluster has no matching indices, aliases or data streams for the index expression (or your user does not have permissions to search them). For example, suppose your index expression is +logs*,remote1:logs*+ and the remote1 cluster has no indices, aliases or data streams that match +logs*+. In that case, that cluster will return no results from that cluster if you include it in a cross-cluster search. + # * The index expression (combined with any query parameters you specify) will likely cause an exception to be thrown when you do the search. In these cases, the "error" field in the +_resolve/cluster+ response will be present. (This is also where security/permission errors will be shown.) + # * A remote cluster is an older version that does not support the feature you want to use in your search.The +remote/info+ endpoint is commonly used to test whether the "local" cluster (the cluster being queried) is connected to its remote clusters, but it does not necessarily reflect whether the remote cluster is available or not. + # The remote cluster may be available, while the local cluster is not currently connected to it. + # You can use the +_resolve/cluster+ API to attempt to reconnect to remote clusters. + # For example with +GET _resolve/cluster+ or +GET _resolve/cluster/*:*+. + # The +connected+ field in the response will indicate whether it was successful. + # If a connection was (re-)established, this will also cause the +remote/info+ endpoint to now indicate a connected status. + # + # @option arguments [String, Array] :name A comma-separated list of names or index patterns for the indices, aliases, and data streams to resolve. + # Resources on remote clusters can be specified using the ++:++ syntax. + # Index and cluster exclusions (e.g., +-cluster1:*+) are also supported. + # If no index expression is specified, information about all remote clusters configured on the local cluster + # is returned without doing any index matching + # @option arguments [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 indices. This behavior applies even if the request targets other open indices. For example, a request + # targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. + # NOTE: This option is only supported when specifying an index expression. You will get an error if you specify index + # options to the +_resolve/cluster+ API endpoint that takes no index expression. Server default: true. + # @option arguments [String, Array] :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+. + # NOTE: This option is only supported when specifying an index expression. You will get an error if you specify index + # options to the +_resolve/cluster+ API endpoint that takes no index expression. Server default: open. + # @option arguments [Boolean] :ignore_throttled If true, concrete, expanded, or aliased indices are ignored when frozen. + # NOTE: This option is only supported when specifying an index expression. You will get an error if you specify index + # options to the +_resolve/cluster+ API endpoint that takes no index expression. + # @option arguments [Boolean] :ignore_unavailable If false, the request returns an error if it targets a missing or closed index. + # NOTE: This option is only supported when specifying an index expression. You will get an error if you specify index + # options to the +_resolve/cluster+ API endpoint that takes no index expression. + # @option arguments [Time] :timeout The maximum time to wait for remote clusters to respond. + # If a remote cluster does not respond within this timeout period, the API response + # will show the cluster as not connected and include an error message that the + # request timed out.The default timeout is unset and the query can take + # as long as the networking layer is configured to wait for remote clusters that are + # not responding (typically 30 seconds). + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-resolve-cluster + # + def resolve_cluster(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.resolve_cluster' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _name = arguments.delete(:name) + + method = Elasticsearch::API::HTTP_GET + path = if _name + "_resolve/cluster/#{Utils.listify(_name)}" + else + '_resolve/cluster' + end + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/resolve_index.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/resolve_index.rb index 71a0f80cd1..2e0331a3f3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/resolve_index.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/resolve_index.rb @@ -15,22 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Returns information about any matching indices, aliases, and data streams + # Resolve indices. + # Resolve the names and/or index patterns for indices, aliases, and data streams. + # Multiple patterns and remote clusters are supported. # - # @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 [String, Array] :name Comma-separated name(s) or index pattern(s) of the indices, aliases, and data streams to resolve. + # Resources on remote clusters can be specified using the ++:++ syntax. (*Required*) + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-resolve-index-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-resolve-index # def resolve_index(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.resolve_index' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -41,11 +58,11 @@ def resolve_index(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_GET - path = "_resolve/index/#{Utils.__listify(_name)}" + path = "_resolve/index/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb index aac93fbb27..720fbd318a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb @@ -15,34 +15,72 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Updates an alias to point to a new index when the existing index - # is considered to be too large or too old. + # Roll over to a new index. + # TIP: It is recommended to use the index lifecycle rollover action to automate rollovers. + # The rollover API creates a new index for a data stream or index alias. + # The API behavior depends on the rollover target. + # **Roll over a data stream** + # If you roll over a data stream, the API creates a new write index for the stream. + # The stream's previous write index becomes a regular backing index. + # A rollover also increments the data stream's generation. + # **Roll over an index alias with a write index** + # TIP: Prior to Elasticsearch 7.9, you'd typically use an index alias with a write index to manage time series data. + # Data streams replace this functionality, require less maintenance, and automatically integrate with data tiers. + # If an index alias points to multiple indices, one of the indices must be a write index. + # The rollover API creates a new write index for the alias with +is_write_index+ set to +true+. + # The API also +sets is_write_index+ to +false+ for the previous write index. + # **Roll over an index alias with one index** + # If you roll over an index alias that points to only one index, the API creates a new index for the alias and removes the original index from the alias. + # NOTE: A rollover creates a new index and is subject to the +wait_for_active_shards+ setting. + # **Increment index names for an alias** + # When you roll over an index alias, you can specify a name for the new index. + # If you don't specify a name and the current index ends with +-+ and a number, such as +my-index-000001+ or +my-index-3+, the new index name increments that number. + # For example, if you roll over an alias with a current index of +my-index-000001+, the rollover creates a new index named +my-index-000002+. + # This number is always six characters and zero-padded, regardless of the previous index's name. + # If you use an index alias for time series data, you can use date math in the index name to track the rollover date. + # For example, you can create an alias that points to an index named ++. + # If you create the index on May 6, 2099, the index's name is +my-index-2099.05.06-000001+. + # If you roll over the alias on May 7, 2099, the new index's name is +my-index-2099.05.07-000002+. # - # @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 Specify timeout for connection to master - # @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 [String] :alias Name of the data stream or index alias to roll over. (*Required*) + # @option arguments [String] :new_index Name of the index to create. + # Supports date math. + # Data streams do not support this parameter. + # @option arguments [Boolean] :dry_run If +true+, checks whether the current index satisfies the specified conditions but does not perform a rollover. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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+). Server default: 1. + # @option arguments [Boolean] :lazy If set to true, the rollover action will only mark a data stream to signal that it needs to be rolled over at the next write. + # Only allowed on data streams. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The conditions that needs to be met for executing rollover + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-rollover # def rollover(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.rollover' } + + defined_params = [:alias, :new_index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'alias' missing" unless arguments[:alias] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _alias = arguments.delete(:alias) @@ -50,14 +88,14 @@ def rollover(arguments = {}) method = Elasticsearch::API::HTTP_POST path = if _alias && _new_index - "#{Utils.__listify(_alias)}/_rollover/#{Utils.__listify(_new_index)}" + "#{Utils.listify(_alias)}/_rollover/#{Utils.listify(_new_index)}" else - "#{Utils.__listify(_alias)}/_rollover" + "#{Utils.listify(_alias)}/_rollover" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/segments.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/segments.rb index 0f5505852c..33719cd46f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/segments.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/segments.rb @@ -15,42 +15,56 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Provides low-level information about segments in a Lucene index. + # Get index segments. + # Get low-level information about the Lucene segments in index shards. + # For data streams, the API returns information about the stream's backing 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 [Boolean] :verbose Includes detailed memory usage by Lucene. *Deprecated* + # @option arguments [String, Array] :index Comma-separated list of data streams, indices, and aliases used to limit the request. + # Supports wildcards (+*+). + # To target all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-segments.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-segments # def segments(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.segments' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "#{Utils.__listify(_index)}/_segments" + "#{Utils.listify(_index)}/_segments" else - "_segments" + '_segments' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/shard_stores.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/shard_stores.rb index 62f4848579..14d4ee9cb3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/shard_stores.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/shard_stores.rb @@ -15,42 +15,60 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Provides store information for shard copies of indices. + # Get index shard stores. + # Get store information about replica shards in one or more indices. + # For data streams, the API retrieves store information for the stream's backing indices. + # The index shard stores API returns the following information: + # * The node on which each replica shard exists. + # * The allocation ID for each replica shard. + # * A unique ID for each replica shard. + # * Any errors encountered while opening the shard index or from an earlier failure. + # By default, the API returns store information only for primary shards that are unassigned or have one or more unassigned replica shards. # - # @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 [String, Array] :index List of data streams, indices, and aliases used to limit the request. + # @option arguments [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 indices. This behavior applies even if the request + # targets other open indices. + # @option arguments [String, Array] :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. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If true, missing or closed indices are not included in the response. + # @option arguments [Shardstorestatus] :status List of shard health statuses used to limit the request. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shards-stores.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-shard-stores # def shard_stores(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.shard_stores' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "#{Utils.__listify(_index)}/_shard_stores" + "#{Utils.listify(_index)}/_shard_stores" else - "_shard_stores" + '_shard_stores' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb index 2fbb9c91a3..2df762cdf1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/shrink.rb @@ -15,44 +15,76 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Allow to shrink an existing index into a new index with fewer primary shards. + # Shrink an index. + # Shrink an index into a new index with fewer primary shards. + # Before you can shrink an index: + # * The index must be read-only. + # * A copy of every shard in the index must reside on the same node. + # * The index must have a green health status. + # To make shard allocation easier, we recommend you also remove the index's replica shards. + # You can later re-add replica shards as part of the shrink operation. + # The requested number of primary shards in the target index must be a factor of the number of shards in the source index. + # For example an index with 8 primary shards can be shrunk into 4, 2 or 1 primary shards or an index with 15 primary shards can be shrunk into 5, 3 or 1. + # If the number of shards in the index is a prime number it can only be shrunk into a single primary shard + # Before shrinking, a (primary or replica) copy of every shard in the index must be present on the same node. + # The current write index on a data stream cannot be shrunk. In order to shrink the current write index, the data stream must first be rolled over so that a new write index is created and then the previous write index can be shrunk. + # A shrink operation: + # * Creates a new target index with the same definition as the source index, but with a smaller number of primary shards. + # * Hard-links segments from the source index into the target index. If the file system does not support hard-linking, then all segments are copied into the new index, which is a much more time consuming process. Also if using multiple data paths, shards on different data paths require a full copy of segment files if they are not on the same disk since hardlinks do not work across disks. + # * Recovers the target index as though it were a closed index which had just been re-opened. Recovers shards to the +.routing.allocation.initial_recovery._id+ index setting. + # IMPORTANT: Indices can only be shrunk if they satisfy the following requirements: + # * The target index must not exist. + # * The source index must have more primary shards than the target index. + # * The number of primary shards in the target index must be a factor of the number of primary shards in the source index. The source index must have more primary shards than the target index. + # * The index must not contain more than 2,147,483,519 documents in total across all shards that will be shrunk into a single shard on the target index as this is the maximum number of docs that can fit into a single shard. + # * The node handling the shrink process must have sufficient free disk space to accommodate a second copy of the existing index. # - # @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 [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master - # @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 [String] :index Name of the source index to shrink. (*Required*) + # @option arguments [String] :target Name of the target index to create. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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+). Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-shrink # def shrink(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.shrink' } + + defined_params = [:index, :target].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) _target = arguments.delete(:target) method = Elasticsearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_shrink/#{Utils.__listify(_target)}" + path = "#{Utils.listify(_index)}/_shrink/#{Utils.listify(_target)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_index_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_index_template.rb index 60b1ff6373..ab59e70b81 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_index_template.rb @@ -15,41 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Simulate matching the given index name against the index templates in the system + # Simulate an index. + # Get the index configuration that would be applied to the specified index from an existing index template. # - # @option arguments [String] :name The name of the index (it must be a concrete index name) + # @option arguments [String] :name Name of the index to simulate (*Required*) # @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 Specify timeout for connection to master - # @option arguments [Boolean] :include_defaults Return all relevant default configurations for this index template simulation (default: false) + # @option arguments [String] :cause User defined reason for dry-run creating the new template for simulation purposes Server default: false. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Boolean] :include_defaults If true, returns all relevant default configurations for the index template. # @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 # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-simulate-index-template # def simulate_index_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.simulate_index_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = nil _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_POST - path = "_index_template/_simulate_index/#{Utils.__listify(_name)}" + path = "_index_template/_simulate_index/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_template.rb index c581f77ba0..76b4953c60 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_template.rb @@ -15,26 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Simulate resolving the given template name or body + # Simulate an index template. + # Get the index configuration that would be applied by a particular index template. # - # @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] :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 arguments [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 arguments [String] :cause User defined reason for dry-run creating the new template for simulation purposes - # @option arguments [Time] :master_timeout Specify timeout for connection to master - # @option arguments [Boolean] :include_defaults Return all relevant default configurations for this template simulation (default: false) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Boolean] :include_defaults If true, returns all relevant default configurations for the index template. # @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 + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-simulate-template # def simulate_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.simulate_template' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -44,14 +53,14 @@ def simulate_template(arguments = {}) method = Elasticsearch::API::HTTP_POST path = if _name - "_index_template/_simulate/#{Utils.__listify(_name)}" + "_index_template/_simulate/#{Utils.listify(_name)}" else - "_index_template/_simulate" + '_index_template/_simulate' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/split.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/split.rb index 1c6d3e3ff7..121ea50c0b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/split.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/split.rb @@ -15,44 +15,77 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Allows you to split an existing index into a new index with more primary shards. + # Split an index. + # Split an index into a new index with more primary shards. + # * Before you can split an index: + # * The index must be read-only. + # * The cluster health status must be green. + # You can do make an index read-only with the following request using the add index block API: + # + + # PUT /my_source_index/_block/write + # + + # The current write index on a data stream cannot be split. + # In order to split the current write index, the data stream must first be rolled over so that a new write index is created and then the previous write index can be split. + # The number of times the index can be split (and the number of shards that each original shard can be split into) is determined by the +index.number_of_routing_shards+ setting. + # The number of routing shards specifies the hashing space that is used internally to distribute documents across shards with consistent hashing. + # For instance, a 5 shard index with +number_of_routing_shards+ set to 30 (5 x 2 x 3) could be split by a factor of 2 or 3. + # A split operation: + # * Creates a new target index with the same definition as the source index, but with a larger number of primary shards. + # * Hard-links segments from the source index into the target index. If the file system doesn't support hard-linking, all segments are copied into the new index, which is a much more time consuming process. + # * Hashes all documents again, after low level files are created, to delete documents that belong to a different shard. + # * Recovers the target index as though it were a closed index which had just been re-opened. + # IMPORTANT: Indices can only be split if they satisfy the following requirements: + # * The target index must not exist. + # * The source index must have fewer primary shards than the target index. + # * The number of primary shards in the target index must be a multiple of the number of primary shards in the source index. + # * The node handling the split process must have sufficient free disk space to accommodate a second copy of the existing index. # - # @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 [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master - # @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 [String] :index Name of the source index to split. (*Required*) + # @option arguments [String] :target Name of the target index to create. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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+). Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-split-index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-split # def split(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.split' } + + defined_params = [:index, :target].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'target' missing" unless arguments[:target] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) _target = arguments.delete(:target) method = Elasticsearch::API::HTTP_PUT - path = "#{Utils.__listify(_index)}/_split/#{Utils.__listify(_target)}" + path = "#{Utils.listify(_index)}/_split/#{Utils.listify(_target)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/stats.rb index 1c8c3387c8..056b022fda 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/stats.rb @@ -15,31 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Provides statistics on operations happening in an index. + # Get index statistics. + # For data streams, the API retrieves statistics for the stream's backing indices. + # By default, the returned statistics are index-level with +primaries+ and +total+ aggregations. + # +primaries+ are the values for only the primary shards. + # +total+ are the accumulated values for both primary and replica shards. + # To get shard-level statistics, set the +level+ parameter to +shards+. + # NOTE: When moving to another node, the shard-level statistics for a shard are cleared. + # Although the shard is no longer part of the node, that node retains any node-level statistics to which the shard contributed. # - # @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, bulk) - # @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 the `completion` index metric (supports wildcards) - # @option arguments [List] :fielddata_fields A comma-separated list of fields for the `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 [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 [String, Array] :metric Limit the information returned the specific metrics. + # @option arguments [String, Array] :index A comma-separated list of index names; use +_all+ or empty string to perform the operation on all indices + # @option arguments [String, Array] :completion_fields Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. + # @option arguments [String, Array] :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 arguments [String, Array] :fielddata_fields Comma-separated list or wildcard expressions of fields to include in fielddata statistics. + # @option arguments [String, Array] :fields Comma-separated list or wildcard expressions of fields to include in the statistics. + # @option arguments [Boolean] :forbid_closed_indices If true, statistics are not collected from closed indices. Server default: true. + # @option arguments [String] :groups Comma-separated list of search groups to include in the search statistics. + # @option arguments [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 arguments [Boolean] :include_unloaded_segments If true, the response includes information from segments that are not loaded into memory. + # @option arguments [String] :level Indicates whether statistics are aggregated at the cluster, index, or shard level. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-stats # def stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.stats' } + + defined_params = [:metric, :index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -51,18 +67,18 @@ def stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _index && _metric - "#{Utils.__listify(_index)}/_stats/#{Utils.__listify(_metric)}" + "#{Utils.listify(_index)}/_stats/#{Utils.listify(_metric)}" elsif _metric - "_stats/#{Utils.__listify(_metric)}" + "_stats/#{Utils.listify(_metric)}" elsif _index - "#{Utils.__listify(_index)}/_stats" + "#{Utils.listify(_index)}/_stats" else - "_stats" + '_stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/unfreeze.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/unfreeze.rb deleted file mode 100644 index def6fb41f1..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/unfreeze.rb +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Indices - module Actions - # Unfreezes an index. When a frozen index is unfrozen, the index goes through the normal recovery process and becomes writeable again. - # - # @option arguments [String] :index The name of the index to unfreeze - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master - # @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 - # - # *Deprecation notice*: - # Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release. - # Deprecated since version 7.14.0 - # - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/unfreeze-index-api.html - # - def unfreeze(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _index = arguments.delete(:index) - - method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_unfreeze" - params = Utils.process_params(arguments) - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/update_aliases.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/update_aliases.rb index 2b7dba3775..a34de394a2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/update_aliases.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/update_aliases.rb @@ -15,36 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Updates index aliases. + # Create or update an alias. + # Adds a data stream or index to an alias. # - # @option arguments [Time] :timeout Request timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The definition of `actions` to perform (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-update-aliases # def update_aliases(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.update_aliases' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_aliases" + path = '_aliases' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb index ce7eed2869..7e7fd81ac6 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/validate_query.rb @@ -15,38 +15,54 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Indices module Actions - # Allows a user to validate a potentially expensive query without executing it. + # Validate a query. + # Validates a query without running 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 [String, Array] :index Comma-separated list of data streams, indices, and aliases to search. + # Supports wildcards (+*+). + # To search all data streams or indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. Server default: true. + # @option arguments [Boolean] :all_shards If +true+, the validation is executed on all shards instead of one random shard per index. + # @option arguments [String] :analyzer Analyzer to use for the query string. + # This parameter can only be used when the +q+ query string parameter is specified. + # @option arguments [Boolean] :analyze_wildcard If +true+, wildcard and prefix queries are analyzed. + # @option arguments [String] :default_operator The default operator for query string query: +AND+ or +OR+. Server default: OR. + # @option arguments [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 arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :explain If +true+, the response returns detailed information if an error has occurred. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :lenient If +true+, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. + # @option arguments [Boolean] :rewrite If +true+, returns a more detailed explanation showing the actual Lucene query that will be executed. + # @option arguments [String] :q Query in the Lucene query string syntax. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The query definition specified with the Query DSL + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-validate.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-validate-query # def validate_query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'indices.validate_query' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -57,14 +73,14 @@ def validate_query(arguments = {}) end path = if _index - "#{Utils.__listify(_index)}/_validate/query" + "#{Utils.listify(_index)}/_validate/query" else - "_validate/query" + '_validate/query' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/chat_completion_unified.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/chat_completion_unified.rb new file mode 100644 index 0000000000..03c56cd213 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/chat_completion_unified.rb @@ -0,0 +1,63 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Perform chat completion inference + # + # @option arguments [String] :inference_id The inference Id (*Required*) + # @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body chat_completion_request + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-unified-inference + # + def chat_completion_unified(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.chat_completion_unified' } + + defined_params = [:inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_POST + path = "_inference/chat_completion/#{Utils.listify(_inference_id)}/_stream" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/completion.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/completion.rb new file mode 100644 index 0000000000..a59e3a440e --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/completion.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Perform completion inference on the service + # + # @option arguments [String] :inference_id The inference Id (*Required*) + # @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-inference + # + def completion(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.completion' } + + defined_params = [:inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_POST + path = "_inference/completion/#{Utils.listify(_inference_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/delete.rb new file mode 100644 index 0000000000..fe9e9485b8 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/delete.rb @@ -0,0 +1,69 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Delete an inference endpoint + # + # @option arguments [String] :task_type The task type + # @option arguments [String] :inference_id The inference identifier. (*Required*) + # @option arguments [Boolean] :dry_run When true, the endpoint is not deleted and a list of ingest processors which reference this endpoint is returned. + # @option arguments [Boolean] :force When true, the inference endpoint is forcefully deleted even if it is still being used by ingest processors or semantic text fields. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-delete + # + def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.delete' } + + defined_params = [:inference_id, :task_type].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _task_type = arguments.delete(:task_type) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_DELETE + path = if _task_type && _inference_id + "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}" + else + "_inference/#{Utils.listify(_inference_id)}" + end + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/get.rb new file mode 100644 index 0000000000..0e6651ab15 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/get.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Get an inference endpoint + # + # @option arguments [String] :task_type The task type + # @option arguments [String] :inference_id The inference Id + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-get + # + def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.get' } + + defined_params = [:inference_id, :task_type].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _task_type = arguments.delete(:task_type) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_GET + path = if _task_type && _inference_id + "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}" + elsif _inference_id + "_inference/#{Utils.listify(_inference_id)}" + else + '_inference' + end + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb new file mode 100644 index 0000000000..83959aa4c1 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb @@ -0,0 +1,73 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Perform inference on the service. + # This API enables you to use machine learning models to perform specific tasks on data that you provide as an input. + # It returns a response with the results of the tasks. + # The inference endpoint you use can perform one specific task that has been defined when the endpoint was created with the create inference API. + # For details about using this API with a service, such as Amazon Bedrock, Anthropic, or HuggingFace, refer to the service-specific documentation. + # + # @option arguments [String] :task_type The type of inference task that the model performs. + # @option arguments [String] :inference_id The unique identifier for the inference endpoint. (*Required*) + # @option arguments [Time] :timeout The amount of time to wait for the inference request to complete. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-inference + # + def inference(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.inference' } + + defined_params = [:inference_id, :task_type].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_POST + path = if _task_type && _inference_id + "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}" + else + "_inference/#{Utils.listify(_inference_id)}" + end + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put.rb new file mode 100644 index 0000000000..979e40cd03 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put.rb @@ -0,0 +1,77 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an inference endpoint. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Mistral, Azure OpenAI, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face. + # For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models. + # However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs. + # + # @option arguments [String] :task_type The task type + # @option arguments [String] :inference_id The inference Id (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body inference_config + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put + # + def put(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put' } + + defined_params = [:inference_id, :task_type].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = if _task_type && _inference_id + "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}" + else + "_inference/#{Utils.listify(_inference_id)}" + end + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb new file mode 100644 index 0000000000..6622c6a839 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb @@ -0,0 +1,75 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an AlibabaCloud AI Search inference endpoint. + # Create an inference endpoint to perform an inference task with the +alibabacloud-ai-search+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :alibabacloud_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-alibabacloud + # + def put_alibabacloud(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_alibabacloud' } + + defined_params = [:task_type, :alibabacloud_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:alibabacloud_inference_id] + raise ArgumentError, + "Required argument 'alibabacloud_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _alibabacloud_inference_id = arguments.delete(:alibabacloud_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_alibabacloud_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb new file mode 100644 index 0000000000..fe507d2147 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb @@ -0,0 +1,70 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an Amazon Bedrock inference endpoint. + # Creates an inference endpoint to perform an inference task with the +amazonbedrock+ service. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :amazonbedrock_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-amazonbedrock + # + def put_amazonbedrock(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_amazonbedrock' } + + defined_params = [:task_type, :amazonbedrock_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:amazonbedrock_inference_id] + raise ArgumentError, + "Required argument 'amazonbedrock_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _amazonbedrock_inference_id = arguments.delete(:amazonbedrock_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_amazonbedrock_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb new file mode 100644 index 0000000000..57b4078bb9 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb @@ -0,0 +1,76 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an Anthropic inference endpoint. + # Create an inference endpoint to perform an inference task with the +anthropic+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The task type. + # The only valid task type for the model to perform is +completion+. (*Required*) + # @option arguments [String] :anthropic_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-anthropic + # + def put_anthropic(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_anthropic' } + + defined_params = [:task_type, :anthropic_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:anthropic_inference_id] + raise ArgumentError, + "Required argument 'anthropic_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _anthropic_inference_id = arguments.delete(:anthropic_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_anthropic_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb new file mode 100644 index 0000000000..e28ea8a7f7 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb @@ -0,0 +1,75 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an Azure AI studio inference endpoint. + # Create an inference endpoint to perform an inference task with the +azureaistudio+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :azureaistudio_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-azureaistudio + # + def put_azureaistudio(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_azureaistudio' } + + defined_params = [:task_type, :azureaistudio_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:azureaistudio_inference_id] + raise ArgumentError, + "Required argument 'azureaistudio_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _azureaistudio_inference_id = arguments.delete(:azureaistudio_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_azureaistudio_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb new file mode 100644 index 0000000000..d2043dcb1e --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb @@ -0,0 +1,80 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an Azure OpenAI inference endpoint. + # Create an inference endpoint to perform an inference task with the +azureopenai+ service. + # The list of chat completion models that you can choose from in your Azure OpenAI deployment include: + # * {https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#gpt-4-and-gpt-4-turbo-models GPT-4 and GPT-4 Turbo models} + # * {https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#gpt-35 GPT-3.5} + # The list of embeddings models that you can choose from in your deployment can be found in the {https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#embeddings Azure models documentation}. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. + # NOTE: The +chat_completion+ task type only supports streaming and only through the _stream API. (*Required*) + # @option arguments [String] :azureopenai_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-azureopenai + # + def put_azureopenai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_azureopenai' } + + defined_params = [:task_type, :azureopenai_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:azureopenai_inference_id] + raise ArgumentError, + "Required argument 'azureopenai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _azureopenai_inference_id = arguments.delete(:azureopenai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_azureopenai_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb new file mode 100644 index 0000000000..b9fff487e6 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb @@ -0,0 +1,75 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create a Cohere inference endpoint. + # Create an inference endpoint to perform an inference task with the +cohere+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :cohere_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-cohere + # + def put_cohere(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_cohere' } + + defined_params = [:task_type, :cohere_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:cohere_inference_id] + raise ArgumentError, + "Required argument 'cohere_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _cohere_inference_id = arguments.delete(:cohere_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_cohere_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb new file mode 100644 index 0000000000..7a966ef3a2 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb @@ -0,0 +1,71 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an Elasticsearch inference endpoint. + # Create an inference endpoint to perform an inference task with the +elasticsearch+ service. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :elasticsearch_inference_id The unique identifier of the inference endpoint. + # The must not match the +model_id+. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-elasticsearch + # + def put_elasticsearch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_elasticsearch' } + + defined_params = [:task_type, :elasticsearch_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:elasticsearch_inference_id] + raise ArgumentError, + "Required argument 'elasticsearch_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _elasticsearch_inference_id = arguments.delete(:elasticsearch_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_elasticsearch_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb new file mode 100644 index 0000000000..16e6e80bb3 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an ELSER inference endpoint. + # Create an inference endpoint to perform an inference task with the +elser+ service. + # You can also deploy ELSER by using the Elasticsearch inference integration. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :elser_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-elser + # + def put_elser(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_elser' } + + defined_params = [:task_type, :elser_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + raise ArgumentError, "Required argument 'elser_inference_id' missing" unless arguments[:elser_inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _elser_inference_id = arguments.delete(:elser_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_elser_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb new file mode 100644 index 0000000000..31f9d0f3ad --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb @@ -0,0 +1,75 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an Google AI Studio inference endpoint. + # Create an inference endpoint to perform an inference task with the +googleaistudio+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :googleaistudio_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-googleaistudio + # + def put_googleaistudio(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_googleaistudio' } + + defined_params = [:task_type, :googleaistudio_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:googleaistudio_inference_id] + raise ArgumentError, + "Required argument 'googleaistudio_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _googleaistudio_inference_id = arguments.delete(:googleaistudio_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_googleaistudio_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb new file mode 100644 index 0000000000..c3d8f45bf7 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb @@ -0,0 +1,75 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create a Google Vertex AI inference endpoint. + # Create an inference endpoint to perform an inference task with the +googlevertexai+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :googlevertexai_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-googlevertexai + # + def put_googlevertexai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_googlevertexai' } + + defined_params = [:task_type, :googlevertexai_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:googlevertexai_inference_id] + raise ArgumentError, + "Required argument 'googlevertexai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _googlevertexai_inference_id = arguments.delete(:googlevertexai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_googlevertexai_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb new file mode 100644 index 0000000000..75d0f80753 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb @@ -0,0 +1,86 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create a Hugging Face inference endpoint. + # Create an inference endpoint to perform an inference task with the +hugging_face+ service. + # You must first create an inference endpoint on the Hugging Face endpoint page to get an endpoint URL. + # Select the model you want to use on the new endpoint creation page (for example +intfloat/e5-small-v2+), then select the sentence embeddings task under the advanced configuration section. + # Create the endpoint and copy the URL after the endpoint initialization has been finished. + # The following models are recommended for the Hugging Face service: + # * +all-MiniLM-L6-v2+ + # * +all-MiniLM-L12-v2+ + # * +all-mpnet-base-v2+ + # * +e5-base-v2+ + # * +e5-small-v2+ + # * +multilingual-e5-base+ + # * +multilingual-e5-small+ + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :huggingface_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-hugging-face + # + def put_hugging_face(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_hugging_face' } + + defined_params = [:task_type, :huggingface_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:huggingface_inference_id] + raise ArgumentError, + "Required argument 'huggingface_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _huggingface_inference_id = arguments.delete(:huggingface_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_huggingface_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb new file mode 100644 index 0000000000..a8f63c0e99 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb @@ -0,0 +1,77 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an JinaAI inference endpoint. + # Create an inference endpoint to perform an inference task with the +jinaai+ service. + # To review the available +rerank+ models, refer to . + # To review the available +text_embedding+ models, refer to the . + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :jinaai_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-jinaai + # + def put_jinaai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_jinaai' } + + defined_params = [:task_type, :jinaai_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:jinaai_inference_id] + raise ArgumentError, + "Required argument 'jinaai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _jinaai_inference_id = arguments.delete(:jinaai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_jinaai_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb new file mode 100644 index 0000000000..dbdb9d1f06 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb @@ -0,0 +1,76 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create a Mistral inference endpoint. + # Creates an inference endpoint to perform an inference task with the +mistral+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The task type. + # The only valid task type for the model to perform is +text_embedding+. (*Required*) + # @option arguments [String] :mistral_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-mistral + # + def put_mistral(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_mistral' } + + defined_params = [:task_type, :mistral_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:mistral_inference_id] + raise ArgumentError, + "Required argument 'mistral_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _mistral_inference_id = arguments.delete(:mistral_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_mistral_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb new file mode 100644 index 0000000000..c5a338f91b --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb @@ -0,0 +1,76 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create an OpenAI inference endpoint. + # Create an inference endpoint to perform an inference task with the +openai+ service or +openai+ compatible APIs. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. + # NOTE: The +chat_completion+ task type only supports streaming and only through the _stream API. (*Required*) + # @option arguments [String] :openai_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-openai + # + def put_openai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_openai' } + + defined_params = [:task_type, :openai_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:openai_inference_id] + raise ArgumentError, + "Required argument 'openai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _openai_inference_id = arguments.delete(:openai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_openai_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb new file mode 100644 index 0000000000..1143543838 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb @@ -0,0 +1,71 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create a VoyageAI inference endpoint. + # Create an inference endpoint to perform an inference task with the +voyageai+ service. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :voyageai_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-voyageai + # + def put_voyageai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_voyageai' } + + defined_params = [:task_type, :voyageai_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:voyageai_inference_id] + raise ArgumentError, + "Required argument 'voyageai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _voyageai_inference_id = arguments.delete(:voyageai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_voyageai_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_watsonx.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_watsonx.rb new file mode 100644 index 0000000000..1e8c20ab24 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_watsonx.rb @@ -0,0 +1,78 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create a Watsonx inference endpoint. + # Create an inference endpoint to perform an inference task with the +watsonxai+ service. + # You need an IBM Cloud Databases for Elasticsearch deployment to use the +watsonxai+ inference service. + # You can provision one through the IBM catalog, the Cloud Databases CLI plug-in, the Cloud Databases API, or Terraform. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The task type. + # The only valid task type for the model to perform is +text_embedding+. (*Required*) + # @option arguments [String] :watsonx_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-watsonx + # + def put_watsonx(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_watsonx' } + + defined_params = [:task_type, :watsonx_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:watsonx_inference_id] + raise ArgumentError, + "Required argument 'watsonx_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _watsonx_inference_id = arguments.delete(:watsonx_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_watsonx_inference_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/rerank.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/rerank.rb new file mode 100644 index 0000000000..eed8aa6e27 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/rerank.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Perform rereanking inference on the service + # + # @option arguments [String] :inference_id The unique identifier for the inference endpoint. (*Required*) + # @option arguments [Time] :timeout The amount of time to wait for the inference request to complete. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-inference + # + def rerank(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.rerank' } + + defined_params = [:inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_POST + path = "_inference/rerank/#{Utils.listify(_inference_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/sparse_embedding.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/sparse_embedding.rb new file mode 100644 index 0000000000..4370846956 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/sparse_embedding.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Perform sparse embedding inference on the service + # + # @option arguments [String] :inference_id The inference Id (*Required*) + # @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-inference + # + def sparse_embedding(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.sparse_embedding' } + + defined_params = [:inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_POST + path = "_inference/sparse_embedding/#{Utils.listify(_inference_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/stream_completion.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/stream_completion.rb new file mode 100644 index 0000000000..dd3d03d63d --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/stream_completion.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Perform streaming inference. + # Get real-time responses for completion tasks by delivering answers incrementally, reducing response times during computation. + # This API works only with the completion task type. + # IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Azure, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face. For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models. However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs. + # This API requires the +monitor_inference+ cluster privilege (the built-in +inference_admin+ and +inference_user+ roles grant this privilege). You must use a client that supports streaming. + # + # @option arguments [String] :inference_id The unique identifier for the inference endpoint. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-stream-inference + # + def stream_completion(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.stream_completion' } + + defined_params = [:inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_POST + path = "_inference/completion/#{Utils.listify(_inference_id)}/_stream" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/text_embedding.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/text_embedding.rb new file mode 100644 index 0000000000..70741d5fa0 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/text_embedding.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Perform text embedding inference on the service + # + # @option arguments [String] :inference_id The inference Id (*Required*) + # @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-inference + # + def text_embedding(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.text_embedding' } + + defined_params = [:inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _inference_id = arguments.delete(:inference_id) + + method = Elasticsearch::API::HTTP_POST + path = "_inference/text_embedding/#{Utils.listify(_inference_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/update.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/update.rb new file mode 100644 index 0000000000..76a0ffe88b --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/update.rb @@ -0,0 +1,73 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Update an inference endpoint. + # Modify +task_settings+, secrets (within +service_settings+), or +num_allocations+ for an inference endpoint, depending on the specific endpoint service and +task_type+. + # IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Azure, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face. + # For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models. + # However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs. + # + # @option arguments [String] :inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [String] :task_type The type of inference task that the model performs. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body inference_config + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-update + # + def update(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.update' } + + defined_params = [:inference_id, :task_type].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _inference_id = arguments.delete(:inference_id) + + _task_type = arguments.delete(:task_type) + + method = Elasticsearch::API::HTTP_PUT + path = if _task_type && _inference_id + "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}/_update" + else + "_inference/#{Utils.listify(_inference_id)}/_update" + end + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/info.rb index d199a17277..0b671f74d4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/info.rb @@ -15,30 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns basic information about the cluster. + # Get cluster info. + # Get basic build, version, and cluster information. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-info # def info(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'info' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "" + path = '' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_geoip_database.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_geoip_database.rb new file mode 100644 index 0000000000..13afc23af5 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_geoip_database.rb @@ -0,0 +1,64 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Ingest + module Actions + # Delete GeoIP database configurations. + # Delete one or more IP geolocation database configurations. + # + # @option arguments [String, Array] :id A comma-separated list of geoip database configurations to delete (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-delete-geoip-database + # + def delete_geoip_database(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.delete_geoip_database' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_ingest/geoip/database/#{Utils.listify(_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_ip_location_database.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_ip_location_database.rb new file mode 100644 index 0000000000..572ce52327 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_ip_location_database.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Ingest + module Actions + # Delete IP geolocation database configurations. + # + # @option arguments [String, Array] :id A comma-separated list of IP location database configurations. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # A value of +-1+ indicates that the request should never time out. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. + # A value of +-1+ indicates that the request should never time out. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-delete-ip-location-database + # + def delete_ip_location_database(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.delete_ip_location_database' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_ingest/ip_location/database/#{Utils.listify(_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb index 4c653ec284..310cb3b0a9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb @@ -15,23 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Ingest module Actions - # Deletes a pipeline. + # Delete pipelines. + # Delete one or more ingest pipelines. # - # @option arguments [String] :id Pipeline ID - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [String] :id 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 +*+. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-pipeline-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-delete-pipeline # def delete_pipeline(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.delete_pipeline' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -42,11 +53,11 @@ def delete_pipeline(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE - path = "_ingest/pipeline/#{Utils.__listify(_id)}" + path = "_ingest/pipeline/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/geo_ip_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/geo_ip_stats.rb index 15ab98e64a..0e0e3beab8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/geo_ip_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/geo_ip_stats.rb @@ -15,31 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Ingest module Actions - # Returns statistical information about geoip databases + # Get GeoIP statistics. + # Get download statistics for GeoIP2 databases that are used with the GeoIP processor. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/geoip-stats-api.html + # @see https://www.elastic.co/docs/reference/enrich-processor/geoip-processor # def geo_ip_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.geo_ip_stats' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_ingest/geoip/stats" + path = '_ingest/geoip/stats' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_geoip_database.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_geoip_database.rb new file mode 100644 index 0000000000..6094f39a00 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_geoip_database.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Ingest + module Actions + # Get GeoIP database configurations. + # Get information about one or more IP geolocation database configurations. + # + # @option arguments [String, Array] :id A comma-separated list of database configuration IDs to retrieve. + # Wildcard (+*+) expressions are supported. + # To get all database configurations, omit this parameter or use +*+. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-get-geoip-database + # + def get_geoip_database(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.get_geoip_database' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_GET + path = if _id + "_ingest/geoip/database/#{Utils.listify(_id)}" + else + '_ingest/geoip/database' + end + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_ip_location_database.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_ip_location_database.rb new file mode 100644 index 0000000000..bbaaca5404 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_ip_location_database.rb @@ -0,0 +1,67 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Ingest + module Actions + # Get IP geolocation database configurations. + # + # @option arguments [String, Array] :id Comma-separated list of database configuration IDs to retrieve. + # Wildcard (+*+) expressions are supported. + # To get all database configurations, omit this parameter or use +*+. + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # A value of +-1+ indicates that the request should never time out. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-get-ip-location-database + # + def get_ip_location_database(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.get_ip_location_database' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_GET + path = if _id + "_ingest/ip_location/database/#{Utils.listify(_id)}" + else + '_ingest/ip_location/database' + end + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_pipeline.rb index 400c3ea593..48a86d8001 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/get_pipeline.rb @@ -15,23 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Ingest module Actions - # Returns a pipeline. + # Get pipelines. + # Get information about one or more ingest pipelines. + # This API returns a local reference of the pipeline. # - # @option arguments [String] :id Comma separated list of pipeline ids. Wildcards supported + # @option arguments [String] :id Comma-separated list of pipeline IDs to retrieve. + # Wildcard (+*+) expressions are supported. + # To get all ingest pipelines, omit this parameter or use +*+. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Boolean] :summary Return pipelines without their definitions (default: false) - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-pipeline-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-get-pipeline # def get_pipeline(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.get_pipeline' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +53,14 @@ def get_pipeline(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _id - "_ingest/pipeline/#{Utils.__listify(_id)}" + "_ingest/pipeline/#{Utils.listify(_id)}" else - "_ingest/pipeline" + '_ingest/pipeline' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/processor_grok.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/processor_grok.rb index 9f893c10a0..91cffdbb3f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/processor_grok.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/processor_grok.rb @@ -15,31 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Ingest module Actions - # Returns a list of the built-in patterns. + # Run a grok processor. + # Extract structured fields out of a single text field within a document. + # You must choose which field to extract matched fields from, as well as the grok pattern you expect will match. + # A grok pattern is like a regular expression that supports aliased expressions that can be reused. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/grok-processor.html#grok-processor-rest-get + # @see https://www.elastic.co/docs/reference/enrich-processor/grok-processor # def processor_grok(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.processor_grok' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_ingest/processor/grok" + path = '_ingest/processor/grok' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_geoip_database.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_geoip_database.rb new file mode 100644 index 0000000000..dded11f00f --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_geoip_database.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Ingest + module Actions + # Create or update a GeoIP database configuration. + # Refer to the create or update IP geolocation database configuration API. + # + # @option arguments [String] :id ID of the database configuration to create or update. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-put-geoip-database + # + def put_geoip_database(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.put_geoip_database' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_PUT + path = "_ingest/geoip/database/#{Utils.listify(_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_ip_location_database.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_ip_location_database.rb new file mode 100644 index 0000000000..c8c25c27ea --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_ip_location_database.rb @@ -0,0 +1,68 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Ingest + module Actions + # Create or update an IP geolocation database configuration. + # + # @option arguments [String] :id The database configuration identifier. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # A value of +-1+ indicates that the request should never time out. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. + # If no response is received before the timeout expires, the cluster metadata update still applies but the response indicates that it was not completely acknowledged. + # A value of +-1+ indicates that the request should never time out. Server default: 30s. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body configuration + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-put-ip-location-database + # + def put_ip_location_database(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.put_ip_location_database' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_PUT + path = "_ingest/ip_location/database/#{Utils.listify(_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_pipeline.rb index db4628544b..2d22696020 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/put_pipeline.rb @@ -15,25 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Ingest module Actions - # Creates or updates a pipeline. + # Create or update a pipeline. + # Changes made using this API take effect immediately. # - # @option arguments [String] :id Pipeline ID + # @option arguments [String] :id ID of the ingest pipeline to create or update. (*Required*) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Integer] :if_version Required version for optimistic concurrency control for pipeline updates - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The ingest definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html + # @see https://www.elastic.co/docs/manage-data/ingest/transform-enrich/ingest-pipelines # def put_pipeline(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.put_pipeline' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -45,11 +53,11 @@ def put_pipeline(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_PUT - path = "_ingest/pipeline/#{Utils.__listify(_id)}" + path = "_ingest/pipeline/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb index 21f26cc5d5..f07bdcc564 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ingest/simulate.rb @@ -15,23 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Ingest module Actions - # Allows to simulate a pipeline with example documents. + # Simulate a pipeline. + # Run an ingest pipeline against a set of provided documents. + # You can either specify an existing pipeline to use with the provided documents or supply a pipeline definition in the body of the request. # - # @option arguments [String] :id Pipeline ID - # @option arguments [Boolean] :verbose Verbose mode. Display data output for each processor in executed pipeline + # @option arguments [String] :id The pipeline to test. + # If you don't specify a +pipeline+ in the request body, this parameter is required. + # @option arguments [Boolean] :verbose If +true+, the response includes output data for each processor in the executed pipeline. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The simulate definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/simulate-pipeline-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ingest-simulate # def simulate(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ingest.simulate' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone @@ -43,14 +53,14 @@ def simulate(arguments = {}) method = Elasticsearch::API::HTTP_POST path = if _id - "_ingest/pipeline/#{Utils.__listify(_id)}/_simulate" + "_ingest/pipeline/#{Utils.listify(_id)}/_simulate" else - "_ingest/pipeline/_simulate" + '_ingest/pipeline/_simulate' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/knn_search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/knn_search.rb deleted file mode 100644 index 83bd8ac9d9..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/knn_search.rb +++ /dev/null @@ -1,62 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Actions - # Performs a kNN search. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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` to perform the operation on all indices - # @option arguments [List] :routing A comma-separated list of specific routing values - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html - # - def knn_search(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _index = arguments.delete(:index) - - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - - path = "#{Utils.__listify(_index)}/_knn_search" - params = Utils.process_params(arguments) - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/license/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/license/delete.rb index 47b5c5adae..b6ca8b5bb7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/license/delete.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/license/delete.rb @@ -15,31 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module License module Actions - # Deletes licensing information for the cluster + # Delete the license. + # When the license expires, your subscription level reverts to Basic. + # If the operator privileges feature is enabled, only operator users can use this API. # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-license.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-license-delete # def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'license.delete' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_DELETE - path = "_license" - params = {} + path = '_license' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/license/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/license/get.rb index aaff59578f..4dcaaed830 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/license/get.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/license/get.rb @@ -15,33 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module License module Actions - # Retrieves licensing information for the cluster + # Get license information. + # Get information about your Elastic license including its type, its status, when it was issued, and when it expires. # - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) - # @option arguments [Boolean] :accept_enterprise Supported for backwards compatibility with 7.x. If this param is used it must be set to true *Deprecated* + # @option arguments [Boolean] :accept_enterprise If +true+, this parameter returns enterprise for Enterprise license types. If +false+, this parameter returns platinum for both platinum and enterprise license types. This behavior is maintained for backwards compatibility. + # This parameter is deprecated and will always be set to true in 8.x. Server default: true. + # @option arguments [Boolean] :local Specifies whether to retrieve local information. The default value is +false+, which means the information is retrieved from the master node. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-license.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-license-get # def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'license.get' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_license" + path = '_license' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/license/get_basic_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/license/get_basic_status.rb index ae1ee87210..0ae09ccbfa 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/license/get_basic_status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/license/get_basic_status.rb @@ -15,31 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module License module Actions - # Retrieves information about the status of the basic license. + # Get the basic license status. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-basic-status.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-license-get-basic-status # def get_basic_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'license.get_basic_status' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_license/basic_status" + path = '_license/basic_status' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/license/get_trial_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/license/get_trial_status.rb index 454e77cce8..b640725d0a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/license/get_trial_status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/license/get_trial_status.rb @@ -15,31 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module License module Actions - # Retrieves information about the status of the trial license. + # Get the trial status. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trial-status.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-license-get-trial-status # def get_trial_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'license.get_trial_status' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_license/trial_status" + path = '_license/trial_status' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/license/post.rb b/elasticsearch-api/lib/elasticsearch/api/actions/license/post.rb index 8c03da859f..b91887af35 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/license/post.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/license/post.rb @@ -15,33 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module License module Actions - # Updates the license for the cluster. + # Update the license. + # You can update your license at runtime without shutting down your nodes. + # License updates take effect immediately. + # If the license you are installing does not support all of the features that were available with your previous license, however, you are notified in the response. + # You must then re-submit the API request with the acknowledge parameter set to true. + # NOTE: If Elasticsearch security features are enabled and you are installing a gold or higher license, you must enable TLS on the transport networking layer before you install the license. + # If the operator privileges feature is enabled, only operator users can use this API. # - # @option arguments [Boolean] :acknowledge whether the user has acknowledged acknowledge messages (default: false) + # @option arguments [Boolean] :acknowledge Specifies whether you acknowledge the license changes. + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body licenses to be installed + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-license.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-license-post # def post(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'license.post' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_PUT - path = "_license" + path = '_license' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/license/post_start_basic.rb b/elasticsearch-api/lib/elasticsearch/api/actions/license/post_start_basic.rb index b5b3ff59a5..28662b0d8b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/license/post_start_basic.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/license/post_start_basic.rb @@ -15,32 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module License module Actions - # Starts an indefinite basic license. + # Start a basic license. + # Start an indefinite basic license, which gives access to all the basic features. + # NOTE: In order to start a basic license, you must not currently have a basic license. + # If the basic license does not support all of the features that are available with your current license, however, you are notified in the response. + # You must then re-submit the API request with the +acknowledge+ parameter set to +true+. + # To check the status of your basic license, use the get basic license API. # # @option arguments [Boolean] :acknowledge whether the user has acknowledged acknowledge messages (default: false) + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-basic.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-license-post-start-basic # def post_start_basic(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'license.post_start_basic' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_license/start_basic" + path = '_license/start_basic' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/license/post_start_trial.rb b/elasticsearch-api/lib/elasticsearch/api/actions/license/post_start_trial.rb index ae1713b178..70e9a89669 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/license/post_start_trial.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/license/post_start_trial.rb @@ -15,33 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module License module Actions - # starts a limited time trial license. + # Start a trial. + # Start a 30-day trial, which gives access to all subscription features. + # NOTE: You are allowed to start a trial only if your cluster has not already activated a trial for the current major product version. + # For example, if you have already activated a trial for v8.0, you cannot start a new trial until v9.0. You can, however, request an extended trial at https://www.elastic.co/trialextension. + # To check the status of your trial, use the get trial status API. # - # @option arguments [String] :type The type of trial license to generate (default: "trial") # @option arguments [Boolean] :acknowledge whether the user has acknowledged acknowledge messages (default: false) + # @option arguments [String] :type_query_string [TODO] + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-trial.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-license-post-start-trial # def post_start_trial(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'license.post_start_trial' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_license/start_trial" + path = '_license/start_trial' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/logstash/delete_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/logstash/delete_pipeline.rb index 58ab034b24..d75dc68cf9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/logstash/delete_pipeline.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/logstash/delete_pipeline.rb @@ -15,21 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Logstash module Actions - # Deletes Logstash Pipelines used by Central Management + # Delete a Logstash pipeline. + # Delete a pipeline that is used for Logstash Central Management. + # If the request succeeds, you receive an empty response with an appropriate status code. # - # @option arguments [String] :id The ID of the Pipeline + # @option arguments [String] :id An identifier for the pipeline. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-delete-pipeline.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-logstash-delete-pipeline # def delete_pipeline(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'logstash.delete_pipeline' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +49,11 @@ def delete_pipeline(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE - path = "_logstash/pipeline/#{Utils.__listify(_id)}" + path = "_logstash/pipeline/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/logstash/get_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/logstash/get_pipeline.rb index 356a05261d..08f84d3339 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/logstash/get_pipeline.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/logstash/get_pipeline.rb @@ -15,21 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Logstash module Actions - # Retrieves Logstash Pipelines used by Central Management + # Get Logstash pipelines. + # Get pipelines that are used for Logstash Central Management. # - # @option arguments [String] :id A comma-separated list of Pipeline IDs + # @option arguments [String, Array] :id A comma-separated list of pipeline identifiers. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-get-pipeline.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-logstash-get-pipeline # def get_pipeline(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'logstash.get_pipeline' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -39,14 +47,14 @@ def get_pipeline(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _id - "_logstash/pipeline/#{Utils.__listify(_id)}" + "_logstash/pipeline/#{Utils.listify(_id)}" else - "_logstash/pipeline" + '_logstash/pipeline' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/logstash/put_pipeline.rb b/elasticsearch-api/lib/elasticsearch/api/actions/logstash/put_pipeline.rb index dd4d6d8b6b..89d3620e91 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/logstash/put_pipeline.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/logstash/put_pipeline.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Logstash module Actions - # Adds and updates Logstash Pipelines used for Central Management + # Create or update a Logstash pipeline. + # Create a pipeline that is used for Logstash Central Management. + # If the specified pipeline exists, it is replaced. # - # @option arguments [String] :id The ID of the Pipeline + # @option arguments [String] :id An identifier for the pipeline. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The Pipeline to add or update (*Required*) + # @option arguments [Hash] :body pipeline # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-put-pipeline.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-logstash-put-pipeline # def put_pipeline(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'logstash.put_pipeline' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -42,11 +51,11 @@ def put_pipeline(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_PUT - path = "_logstash/pipeline/#{Utils.__listify(_id)}" + path = "_logstash/pipeline/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/clear_trained_model_deployment_cache.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/clear_trained_model_deployment_cache.rb index 05e471a91e..d68157dcda 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/clear_trained_model_deployment_cache.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/clear_trained_model_deployment_cache.rb @@ -15,21 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Clear the cached results from a trained model deployment + # Clear trained model deployment cache. + # Cache will be cleared on all nodes where the trained model is assigned. + # A trained model deployment may have an inference cache enabled. + # As requests are handled by each allocated node, their responses may be cached on that individual node. + # Calling this API clears the caches without restarting the deployment. # # @option arguments [String] :model_id The unique identifier of the trained model. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-trained-model-deployment-cache.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-clear-trained-model-deployment-cache # def clear_trained_model_deployment_cache(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.clear_trained_model_deployment_cache' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] arguments = arguments.clone @@ -40,11 +51,11 @@ def clear_trained_model_deployment_cache(arguments = {}) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/trained_models/#{Utils.__listify(_model_id)}/deployment/cache/_clear" + path = "_ml/trained_models/#{Utils.listify(_model_id)}/deployment/cache/_clear" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/close_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/close_job.rb index 18a2d043db..386281093a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/close_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/close_job.rb @@ -15,25 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Closes one or more anomaly detection jobs. A job can be opened and closed multiple times throughout its lifecycle. + # Close anomaly detection jobs. + # A job can be opened and closed multiple times throughout its lifecycle. A closed job cannot receive data or perform analysis operations, but you can still explore and navigate results. + # When you close a job, it runs housekeeping tasks such as pruning the model history, flushing buffers, calculating final results and persisting the model snapshots. Depending upon the size of the job, it could take several minutes to close and the equivalent time to re-open. After it is closed, the job has a minimal overhead on the cluster except for maintaining its meta data. Therefore it is a best practice to close jobs that are no longer required to process data. + # If you close an anomaly detection job whose datafeed is running, the request first tries to stop the datafeed. This behavior is equivalent to calling stop datafeed API with the same timeout and force parameters as the close job request. + # When a datafeed that has a specified end date stops, it automatically closes its associated job. # - # @option arguments [String] :job_id The name of the job to close - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - # @option arguments [Boolean] :force True if the job should be forcefully closed - # @option arguments [Time] :timeout Controls the time to wait until a job has closed. Default to 30 minutes + # @option arguments [String] :job_id Identifier for the anomaly detection job. It can be a job identifier, a group name, or a wildcard expression. You can close multiple anomaly detection jobs in a single API request by using a group name, a comma-separated list of jobs, or a wildcard expression. You can close all jobs by using +_all+ or by specifying +*+ as the job identifier. (*Required*) + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: contains wildcard expressions and there are no jobs that match; contains the +_all+ string or no identifiers and there are no matches; or contains wildcard expressions and there are only partial matches. By default, it returns an empty jobs array when there are no matches and the subset of results when there are partial matches. + # If +false+, the request returns a 404 status code when there are no matches or only partial matches. Server default: true. + # @option arguments [Boolean] :force Use to close a failed job, or to forcefully close a job which has not responded to its initial close request; the request returns without performing the associated actions such as flushing buffers and persisting the model snapshots. + # If you want the job to be in a consistent state after the close job API returns, do not set to +true+. This parameter should be used only in situations where the job has already failed or where you are not interested in results the job might have recently produced or might produce in the future. + # @option arguments [Time] :timeout Controls the time to wait until a job has closed. Server default: 30m. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The URL params optionally sent in the body + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-close-job # def close_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.close_job' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -44,11 +57,11 @@ def close_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_close" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_close" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar.rb index 7af6b3b13d..405752a5af 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar.rb @@ -15,21 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes a calendar. + # Delete a calendar. + # Remove all scheduled events from a calendar, then delete it. # - # @option arguments [String] :calendar_id The ID of the calendar to delete + # @option arguments [String] :calendar_id A string that uniquely identifies a calendar. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-calendar # def delete_calendar(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_calendar' } + + defined_params = [:calendar_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'calendar_id' missing" unless arguments[:calendar_id] arguments = arguments.clone @@ -40,11 +48,11 @@ def delete_calendar(arguments = {}) _calendar_id = arguments.delete(:calendar_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/calendars/#{Utils.__listify(_calendar_id)}" + path = "_ml/calendars/#{Utils.listify(_calendar_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar_event.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar_event.rb index 14b90a8406..e520471ff3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar_event.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar_event.rb @@ -15,22 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes scheduled events from a calendar. + # Delete events from a calendar. # - # @option arguments [String] :calendar_id The ID of the calendar to modify - # @option arguments [String] :event_id The ID of the event to remove from the calendar + # @option arguments [String] :calendar_id A string that uniquely identifies a calendar. (*Required*) + # @option arguments [String] :event_id Identifier for the scheduled event. + # You can obtain this identifier by using the get calendar events API. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-event.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-calendar-event # def delete_calendar_event(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_calendar_event' } + + defined_params = [:calendar_id, :event_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'calendar_id' missing" unless arguments[:calendar_id] raise ArgumentError, "Required argument 'event_id' missing" unless arguments[:event_id] @@ -44,11 +52,11 @@ def delete_calendar_event(arguments = {}) _event_id = arguments.delete(:event_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/calendars/#{Utils.__listify(_calendar_id)}/events/#{Utils.__listify(_event_id)}" + path = "_ml/calendars/#{Utils.listify(_calendar_id)}/events/#{Utils.listify(_event_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar_job.rb index 2869b2bd88..642a9c689d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_calendar_job.rb @@ -15,22 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes anomaly detection jobs from a calendar. + # Delete anomaly jobs from a calendar. # - # @option arguments [String] :calendar_id The ID of the calendar to modify - # @option arguments [String] :job_id The ID of the job to remove from the calendar + # @option arguments [String] :calendar_id A string that uniquely identifies a calendar. (*Required*) + # @option arguments [String, Array] :job_id An identifier for the anomaly detection jobs. It can be a job identifier, a group name, or a + # comma-separated list of jobs or groups. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-calendar-job # def delete_calendar_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_calendar_job' } + + defined_params = [:calendar_id, :job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'calendar_id' missing" unless arguments[:calendar_id] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] @@ -44,11 +52,11 @@ def delete_calendar_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/calendars/#{Utils.__listify(_calendar_id)}/jobs/#{Utils.__listify(_job_id)}" + path = "_ml/calendars/#{Utils.listify(_calendar_id)}/jobs/#{Utils.listify(_job_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_data_frame_analytics.rb index 1529f7ad1a..337ec1b27e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_data_frame_analytics.rb @@ -15,23 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes an existing data frame analytics job. + # Delete a data frame analytics job. # - # @option arguments [String] :id The ID of the data frame analytics to delete - # @option arguments [Boolean] :force True if the job should be forcefully deleted - # @option arguments [Time] :timeout Controls the time to wait until a job is deleted. Defaults to 1 minute + # @option arguments [String] :id Identifier for the data frame analytics job. (*Required*) + # @option arguments [Boolean] :force If +true+, it deletes a job that is not stopped; this method is quicker than stopping and deleting the job. + # @option arguments [Time] :timeout The time to wait for the job to be deleted. Server default: 1m. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-data-frame-analytics # def delete_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -42,11 +49,11 @@ def delete_data_frame_analytics(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/data_frame/analytics/#{Utils.__listify(_id)}" + path = "_ml/data_frame/analytics/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_datafeed.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_datafeed.rb index d9b4a1e009..7526f8907e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_datafeed.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_datafeed.rb @@ -15,22 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes an existing datafeed. + # Delete a datafeed. # - # @option arguments [String] :datafeed_id The ID of the datafeed to delete - # @option arguments [Boolean] :force True if the datafeed should be forcefully deleted + # @option arguments [String] :datafeed_id A numerical character string that uniquely identifies the datafeed. This + # identifier can contain lowercase alphanumeric characters (a-z and 0-9), + # hyphens, and underscores. It must start and end with alphanumeric + # characters. (*Required*) + # @option arguments [Boolean] :force Use to forcefully delete a started datafeed; this method is quicker than + # stopping and deleting the datafeed. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-datafeed # def delete_datafeed(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_datafeed' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'datafeed_id' missing" unless arguments[:datafeed_id] arguments = arguments.clone @@ -41,11 +52,11 @@ def delete_datafeed(arguments = {}) _datafeed_id = arguments.delete(:datafeed_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}" + path = "_ml/datafeeds/#{Utils.listify(_datafeed_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_expired_data.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_expired_data.rb index 1dc2b2e0cd..884fff38e7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_expired_data.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_expired_data.rb @@ -15,24 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes expired and unused machine learning data. + # Delete expired ML data. + # Delete all job results, model snapshots and forecast data that have exceeded + # their retention days period. Machine learning state documents that are not + # associated with any job are also deleted. + # You can limit the request to a single or set of anomaly detection jobs by + # using a job identifier, a group name, a comma-separated list of jobs, or a + # wildcard expression. You can delete expired data for all anomaly detection + # jobs by using +_all+, by specifying +*+ as the ++, or by omitting the + # ++. # - # @option arguments [String] :job_id The ID of the job(s) to perform expired data hygiene for - # @option arguments [Number] :requests_per_second The desired requests per second for the deletion processes. - # @option arguments [Time] :timeout How long can the underlying delete processes run until they are canceled + # @option arguments [String] :job_id Identifier for an anomaly detection job. It can be a job identifier, a + # group name, or a wildcard expression. + # @option arguments [Float] :requests_per_second The desired requests per second for the deletion processes. The default + # behavior is no throttling. + # @option arguments [Time] :timeout How long can the underlying delete processes run until they are canceled. Server default: 8h. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body deleting expired data parameters + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-expired-data # def delete_expired_data(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_expired_data' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -42,14 +59,14 @@ def delete_expired_data(arguments = {}) method = Elasticsearch::API::HTTP_DELETE path = if _job_id - "_ml/_delete_expired_data/#{Utils.__listify(_job_id)}" + "_ml/_delete_expired_data/#{Utils.listify(_job_id)}" else - "_ml/_delete_expired_data" + '_ml/_delete_expired_data' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_filter.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_filter.rb index f5751b33a9..4b006ed27b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_filter.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_filter.rb @@ -15,21 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes a filter. + # Delete a filter. + # If an anomaly detection job references the filter, you cannot delete the + # filter. You must update or delete the job before you can delete the filter. # - # @option arguments [String] :filter_id The ID of the filter to delete + # @option arguments [String] :filter_id A string that uniquely identifies a filter. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-filter.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-filter # def delete_filter(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_filter' } + + defined_params = [:filter_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'filter_id' missing" unless arguments[:filter_id] arguments = arguments.clone @@ -40,11 +49,11 @@ def delete_filter(arguments = {}) _filter_id = arguments.delete(:filter_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/filters/#{Utils.__listify(_filter_id)}" + path = "_ml/filters/#{Utils.listify(_filter_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_forecast.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_forecast.rb index 0ace7f717c..2642bab316 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_forecast.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_forecast.rb @@ -15,24 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes forecasts from a machine learning job. + # Delete forecasts from a job. + # By default, forecasts are retained for 14 days. You can specify a + # different retention period with the +expires_in+ parameter in the forecast + # jobs API. The delete forecast API enables you to delete one or more + # forecasts before they expire. # - # @option arguments [String] :job_id The ID of the job from which to delete forecasts - # @option arguments [String] :forecast_id The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` - # @option arguments [Boolean] :allow_no_forecasts Whether to ignore if `_all` matches no forecasts - # @option arguments [Time] :timeout Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String] :forecast_id A comma-separated list of forecast identifiers. If you do not specify + # this optional parameter or if you specify +_all+ or +*+ the API deletes + # all forecasts from the job. + # @option arguments [Boolean] :allow_no_forecasts Specifies whether an error occurs when there are no forecasts. In + # particular, if this parameter is set to +false+ and there are no + # forecasts associated with the job, attempts to delete all forecasts + # return an error. Server default: true. + # @option arguments [Time] :timeout Specifies the period of time to wait for the completion of the delete + # operation. When this period of time elapses, the API fails and returns an + # error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-forecast # def delete_forecast(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_forecast' } + + defined_params = [:job_id, :forecast_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -46,14 +64,14 @@ def delete_forecast(arguments = {}) method = Elasticsearch::API::HTTP_DELETE path = if _job_id && _forecast_id - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_forecast/#{Utils.__listify(_forecast_id)}" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_forecast/#{Utils.listify(_forecast_id)}" else - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_forecast" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_forecast" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_job.rb index 118dfc35fa..980280bfb1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_job.rb @@ -15,24 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes an existing anomaly detection job. + # Delete an anomaly detection job. + # All job configuration, model state and results are deleted. + # It is not currently possible to delete multiple jobs using wildcards or a + # comma separated list. If you delete a job that has a datafeed, the request + # first tries to delete the datafeed. This behavior is equivalent to calling + # the delete datafeed API with the same timeout and force parameters as the + # delete job request. # - # @option arguments [String] :job_id The ID of the job to delete - # @option arguments [Boolean] :force True if the job should be forcefully deleted - # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning - # @option arguments [Boolean] :delete_user_annotations Should annotations added by the user be deleted + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [Boolean] :force Use to forcefully delete an opened job; this method is quicker than + # closing and deleting the job. + # @option arguments [Boolean] :delete_user_annotations Specifies whether annotations that have been added by the + # user should be deleted along with any auto-generated annotations when the job is + # reset. + # @option arguments [Boolean] :wait_for_completion Specifies whether the request should return immediately or wait until the + # job deletion completes. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-job # def delete_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_job' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -43,11 +60,11 @@ def delete_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_model_snapshot.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_model_snapshot.rb index 0596fd2728..3657140310 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_model_snapshot.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_model_snapshot.rb @@ -15,22 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes an existing model snapshot. + # Delete a model snapshot. + # You cannot delete the active model snapshot. To delete that snapshot, first + # revert to a different one. To identify the active model snapshot, refer to + # the +model_snapshot_id+ in the results from the get jobs API. # - # @option arguments [String] :job_id The ID of the job to fetch - # @option arguments [String] :snapshot_id The ID of the snapshot to delete + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String] :snapshot_id Identifier for the model snapshot. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-model-snapshot # def delete_model_snapshot(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_model_snapshot' } + + defined_params = [:job_id, :snapshot_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] raise ArgumentError, "Required argument 'snapshot_id' missing" unless arguments[:snapshot_id] @@ -44,11 +54,11 @@ def delete_model_snapshot(arguments = {}) _snapshot_id = arguments.delete(:snapshot_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/model_snapshots/#{Utils.__listify(_snapshot_id)}" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/model_snapshots/#{Utils.listify(_snapshot_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_trained_model.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_trained_model.rb index 827a0e0a64..186dbf152c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_trained_model.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_trained_model.rb @@ -15,23 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes an existing trained inference model that is currently not referenced by an ingest pipeline. + # Delete an unreferenced trained model. + # The request deletes a trained inference model that is not referenced by an ingest pipeline. # - # @option arguments [String] :model_id The ID of the trained model to delete - # @option arguments [Time] :timeout Controls the amount of time to wait for the model to be deleted. - # @option arguments [Boolean] :force True if the model should be forcefully deleted + # @option arguments [String] :model_id The unique identifier of the trained model. (*Required*) + # @option arguments [Boolean] :force Forcefully deletes a trained model that is referenced by ingest pipelines or has a started deployment. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-trained-model # def delete_trained_model(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_trained_model' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] arguments = arguments.clone @@ -42,11 +50,11 @@ def delete_trained_model(arguments = {}) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/trained_models/#{Utils.__listify(_model_id)}" + path = "_ml/trained_models/#{Utils.listify(_model_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_trained_model_alias.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_trained_model_alias.rb index 491d168962..a8a279f57a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_trained_model_alias.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/delete_trained_model_alias.rb @@ -15,22 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Deletes a model alias that refers to the trained model + # Delete a trained model alias. + # This API deletes an existing model alias that refers to a trained model. If + # the model alias is missing or refers to a model other than the one identified + # by the +model_id+, this API returns an error. # - # @option arguments [String] :model_alias The trained model alias to delete - # @option arguments [String] :model_id The trained model where the model alias is assigned + # @option arguments [String] :model_alias The model alias to delete. (*Required*) + # @option arguments [String] :model_id The trained model ID to which the model alias refers. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models-aliases.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-delete-trained-model-alias # def delete_trained_model_alias(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.delete_trained_model_alias' } + + defined_params = [:model_id, :model_alias].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] raise ArgumentError, "Required argument 'model_alias' missing" unless arguments[:model_alias] @@ -44,11 +54,11 @@ def delete_trained_model_alias(arguments = {}) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_DELETE - path = "_ml/trained_models/#{Utils.__listify(_model_id)}/model_aliases/#{Utils.__listify(_model_alias)}" + path = "_ml/trained_models/#{Utils.listify(_model_id)}/model_aliases/#{Utils.listify(_model_alias)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/estimate_model_memory.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/estimate_model_memory.rb index 2c351d13be..fe40188df3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/estimate_model_memory.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/estimate_model_memory.rb @@ -15,34 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Estimates the model memory + # Estimate job model memory usage. + # Make an estimation of the memory usage for an anomaly detection job model. + # The estimate is based on analysis configuration details for the job and cardinality + # estimates for the fields it references. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The analysis config, plus cardinality estimates for fields it references (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-estimate-model-memory # def estimate_model_memory(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.estimate_model_memory' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/_estimate_model_memory" + path = '_ml/anomaly_detectors/_estimate_model_memory' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/evaluate_data_frame.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/evaluate_data_frame.rb index 380a3c62de..c5b24f2ca9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/evaluate_data_frame.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/evaluate_data_frame.rb @@ -15,34 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Evaluates the data frame analytics for an annotated index. + # Evaluate data frame analytics. + # The API packages together commonly used evaluation metrics for various types + # of machine learning features. This has been designed for use on indexes + # created by data frame analytics. Evaluation requires both a ground truth + # field and an analytics result field to be present. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The evaluation definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-evaluate-data-frame # def evaluate_data_frame(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.evaluate_data_frame' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_ml/data_frame/_evaluate" + path = '_ml/data_frame/_evaluate' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/explain_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/explain_data_frame_analytics.rb index 1e49f96a08..23866c36f0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/explain_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/explain_data_frame_analytics.rb @@ -15,22 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Explains a data frame analytics config. + # Explain data frame analytics config. + # This API provides explanations for a data frame analytics config that either + # exists already or one that has not been created yet. The following + # explanations are provided: + # * which fields are included or not in the analysis and why, + # * how much memory is estimated to be required. The estimate can be used when deciding the appropriate value for model_memory_limit setting later on. + # If you have object fields or fields that are excluded via source filtering, they are not included in the explanation. # - # @option arguments [String] :id The ID of the data frame analytics to explain + # @option arguments [String] :id Identifier for the data frame analytics job. This identifier can contain + # lowercase alphanumeric characters (a-z and 0-9), hyphens, and + # underscores. It must start and end with alphanumeric characters. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The data frame analytics config to explain + # @option arguments [Hash] :body request body # - # @see http://www.elastic.co/guide/en/elasticsearch/reference/current/explain-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-explain-data-frame-analytics # def explain_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.explain_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -45,14 +60,14 @@ def explain_data_frame_analytics(arguments = {}) end path = if _id - "_ml/data_frame/analytics/#{Utils.__listify(_id)}/_explain" + "_ml/data_frame/analytics/#{Utils.listify(_id)}/_explain" else - "_ml/data_frame/analytics/_explain" + '_ml/data_frame/analytics/_explain' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/flush_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/flush_job.rb index 81f4889724..2d76063a4a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/flush_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/flush_job.rb @@ -15,27 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Forces any buffered data to be processed by the job. + # Force buffered data to be processed. + # The flush jobs API is only applicable when sending data for analysis using + # the post data API. Depending on the content of the buffer, then it might + # additionally calculate new results. Both flush and close operations are + # similar, however the flush is more efficient if you are expecting to send + # more data for analysis. When flushing, the job remains open and is available + # to continue analyzing data. A close operation additionally prunes and + # persists the model state to disk and the job must be opened again before + # analyzing further data. # - # @option arguments [String] :job_id The name of the job to flush - # @option arguments [Boolean] :calc_interim Calculates interim results for the most recent bucket or all buckets within the latency period - # @option arguments [String] :start When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results - # @option arguments [String] :end When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results - # @option arguments [String] :advance_time Advances time to the given value generating results and updating the model for the advanced interval - # @option arguments [String] :skip_time Skips time to the given value without generating results or updating the model for the skipped interval + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String, Time] :advance_time Specifies to advance to a particular time value. Results are generated + # and the model is updated for data from the specified time interval. + # @option arguments [Boolean] :calc_interim If true, calculates the interim results for the most recent bucket or all + # buckets within the latency period. + # @option arguments [String, Time] :end When used in conjunction with +calc_interim+ and +start+, specifies the + # range of buckets on which to calculate interim results. + # @option arguments [String, Time] :skip_time Specifies to skip to a particular time value. Results are not generated + # and the model is not updated for data from the specified time interval. + # @option arguments [String, Time] :start When used in conjunction with +calc_interim+, specifies the range of + # buckets on which to calculate interim results. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Flush parameters + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-flush-job # def flush_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.flush_job' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -46,11 +66,11 @@ def flush_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_flush" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_flush" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/forecast.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/forecast.rb index 7e91fd2b4a..b1cec0ba2c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/forecast.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/forecast.rb @@ -15,25 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Predicts the future behavior of a time series by using its historical behavior. + # Predict future behavior of a time series. + # Forecasts are not supported for jobs that perform population analysis; an + # error occurs if you try to create a forecast for a job that has an + # +over_field_name+ in its configuration. Forcasts predict future behavior + # based on historical data. # - # @option arguments [String] :job_id The ID of the job to forecast for - # @option arguments [Time] :duration The duration of the forecast - # @option arguments [Time] :expires_in The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. - # @option arguments [String] :max_model_memory The max memory able to be used by the forecast. Default is 20mb. + # @option arguments [String] :job_id Identifier for the anomaly detection job. The job must be open when you + # create a forecast; otherwise, an error occurs. (*Required*) + # @option arguments [Time] :duration A period of time that indicates how far into the future to forecast. For + # example, +30d+ corresponds to 30 days. The forecast starts at the last + # record that was processed. Server default: 1d. + # @option arguments [Time] :expires_in The period of time that forecast results are retained. After a forecast + # expires, the results are deleted. If set to a value of 0, the forecast is + # never automatically deleted. Server default: 14d. + # @option arguments [String] :max_model_memory The maximum memory the forecast can use. If the forecast needs to use + # more than the provided amount, it will spool to disk. Default is 20mb, + # maximum is 500mb and minimum is 1mb. If set to 40% or more of the job’s + # configured memory limit, it is automatically reduced to below that + # amount. Server default: 20mb. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Query parameters can be specified in the body + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-forecast.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-forecast # def forecast(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.forecast' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -44,11 +64,11 @@ def forecast(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_forecast" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_forecast" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb index e5b9098019..e321e7d871 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_buckets.rb @@ -15,32 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves anomaly detection job results for one or more buckets. + # Get anomaly detection job results for buckets. + # The API presents a chronological view of the records, grouped by bucket. # - # @option arguments [String] :job_id ID of the job to get bucket results from - # @option arguments [String] :timestamp The timestamp of the desired single bucket result - # @option arguments [Boolean] :expand Include anomaly records - # @option arguments [Boolean] :exclude_interim Exclude interim results - # @option arguments [Integer] :from skips a number of buckets - # @option arguments [Integer] :size specifies a max number of buckets to get - # @option arguments [String] :start Start time filter for buckets - # @option arguments [String] :end End time filter for buckets - # @option arguments [Double] :anomaly_score Filter for the most anomalous buckets - # @option arguments [String] :sort Sort buckets by a particular field - # @option arguments [Boolean] :desc Set the sort direction + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String, Time] :timestamp The timestamp of a single bucket result. If you do not specify this + # parameter, the API returns information about all buckets. + # @option arguments [Float] :anomaly_score Returns buckets with anomaly scores greater or equal than this value. Server default: 0. + # @option arguments [Boolean] :desc If +true+, the buckets are sorted in descending order. + # @option arguments [String, Time] :end Returns buckets with timestamps earlier than this time. +-1+ means it is + # unset and results are not limited to specific timestamps. Server default: -1. + # @option arguments [Boolean] :exclude_interim If +true+, the output excludes interim results. + # @option arguments [Boolean] :expand If true, the output includes anomaly records. + # @option arguments [Integer] :from Skips the specified number of buckets. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of buckets to obtain. Server default: 100. + # @option arguments [String] :sort Specifies the sort field for the requested buckets. Server default: timestamp. + # @option arguments [String, Time] :start Returns buckets with timestamps after this time. +-1+ means it is unset + # and results are not limited to specific timestamps. Server default: -1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Bucket selection details if not provided in URI + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-buckets # def get_buckets(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_buckets' } + + defined_params = [:job_id, :timestamp].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -59,14 +70,14 @@ def get_buckets(arguments = {}) end path = if _job_id && _timestamp - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/results/buckets/#{Utils.__listify(_timestamp)}" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/buckets/#{Utils.listify(_timestamp)}" else - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/results/buckets" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/buckets" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendar_events.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendar_events.rb index 56207de79d..7251f54e40 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendar_events.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendar_events.rb @@ -15,26 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves information about the scheduled events in calendars. + # Get info about events in calendars. # - # @option arguments [String] :calendar_id The ID of the calendar containing the events - # @option arguments [String] :job_id Get events for the job. When this option is used calendar_id must be '_all' - # @option arguments [String] :start Get events after this time - # @option arguments [Date] :end Get events before this time - # @option arguments [Integer] :from Skips a number of events - # @option arguments [Integer] :size Specifies a max number of events to get + # @option arguments [String] :calendar_id A string that uniquely identifies a calendar. You can get information for multiple calendars by using a comma-separated list of ids or a wildcard expression. You can get information for all calendars by using +_all+ or +*+ or by omitting the calendar identifier. (*Required*) + # @option arguments [String, Time] :end Specifies to get events with timestamps earlier than this time. + # @option arguments [Integer] :from Skips the specified number of events. Server default: 0. + # @option arguments [String] :job_id Specifies to get events for a specific anomaly detection job identifier or job group. It must be used with a calendar identifier of +_all+ or +*+. + # @option arguments [Integer] :size Specifies the maximum number of events to obtain. Server default: 100. + # @option arguments [String, Time] :start Specifies to get events with timestamps after this time. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar-event.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-calendar-events # def get_calendar_events(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_calendar_events' } + + defined_params = [:calendar_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'calendar_id' missing" unless arguments[:calendar_id] arguments = arguments.clone @@ -45,11 +52,11 @@ def get_calendar_events(arguments = {}) _calendar_id = arguments.delete(:calendar_id) method = Elasticsearch::API::HTTP_GET - path = "_ml/calendars/#{Utils.__listify(_calendar_id)}/events" + path = "_ml/calendars/#{Utils.listify(_calendar_id)}/events" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendars.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendars.rb index 8fee8aa989..26d6c6e6b6 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendars.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_calendars.rb @@ -15,24 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves configuration information for calendars. + # Get calendar configuration info. # - # @option arguments [String] :calendar_id The ID of the calendar to fetch - # @option arguments [Integer] :from skips a number of calendars - # @option arguments [Integer] :size specifies a max number of calendars to get + # @option arguments [String] :calendar_id A string that uniquely identifies a calendar. You can get information for multiple calendars by using a comma-separated list of ids or a wildcard expression. You can get information for all calendars by using +_all+ or +*+ or by omitting the calendar identifier. + # @option arguments [Integer] :from Skips the specified number of calendars. This parameter is supported only when you omit the calendar identifier. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of calendars to obtain. This parameter is supported only when you omit the calendar identifier. Server default: 10000. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The from and size parameters optionally sent in the body + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-calendars # def get_calendars(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_calendars' } + + defined_params = [:calendar_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -47,14 +54,14 @@ def get_calendars(arguments = {}) end path = if _calendar_id - "_ml/calendars/#{Utils.__listify(_calendar_id)}" + "_ml/calendars/#{Utils.listify(_calendar_id)}" else - "_ml/calendars" + '_ml/calendars' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_categories.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_categories.rb index 03091a80a7..0afa5dab5f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_categories.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_categories.rb @@ -15,26 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves anomaly detection job results for one or more categories. + # Get anomaly detection job results for categories. # - # @option arguments [String] :job_id The name of the job - # @option arguments [Long] :category_id The identifier of the category definition of interest - # @option arguments [Integer] :from skips a number of categories - # @option arguments [Integer] :size specifies a max number of categories to get - # @option arguments [String] :partition_field_value Specifies the partition to retrieve categories for. This is optional, and should never be used for jobs where per-partition categorization is disabled. + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String] :category_id Identifier for the category, which is unique in the job. If you specify + # neither the category ID nor the partition_field_value, the API returns + # information about all categories. If you specify only the + # partition_field_value, it returns information about all categories for + # the specified partition. + # @option arguments [Integer] :from Skips the specified number of categories. Server default: 0. + # @option arguments [String] :partition_field_value Only return categories for the specified partition. + # @option arguments [Integer] :size Specifies the maximum number of categories to obtain. Server default: 100. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Category selection details if not provided in URI + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-categories # def get_categories(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_categories' } + + defined_params = [:job_id, :category_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -53,14 +64,14 @@ def get_categories(arguments = {}) end path = if _job_id && _category_id - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/results/categories/#{Utils.__listify(_category_id)}" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/categories/#{Utils.listify(_category_id)}" else - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/results/categories" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/categories" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_data_frame_analytics.rb index ad2f81d8f1..2fcab59fbb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_data_frame_analytics.rb @@ -15,25 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves configuration information for data frame analytics jobs. + # Get data frame analytics job configuration info. + # You can get information for multiple data frame analytics jobs in a single + # API request by using a comma-separated list of data frame analytics jobs or a + # wildcard expression. # - # @option arguments [String] :id The ID of the data frame analytics to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) - # @option arguments [Integer] :from skips a number of analytics - # @option arguments [Integer] :size specifies a max number of analytics to get - # @option arguments [Boolean] :exclude_generated Omits fields that are illegal to set on data frame analytics PUT + # @option arguments [String] :id Identifier for the data frame analytics job. If you do not specify this + # option, the API returns information for the first hundred data frame + # analytics jobs. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no data frame analytics + # jobs that match. + # - Contains the +_all+ string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # The default value returns an empty data_frame_analytics array when there + # are no matches and the subset of results when there are partial matches. + # If this parameter is +false+, the request returns a 404 status code when + # there are no matches or only partial matches. Server default: true. + # @option arguments [Integer] :from Skips the specified number of data frame analytics jobs. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of data frame analytics jobs to obtain. Server default: 100. + # @option arguments [Boolean] :exclude_generated Indicates if certain fields should be removed from the configuration on + # retrieval. This allows the configuration to be in an acceptable format to + # be retrieved and then added to another cluster. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-data-frame-analytics # def get_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -43,14 +65,14 @@ def get_data_frame_analytics(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _id - "_ml/data_frame/analytics/#{Utils.__listify(_id)}" + "_ml/data_frame/analytics/#{Utils.listify(_id)}" else - "_ml/data_frame/analytics" + '_ml/data_frame/analytics' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_data_frame_analytics_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_data_frame_analytics_stats.rb index 8dc251dca6..e408939427 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_data_frame_analytics_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_data_frame_analytics_stats.rb @@ -15,25 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves usage information for data frame analytics jobs. + # Get data frame analytics jobs usage info. # - # @option arguments [String] :id The ID of the data frame analytics stats to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) - # @option arguments [Integer] :from skips a number of analytics - # @option arguments [Integer] :size specifies a max number of analytics to get - # @option arguments [Boolean] :verbose whether the stats response should be verbose + # @option arguments [String] :id Identifier for the data frame analytics job. If you do not specify this + # option, the API returns information for the first hundred data frame + # analytics jobs. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no data frame analytics + # jobs that match. + # - Contains the +_all+ string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # The default value returns an empty data_frame_analytics array when there + # are no matches and the subset of results when there are partial matches. + # If this parameter is +false+, the request returns a 404 status code when + # there are no matches or only partial matches. Server default: true. + # @option arguments [Integer] :from Skips the specified number of data frame analytics jobs. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of data frame analytics jobs to obtain. Server default: 100. + # @option arguments [Boolean] :verbose Defines whether the stats response should be verbose. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-data-frame-analytics-stats # def get_data_frame_analytics_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_data_frame_analytics_stats' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -43,14 +60,14 @@ def get_data_frame_analytics_stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _id - "_ml/data_frame/analytics/#{Utils.__listify(_id)}/_stats" + "_ml/data_frame/analytics/#{Utils.listify(_id)}/_stats" else - "_ml/data_frame/analytics/_stats" + '_ml/data_frame/analytics/_stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_datafeed_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_datafeed_stats.rb index bd8bde1788..58cbb9278d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_datafeed_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_datafeed_stats.rb @@ -15,22 +15,44 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves usage information for datafeeds. + # Get datafeeds usage info. + # You can get statistics for multiple datafeeds in a single API request by + # using a comma-separated list of datafeeds or a wildcard expression. You can + # get statistics for all datafeeds by using +_all+, by specifying +*+ as the + # ++, or by omitting the ++. If the datafeed is stopped, the + # only information you receive is the +datafeed_id+ and the +state+. + # This API returns a maximum of 10,000 datafeeds. # - # @option arguments [String] :datafeed_id The ID of the datafeeds stats to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + # @option arguments [String, Array] :datafeed_id Identifier for the datafeed. It can be a datafeed identifier or a + # wildcard expression. If you do not specify one of these options, the API + # returns information about all datafeeds. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no datafeeds that match. + # - Contains the +_all+ string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # The default value is +true+, which returns an empty +datafeeds+ array + # when there are no matches and the subset of results when there are + # partial matches. If this parameter is +false+, the request returns a + # +404+ status code when there are no matches or only partial matches. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-datafeed-stats # def get_datafeed_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_datafeed_stats' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -40,14 +62,14 @@ def get_datafeed_stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _datafeed_id - "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}/_stats" + "_ml/datafeeds/#{Utils.listify(_datafeed_id)}/_stats" else - "_ml/datafeeds/_stats" + '_ml/datafeeds/_stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_datafeeds.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_datafeeds.rb index 76cca4e56b..21849047cf 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_datafeeds.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_datafeeds.rb @@ -15,23 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves configuration information for datafeeds. + # Get datafeeds configuration info. + # You can get information for multiple datafeeds in a single API request by + # using a comma-separated list of datafeeds or a wildcard expression. You can + # get information for all datafeeds by using +_all+, by specifying +*+ as the + # ++, or by omitting the ++. + # This API returns a maximum of 10,000 datafeeds. # - # @option arguments [String] :datafeed_id The ID of the datafeeds to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - # @option arguments [Boolean] :exclude_generated Omits fields that are illegal to set on datafeed PUT + # @option arguments [String, Array] :datafeed_id Identifier for the datafeed. It can be a datafeed identifier or a + # wildcard expression. If you do not specify one of these options, the API + # returns information about all datafeeds. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no datafeeds that match. + # - Contains the +_all+ string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # The default value is +true+, which returns an empty +datafeeds+ array + # when there are no matches and the subset of results when there are + # partial matches. If this parameter is +false+, the request returns a + # +404+ status code when there are no matches or only partial matches. + # @option arguments [Boolean] :exclude_generated Indicates if certain fields should be removed from the configuration on + # retrieval. This allows the configuration to be in an acceptable format to + # be retrieved and then added to another cluster. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-datafeeds # def get_datafeeds(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_datafeeds' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +64,14 @@ def get_datafeeds(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _datafeed_id - "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}" + "_ml/datafeeds/#{Utils.listify(_datafeed_id)}" else - "_ml/datafeeds" + '_ml/datafeeds' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_filters.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_filters.rb index 81b6c1e7d1..3a4c1063d6 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_filters.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_filters.rb @@ -15,23 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves filters. + # Get filters. + # You can get a single filter or all filters. # - # @option arguments [String] :filter_id The ID of the filter to fetch - # @option arguments [Integer] :from skips a number of filters - # @option arguments [Integer] :size specifies a max number of filters to get + # @option arguments [String, Array] :filter_id A string that uniquely identifies a filter. + # @option arguments [Integer] :from Skips the specified number of filters. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of filters to obtain. Server default: 100. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-filter.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-filters # def get_filters(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_filters' } + + defined_params = [:filter_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +49,14 @@ def get_filters(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _filter_id - "_ml/filters/#{Utils.__listify(_filter_id)}" + "_ml/filters/#{Utils.listify(_filter_id)}" else - "_ml/filters" + '_ml/filters' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_influencers.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_influencers.rb index 4cbdd7adf8..79245406fa 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_influencers.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_influencers.rb @@ -15,30 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves anomaly detection job results for one or more influencers. + # Get anomaly detection job results for influencers. + # Influencers are the entities that have contributed to, or are to blame for, + # the anomalies. Influencer results are available only if an + # +influencer_field_name+ is specified in the job configuration. # - # @option arguments [String] :job_id Identifier for the anomaly detection job - # @option arguments [Boolean] :exclude_interim Exclude interim results - # @option arguments [Integer] :from skips a number of influencers - # @option arguments [Integer] :size specifies a max number of influencers to get - # @option arguments [String] :start start timestamp for the requested influencers - # @option arguments [String] :end end timestamp for the requested influencers - # @option arguments [Double] :influencer_score influencer score threshold for the requested influencers - # @option arguments [String] :sort sort field for the requested influencers - # @option arguments [Boolean] :desc whether the results should be sorted in decending order + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [Boolean] :desc If true, the results are sorted in descending order. + # @option arguments [String, Time] :end Returns influencers with timestamps earlier than this time. + # The default value means it is unset and results are not limited to + # specific timestamps. Server default: -1. + # @option arguments [Boolean] :exclude_interim If true, the output excludes interim results. By default, interim results + # are included. + # @option arguments [Float] :influencer_score Returns influencers with anomaly scores greater than or equal to this + # value. Server default: 0. + # @option arguments [Integer] :from Skips the specified number of influencers. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of influencers to obtain. Server default: 100. + # @option arguments [String] :sort Specifies the sort field for the requested influencers. By default, the + # influencers are sorted by the +influencer_score+ value. + # @option arguments [String, Time] :start Returns influencers with timestamps after this time. The default value + # means it is unset and results are not limited to specific timestamps. Server default: -1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Influencer selection criteria + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-influencers # def get_influencers(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_influencers' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -54,11 +70,11 @@ def get_influencers(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/results/influencers" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/influencers" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_job_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_job_stats.rb index b8e22d38bd..ae351aa2dd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_job_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_job_stats.rb @@ -15,22 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves usage information for anomaly detection jobs. + # Get anomaly detection jobs usage info. # - # @option arguments [String] :job_id The ID of the jobs stats to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + # @option arguments [String] :job_id Identifier for the anomaly detection job. It can be a job identifier, a + # group name, a comma-separated list of jobs, or a wildcard expression. If + # you do not specify one of these options, the API returns information for + # all anomaly detection jobs. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no jobs that match. + # - Contains the _all string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If +true+, the API returns an empty +jobs+ array when + # there are no matches and the subset of results when there are partial + # matches. If +false+, the API returns a +404+ status + # code when there are no matches or only partial matches. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-job-stats # def get_job_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_job_stats' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -40,14 +57,14 @@ def get_job_stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _job_id - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_stats" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_stats" else - "_ml/anomaly_detectors/_stats" + '_ml/anomaly_detectors/_stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_jobs.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_jobs.rb index 0d2aebe1bb..b59b9ecd72 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_jobs.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_jobs.rb @@ -15,23 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves configuration information for anomaly detection jobs. + # Get anomaly detection jobs configuration info. + # You can get information for multiple anomaly detection jobs in a single API + # request by using a group name, a comma-separated list of jobs, or a wildcard + # expression. You can get information for all anomaly detection jobs by using + # +_all+, by specifying +*+ as the ++, or by omitting the ++. # - # @option arguments [String] :job_id The ID of the jobs to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - # @option arguments [Boolean] :exclude_generated Omits fields that are illegal to set on job PUT + # @option arguments [String, Array] :job_id Identifier for the anomaly detection job. It can be a job identifier, a + # group name, or a wildcard expression. If you do not specify one of these + # options, the API returns information for all anomaly detection jobs. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no jobs that match. + # - Contains the _all string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # The default value is +true+, which returns an empty +jobs+ array when + # there are no matches and the subset of results when there are partial + # matches. If this parameter is +false+, the request returns a +404+ status + # code when there are no matches or only partial matches. Server default: true. + # @option arguments [Boolean] :exclude_generated Indicates if certain fields should be removed from the configuration on + # retrieval. This allows the configuration to be in an acceptable format to + # be retrieved and then added to another cluster. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-jobs # def get_jobs(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_jobs' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +63,14 @@ def get_jobs(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _job_id - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}" else - "_ml/anomaly_detectors" + '_ml/anomaly_detectors' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_memory_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_memory_stats.rb index 84881b8492..13f5bb4b9a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_memory_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_memory_stats.rb @@ -15,23 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Returns information on how ML is using memory. + # Get machine learning memory usage info. + # Get information about how machine learning jobs and trained models are using memory, + # on each node, both within the JVM heap, and natively, outside of the JVM. # - # @option arguments [String] :node_id Specifies the node or nodes to retrieve stats for. - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [String] :node_id The names of particular nodes in the cluster to target. For example, +nodeId1,nodeId2+ or + # +ml:true+ + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout + # expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request + # fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-memory.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-memory-stats # def get_memory_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_memory_stats' } + + defined_params = [:node_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +53,14 @@ def get_memory_stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _node_id - "_ml/memory/#{Utils.__listify(_node_id)}/_stats" + "_ml/memory/#{Utils.listify(_node_id)}/_stats" else - "_ml/memory/_stats" + '_ml/memory/_stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats.rb index a1378d96e0..2515be5b54 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats.rb @@ -15,23 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Gets stats for anomaly detection job model snapshot upgrades that are in progress. + # Get anomaly detection job model snapshot upgrade usage info. # - # @option arguments [String] :job_id The ID of the job. May be a wildcard, comma separated list or `_all`. - # @option arguments [String] :snapshot_id The ID of the snapshot. May be a wildcard, comma separated list or `_all`. - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no jobs or no snapshots. (This includes the `_all` string.) + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String] :snapshot_id A numerical character string that uniquely identifies the model snapshot. You can get information for multiple + # snapshots by using a comma-separated list or a wildcard expression. You can get all snapshots by using +_all+, + # by specifying +*+ as the snapshot ID, or by omitting the snapshot ID. (*Required*) + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no jobs that match. + # - Contains the _all string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # The default value is true, which returns an empty jobs array when there are no matches and the subset of results + # when there are partial matches. If this parameter is false, the request returns a 404 status code when there are + # no matches or only partial matches. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-model-snapshot-upgrade-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-model-snapshot-upgrade-stats # def get_model_snapshot_upgrade_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_model_snapshot_upgrade_stats' } + + defined_params = [:job_id, :snapshot_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] raise ArgumentError, "Required argument 'snapshot_id' missing" unless arguments[:snapshot_id] @@ -45,11 +60,11 @@ def get_model_snapshot_upgrade_stats(arguments = {}) _snapshot_id = arguments.delete(:snapshot_id) method = Elasticsearch::API::HTTP_GET - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/model_snapshots/#{Utils.__listify(_snapshot_id)}/_upgrade/_stats" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/model_snapshots/#{Utils.listify(_snapshot_id)}/_upgrade/_stats" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb index 65371c057c..41efb6ca22 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_model_snapshots.rb @@ -15,29 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves information about model snapshots. + # Get model snapshots info. # - # @option arguments [String] :job_id The ID of the job to fetch - # @option arguments [String] :snapshot_id The ID of the snapshot to fetch - # @option arguments [Integer] :from Skips a number of documents - # @option arguments [Integer] :size The default number of documents returned in queries as a string. - # @option arguments [Date] :start The filter 'start' query parameter - # @option arguments [Date] :end The filter 'end' query parameter - # @option arguments [String] :sort Name of the field to sort on - # @option arguments [Boolean] :desc True if the results should be sorted in descending order + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String] :snapshot_id A numerical character string that uniquely identifies the model snapshot. You can get information for multiple + # snapshots by using a comma-separated list or a wildcard expression. You can get all snapshots by using +_all+, + # by specifying +*+ as the snapshot ID, or by omitting the snapshot ID. + # @option arguments [Boolean] :desc If true, the results are sorted in descending order. + # @option arguments [String, Time] :end Returns snapshots with timestamps earlier than this time. + # @option arguments [Integer] :from Skips the specified number of snapshots. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of snapshots to obtain. Server default: 100. + # @option arguments [String] :sort Specifies the sort field for the requested snapshots. By default, the + # snapshots are sorted by their timestamp. + # @option arguments [String, Time] :start Returns snapshots with timestamps after this time. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Model snapshot selection criteria + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-model-snapshots # def get_model_snapshots(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_model_snapshots' } + + defined_params = [:job_id, :snapshot_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -56,14 +66,14 @@ def get_model_snapshots(arguments = {}) end path = if _job_id && _snapshot_id - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/model_snapshots/#{Utils.__listify(_snapshot_id)}" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/model_snapshots/#{Utils.listify(_snapshot_id)}" else - "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/model_snapshots" + "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/model_snapshots" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb index 382a996d21..5ad6d621f5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_overall_buckets.rb @@ -15,29 +15,68 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves overall bucket results that summarize the bucket results of multiple anomaly detection jobs. + # Get overall bucket results. + # Retrievs overall bucket results that summarize the bucket results of + # multiple anomaly detection jobs. + # The +overall_score+ is calculated by combining the scores of all the + # buckets within the overall bucket span. First, the maximum + # +anomaly_score+ per anomaly detection job in the overall bucket is + # calculated. Then the +top_n+ of those scores are averaged to result in + # the +overall_score+. This means that you can fine-tune the + # +overall_score+ so that it is more or less sensitive to the number of + # jobs that detect an anomaly at the same time. For example, if you set + # +top_n+ to +1+, the +overall_score+ is the maximum bucket score in the + # overall bucket. Alternatively, if you set +top_n+ to the number of jobs, + # the +overall_score+ is high only when all jobs detect anomalies in that + # overall bucket. If you set the +bucket_span+ parameter (to a value + # greater than its default), the +overall_score+ is the maximum + # +overall_score+ of the overall buckets that have a span equal to the + # jobs' largest bucket span. # - # @option arguments [String] :job_id The job IDs for which to calculate overall bucket results - # @option arguments [Integer] :top_n The number of top job bucket scores to be used in the overall_score calculation - # @option arguments [String] :bucket_span The span of the overall buckets. Defaults to the longest job bucket_span - # @option arguments [Double] :overall_score Returns overall buckets with overall scores higher than this value - # @option arguments [Boolean] :exclude_interim If true overall buckets that include interim buckets will be excluded - # @option arguments [String] :start Returns overall buckets with timestamps after this time - # @option arguments [String] :end Returns overall buckets with timestamps earlier than this time - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + # @option arguments [String] :job_id Identifier for the anomaly detection job. It can be a job identifier, a + # group name, a comma-separated list of jobs or groups, or a wildcard + # expression.You can summarize the bucket results for all anomaly detection jobs by + # using +_all+ or by specifying +*+ as the ++. (*Required*) + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no jobs that match. + # - Contains the +_all+ string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If +true+, the request returns an empty +jobs+ array when there are no + # matches and the subset of results when there are partial matches. If this + # parameter is +false+, the request returns a +404+ status code when there + # are no matches or only partial matches. Server default: true. + # @option arguments [Time] :bucket_span The span of the overall buckets. Must be greater or equal to the largest + # bucket span of the specified anomaly detection jobs, which is the default + # value.By default, an overall bucket has a span equal to the largest bucket span + # of the specified anomaly detection jobs. To override that behavior, use + # the optional +bucket_span+ parameter. + # @option arguments [String, Time] :end Returns overall buckets with timestamps earlier than this time. + # @option arguments [Boolean] :exclude_interim If +true+, the output excludes interim results. + # @option arguments [Double, String] :overall_score Returns overall buckets with overall scores greater than or equal to this + # value. + # @option arguments [String, Time] :start Returns overall buckets with timestamps after this time. + # @option arguments [Integer] :top_n The number of top anomaly detection job bucket scores to be used in the + # +overall_score+ calculation. Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Overall bucket selection details if not provided in URI + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-overall-buckets # def get_overall_buckets(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_overall_buckets' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -53,11 +92,11 @@ def get_overall_buckets(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/results/overall_buckets" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/overall_buckets" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_records.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_records.rb index 524cb79457..b80c6bca74 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_records.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_records.rb @@ -15,30 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves anomaly records for an anomaly detection job. + # Get anomaly records for an anomaly detection job. + # Records contain the detailed analytical results. They describe the anomalous + # activity that has been identified in the input data based on the detector + # configuration. + # There can be many anomaly records depending on the characteristics and size + # of the input data. In practice, there are often too many to be able to + # manually process them. The machine learning features therefore perform a + # sophisticated aggregation of the anomaly records into buckets. + # The number of record results depends on the number of anomalies found in each + # bucket, which relates to the number of time series being modeled and the + # number of detectors. # - # @option arguments [String] :job_id The ID of the job - # @option arguments [Boolean] :exclude_interim Exclude interim results - # @option arguments [Integer] :from skips a number of records - # @option arguments [Integer] :size specifies a max number of records to get - # @option arguments [String] :start Start time filter for records - # @option arguments [String] :end End time filter for records - # @option arguments [Double] :record_score Returns records with anomaly scores greater or equal than this value - # @option arguments [String] :sort Sort records by a particular field - # @option arguments [Boolean] :desc Set the sort direction + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [Boolean] :desc If true, the results are sorted in descending order. + # @option arguments [String, Time] :end Returns records with timestamps earlier than this time. The default value + # means results are not limited to specific timestamps. Server default: -1. + # @option arguments [Boolean] :exclude_interim If +true+, the output excludes interim results. + # @option arguments [Integer] :from Skips the specified number of records. Server default: 0. + # @option arguments [Float] :record_score Returns records with anomaly scores greater or equal than this value. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of records to obtain. Server default: 100. + # @option arguments [String] :sort Specifies the sort field for the requested records. Server default: record_score. + # @option arguments [String, Time] :start Returns records with timestamps after this time. The default value means + # results are not limited to specific timestamps. Server default: -1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Record selection criteria + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-records # def get_records(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_records' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -54,11 +73,11 @@ def get_records(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/results/records" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/results/records" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_trained_models.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_trained_models.rb index 148ace8472..af7f75a551 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_trained_models.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_trained_models.rb @@ -15,29 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves configuration information for a trained inference model. + # Get trained model configuration info. # - # @option arguments [String] :model_id The ID of the trained models to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) - # @option arguments [String] :include A comma-separate list of fields to optionally include. Valid options are 'definition' and 'total_feature_importance'. Default is none. - # @option arguments [Boolean] :include_model_definition Should the full model definition be included in the results. These definitions can be large. So be cautious when including them. Defaults to false. *Deprecated* - # @option arguments [Boolean] :decompress_definition Should the model definition be decompressed into valid JSON or returned in a custom compressed format. Defaults to true. - # @option arguments [Integer] :from skips a number of trained models - # @option arguments [Integer] :size specifies a max number of trained models to get - # @option arguments [List] :tags A comma-separated list of tags that the model must have. - # @option arguments [Boolean] :exclude_generated Omits fields that are illegal to set on model PUT + # @option arguments [String, Array] :model_id The unique identifier of the trained model or a model alias.You can get information for multiple trained models in a single API + # request by using a comma-separated list of model IDs or a wildcard + # expression. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no models that match. + # - Contains the _all string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If true, it returns an empty array when there are no matches and the + # subset of results when there are partial matches. Server default: true. + # @option arguments [Boolean] :decompress_definition Specifies whether the included model definition should be returned as a + # JSON map (true) or in a custom compressed format (false). Server default: true. + # @option arguments [Boolean] :exclude_generated Indicates if certain fields should be removed from the configuration on + # retrieval. This allows the configuration to be in an acceptable format to + # be retrieved and then added to another cluster. + # @option arguments [Integer] :from Skips the specified number of models. Server default: 0. + # @option arguments [String] :include A comma delimited string of optional fields to include in the response + # body. + # @option arguments [Integer] :size Specifies the maximum number of models to obtain. Server default: 100. + # @option arguments [String] :tags A comma delimited string of tags. A trained model can have many tags, or + # none. When supplied, only trained models that contain all the supplied + # tags are returned. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-trained-models # def get_trained_models(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_trained_models' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -47,14 +66,14 @@ def get_trained_models(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _model_id - "_ml/trained_models/#{Utils.__listify(_model_id)}" + "_ml/trained_models/#{Utils.listify(_model_id)}" else - "_ml/trained_models" + '_ml/trained_models' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_trained_models_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_trained_models_stats.rb index a34eb6f0d9..d95911aa51 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_trained_models_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/get_trained_models_stats.rb @@ -15,24 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Retrieves usage information for trained inference models. + # Get trained models usage info. + # You can get usage information for multiple trained + # models in a single API request by using a comma-separated list of model IDs or a wildcard expression. # - # @option arguments [String] :model_id The ID of the trained models stats to fetch - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) - # @option arguments [Integer] :from skips a number of trained models - # @option arguments [Integer] :size specifies a max number of trained models to get + # @option arguments [String, Array] :model_id The unique identifier of the trained model or a model alias. It can be a + # comma-separated list or a wildcard expression. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no models that match. + # - Contains the _all string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If true, it returns an empty array when there are no matches and the + # subset of results when there are partial matches. Server default: true. + # @option arguments [Integer] :from Skips the specified number of models. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of models to obtain. Server default: 100. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-trained-models-stats # def get_trained_models_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.get_trained_models_stats' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -42,14 +57,14 @@ def get_trained_models_stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _model_id - "_ml/trained_models/#{Utils.__listify(_model_id)}/_stats" + "_ml/trained_models/#{Utils.listify(_model_id)}/_stats" else - "_ml/trained_models/_stats" + '_ml/trained_models/_stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/infer_trained_model.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/infer_trained_model.rb index dce043ef99..c40a2b7555 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/infer_trained_model.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/infer_trained_model.rb @@ -15,9 +15,9 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning @@ -25,18 +25,20 @@ module Actions # Evaluate a trained model. # # @option arguments [String] :model_id The unique identifier of the trained model. (*Required*) - # @option arguments [Time] :timeout Controls the amount of time to wait for inference results. + # @option arguments [Time] :timeout Controls the amount of time to wait for inference results. Server default: 10s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The docs to apply inference on and inference configuration overrides (*Required*) - # - # *Deprecation notice*: - # /_ml/trained_models/{model_id}/deployment/_infer is deprecated. Use /_ml/trained_models/{model_id}/_infer instead - # Deprecated since version 8.3.0 - # + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-trained-model.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-infer-trained-model # def infer_trained_model(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.infer_trained_model' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] @@ -48,13 +50,11 @@ def infer_trained_model(arguments = {}) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_POST - path = if _model_id - "_ml/trained_models/#{Utils.__listify(_model_id)}/deployment/_infer" - end + path = "_ml/trained_models/#{Utils.listify(_model_id)}/_infer" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/info.rb index 45944ab36d..c74af85130 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/info.rb @@ -15,31 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Returns defaults and limits used by machine learning. + # Get machine learning information. + # Get defaults and limits used by machine learning. + # This endpoint is designed to be used by a user interface that needs to fully + # understand machine learning configurations where some options are not + # specified, meaning that the defaults should be used. This endpoint may be + # used to find out what those defaults are. It also provides information about + # the maximum size of machine learning jobs that could run in the current + # cluster configuration. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-info.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-info # def info(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.info' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_ml/info" + path = '_ml/info' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/open_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/open_job.rb index 4d3de91959..52a4c06281 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/open_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/open_job.rb @@ -15,22 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Opens one or more anomaly detection jobs. + # Open anomaly detection jobs. + # An anomaly detection job must be opened to be ready to receive and analyze + # data. It can be opened and closed multiple times throughout its lifecycle. + # When you open a new job, it starts with an empty model. + # When you open an existing job, the most recent model state is automatically + # loaded. The job is ready to resume its analysis from where it left off, once + # new data is received. # - # @option arguments [String] :job_id The ID of the job to open + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [Time] :timeout Controls the time to wait until a job has opened. Server default: 30m. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Query parameters can be specified in the body + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-open-job # def open_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.open_job' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -41,11 +55,11 @@ def open_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_open" - params = {} + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_open" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/post_calendar_events.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/post_calendar_events.rb index f98a9274db..50a5da4d67 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/post_calendar_events.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/post_calendar_events.rb @@ -15,22 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Posts scheduled events in a calendar. + # Add scheduled events to the calendar. # - # @option arguments [String] :calendar_id The ID of the calendar to modify + # @option arguments [String] :calendar_id A string that uniquely identifies a calendar. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body A list of events (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-calendar-event.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-post-calendar-events # def post_calendar_events(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.post_calendar_events' } + + defined_params = [:calendar_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'calendar_id' missing" unless arguments[:calendar_id] @@ -42,11 +49,11 @@ def post_calendar_events(arguments = {}) _calendar_id = arguments.delete(:calendar_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/calendars/#{Utils.__listify(_calendar_id)}/events" + path = "_ml/calendars/#{Utils.listify(_calendar_id)}/events" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/post_data.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/post_data.rb index d860c6e6e1..e7a38c065d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/post_data.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/post_data.rb @@ -15,24 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Sends data to an anomaly detection job for analysis. + # Send data to an anomaly detection job for analysis. + # IMPORTANT: For each job, data can be accepted from only a single connection at a time. + # It is not currently possible to post data to multiple jobs using wildcards or a comma-separated list. # - # @option arguments [String] :job_id The name of the job receiving the data - # @option arguments [String] :reset_start Optional parameter to specify the start of the bucket resetting range - # @option arguments [String] :reset_end Optional parameter to specify the end of the bucket resetting range + # @option arguments [String] :job_id Identifier for the anomaly detection job. The job must have a state of open to receive and process the data. (*Required*) + # @option arguments [String, Time] :reset_end Specifies the end of the bucket resetting range. + # @option arguments [String, Time] :reset_start Specifies the start of the bucket resetting range. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The data to process (*Required*) + # @option arguments [Hash] :body data # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-post-data # def post_data(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.post_data' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] @@ -44,11 +53,11 @@ def post_data(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_data" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_data" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/preview_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/preview_data_frame_analytics.rb index 86fa509837..c7f0924720 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/preview_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/preview_data_frame_analytics.rb @@ -15,22 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Previews that will be analyzed given a data frame analytics config. + # Preview features used by data frame analytics. + # Preview the extracted features used by a data frame analytics config. # - # @option arguments [String] :id The ID of the data frame analytics to preview + # @option arguments [String] :id Identifier for the data frame analytics job. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The data frame analytics config to preview + # @option arguments [Hash] :body request body # - # @see http://www.elastic.co/guide/en/elasticsearch/reference/current/preview-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-preview-data-frame-analytics # def preview_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.preview_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -45,14 +53,14 @@ def preview_data_frame_analytics(arguments = {}) end path = if _id - "_ml/data_frame/analytics/#{Utils.__listify(_id)}/_preview" + "_ml/data_frame/analytics/#{Utils.listify(_id)}/_preview" else - "_ml/data_frame/analytics/_preview" + '_ml/data_frame/analytics/_preview' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/preview_datafeed.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/preview_datafeed.rb index 6a373e8e75..ab209af122 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/preview_datafeed.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/preview_datafeed.rb @@ -15,24 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Previews a datafeed. + # Preview a datafeed. + # This API returns the first "page" of search results from a datafeed. + # You can preview an existing datafeed or provide configuration details for a datafeed + # and anomaly detection job in the API. The preview shows the structure of the data + # that will be passed to the anomaly detection engine. + # IMPORTANT: When Elasticsearch security features are enabled, the preview uses the credentials of the user that + # called the API. However, when the datafeed starts it uses the roles of the last user that created or updated the + # datafeed. To get a preview that accurately reflects the behavior of the datafeed, use the appropriate credentials. + # You can also use secondary authorization headers to supply the credentials. # - # @option arguments [String] :datafeed_id The ID of the datafeed to preview - # @option arguments [String] :start The start time from where the datafeed preview should begin - # @option arguments [String] :end The end time when the datafeed preview should stop + # @option arguments [String] :datafeed_id A numerical character string that uniquely identifies the datafeed. This identifier can contain lowercase + # alphanumeric characters (a-z and 0-9), hyphens, and underscores. It must start and end with alphanumeric + # characters. NOTE: If you use this path parameter, you cannot provide datafeed or anomaly detection job + # configuration details in the request body. + # @option arguments [String, Time] :start The start time from where the datafeed preview should begin + # @option arguments [String, Time] :end The end time when the datafeed preview should stop # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The datafeed config and job config with which to execute the preview + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-preview-datafeed # def preview_datafeed(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.preview_datafeed' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -47,14 +65,14 @@ def preview_datafeed(arguments = {}) end path = if _datafeed_id - "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}/_preview" + "_ml/datafeeds/#{Utils.listify(_datafeed_id)}/_preview" else - "_ml/datafeeds/_preview" + '_ml/datafeeds/_preview' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_calendar.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_calendar.rb index 7459b0bd60..92409bf37f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_calendar.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_calendar.rb @@ -15,22 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Instantiates a calendar. + # Create a calendar. # - # @option arguments [String] :calendar_id The ID of the calendar to create + # @option arguments [String] :calendar_id A string that uniquely identifies a calendar. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The calendar details + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-calendar # def put_calendar(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_calendar' } + + defined_params = [:calendar_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'calendar_id' missing" unless arguments[:calendar_id] arguments = arguments.clone @@ -41,11 +48,11 @@ def put_calendar(arguments = {}) _calendar_id = arguments.delete(:calendar_id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/calendars/#{Utils.__listify(_calendar_id)}" + path = "_ml/calendars/#{Utils.listify(_calendar_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_calendar_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_calendar_job.rb index beaf19c365..de1e603f3c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_calendar_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_calendar_job.rb @@ -15,22 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Adds an anomaly detection job to a calendar. + # Add anomaly detection job to calendar. # - # @option arguments [String] :calendar_id The ID of the calendar to modify - # @option arguments [String] :job_id The ID of the job to add to the calendar + # @option arguments [String] :calendar_id A string that uniquely identifies a calendar. (*Required*) + # @option arguments [String, Array] :job_id An identifier for the anomaly detection jobs. It can be a job identifier, a group name, or a comma-separated list of jobs or groups. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-calendar-job # def put_calendar_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_calendar_job' } + + defined_params = [:calendar_id, :job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'calendar_id' missing" unless arguments[:calendar_id] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] @@ -44,11 +51,11 @@ def put_calendar_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/calendars/#{Utils.__listify(_calendar_id)}/jobs/#{Utils.__listify(_job_id)}" + path = "_ml/calendars/#{Utils.listify(_calendar_id)}/jobs/#{Utils.listify(_job_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_data_frame_analytics.rb index ba2b626c7c..48798ae7fd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_data_frame_analytics.rb @@ -15,22 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Instantiates a data frame analytics job. + # Create a data frame analytics job. + # This API creates a data frame analytics job that performs an analysis on the + # source indices and stores the outcome in a destination index. + # By default, the query used in the source configuration is +{"match_all": {}}+. + # If the destination index does not exist, it is created automatically when you start the job. + # If you supply only a subset of the regression or classification parameters, hyperparameter optimization occurs. It determines a value for each of the undefined parameters. # - # @option arguments [String] :id The ID of the data frame analytics to create + # @option arguments [String] :id Identifier for the data frame analytics job. This identifier can contain + # lowercase alphanumeric characters (a-z and 0-9), hyphens, and + # underscores. It must start and end with alphanumeric characters. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The data frame analytics configuration (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-data-frame-analytics # def put_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -42,11 +56,11 @@ def put_data_frame_analytics(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/data_frame/analytics/#{Utils.__listify(_id)}" + path = "_ml/data_frame/analytics/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_datafeed.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_datafeed.rb index e8dea26e38..06c1376ebf 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_datafeed.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_datafeed.rb @@ -15,26 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Instantiates a datafeed. + # Create a datafeed. + # Datafeeds retrieve data from Elasticsearch for analysis by an anomaly detection job. + # You can associate only one datafeed with each anomaly detection job. + # The datafeed contains a query that runs at a defined interval (+frequency+). + # If you are concerned about delayed data, you can add a delay (+query_delay') at each interval. + # By default, the datafeed uses the following query:+{"match_all": {"boost": 1}}+. + # When Elasticsearch security features are enabled, your datafeed remembers which roles the user who created it had + # at the time of creation and runs the query using those same roles. If you provide secondary authorization headers, + # those credentials are used instead. + # You must use Kibana, this API, or the create anomaly detection jobs API to create a datafeed. Do not add a datafeed + # directly to the+.ml-config+index. Do not give users+write+privileges on the+.ml-config` index. # - # @option arguments [String] :datafeed_id The ID of the datafeed to create - # @option arguments [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false) - # @option arguments [Boolean] :allow_no_indices Ignore if the source indices expressions resolves to no concrete indices (default: true) - # @option arguments [Boolean] :ignore_throttled Ignore indices that are marked as throttled (default: true) - # @option arguments [String] :expand_wildcards Whether source index expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all) + # @option arguments [String] :datafeed_id A numerical character string that uniquely identifies the datafeed. + # This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + # It must start and end with alphanumeric characters. (*Required*) + # @option arguments [Boolean] :allow_no_indices If true, wildcard indices expressions that resolve into no concrete indices are ignored. This includes the +_all+ + # string or when no indices are specified. Server default: true. + # @option arguments [String, Array] :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. Server default: open. + # @option arguments [Boolean] :ignore_throttled If true, concrete, expanded, or aliased indices are ignored when frozen. Server default: true. + # @option arguments [Boolean] :ignore_unavailable If true, unavailable indices (missing or closed) are ignored. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The datafeed config (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-datafeed # def put_datafeed(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_datafeed' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'datafeed_id' missing" unless arguments[:datafeed_id] @@ -46,11 +67,11 @@ def put_datafeed(arguments = {}) _datafeed_id = arguments.delete(:datafeed_id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}" + path = "_ml/datafeeds/#{Utils.listify(_datafeed_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_filter.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_filter.rb index 73cd594b0c..e2389b083b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_filter.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_filter.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Instantiates a filter. + # Create a filter. + # A filter contains a list of strings. It can be used by one or more anomaly detection jobs. + # Specifically, filters are referenced in the +custom_rules+ property of detector configuration objects. # - # @option arguments [String] :filter_id The ID of the filter to create + # @option arguments [String] :filter_id A string that uniquely identifies a filter. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The filter details (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-filter.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-filter # def put_filter(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_filter' } + + defined_params = [:filter_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'filter_id' missing" unless arguments[:filter_id] @@ -42,11 +51,11 @@ def put_filter(arguments = {}) _filter_id = arguments.delete(:filter_id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/filters/#{Utils.__listify(_filter_id)}" + path = "_ml/filters/#{Utils.listify(_filter_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_job.rb index 6b4e85913a..ad5960bfa4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_job.rb @@ -15,26 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Instantiates an anomaly detection job. + # Create an anomaly detection job. + # If you include a +datafeed_config+, you must have read index privileges on the source index. + # If you include a +datafeed_config+ but do not provide a query, the datafeed uses +{"match_all": {"boost": 1}}+. # - # @option arguments [String] :job_id The ID of the job to create - # @option arguments [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false). Only set if datafeed_config is provided. - # @option arguments [Boolean] :allow_no_indices Ignore if the source indices expressions resolves to no concrete indices (default: true). Only set if datafeed_config is provided. - # @option arguments [Boolean] :ignore_throttled Ignore indices that are marked as throttled (default: true). Only set if datafeed_config is provided. - # @option arguments [String] :expand_wildcards Whether source index expressions should get expanded to open or closed indices (default: open). Only set if datafeed_config is provided. (options: open, closed, hidden, none, all) + # @option arguments [String] :job_id The identifier for the anomaly detection job. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It must start and end with alphanumeric characters. (*Required*) + # @option arguments [Boolean] :allow_no_indices If +true+, wildcard indices expressions that resolve into no concrete indices are ignored. This includes the + # +_all+ string or when no indices are specified. Server default: true. + # @option arguments [String, Array] :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. Valid values are: + # - +all+: Match any data stream or index, including hidden ones. + # - +closed+: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed. + # - +hidden+: Match hidden data streams and hidden indices. Must be combined with +open+, +closed+, or both. + # - +none+: Wildcard patterns are not accepted. + # - +open+: Match open, non-hidden indices. Also matches any non-hidden data stream. Server default: open. + # @option arguments [Boolean] :ignore_throttled If +true+, concrete, expanded or aliased indices are ignored when frozen. Server default: true. + # @option arguments [Boolean] :ignore_unavailable If +true+, unavailable indices (missing or closed) are ignored. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The job (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-job # def put_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_job' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] @@ -46,11 +62,11 @@ def put_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model.rb index 61bd0d3eab..2cefb4921b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model.rb @@ -15,24 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Creates an inference trained model. + # Create a trained model. + # Enable you to supply a trained model that is not created by data frame analytics. # - # @option arguments [String] :model_id The ID of the trained models to store - # @option arguments [Boolean] :defer_definition_decompression If set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations. - # @option arguments [Boolean] :wait_for_completion Whether to wait for all child operations(e.g. model download) to complete, before returning or not. Default to false + # @option arguments [String] :model_id The unique identifier of the trained model. (*Required*) + # @option arguments [Boolean] :defer_definition_decompression If set to +true+ and a +compressed_definition+ is provided, + # the request defers definition decompression and skips relevant + # validations. + # @option arguments [Boolean] :wait_for_completion Whether to wait for all child operations (e.g. model download) + # to complete. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The trained model configuration (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-trained-model # def put_trained_model(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_trained_model' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] @@ -44,11 +55,11 @@ def put_trained_model(arguments = {}) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/trained_models/#{Utils.__listify(_model_id)}" + path = "_ml/trained_models/#{Utils.listify(_model_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_alias.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_alias.rb index 77503e79df..a51e5433e1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_alias.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_alias.rb @@ -15,23 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Creates a new model alias (or reassigns an existing one) to refer to the trained model + # Create or update a trained model alias. + # A trained model alias is a logical name used to reference a single trained + # model. + # You can use aliases instead of trained model identifiers to make it easier to + # reference your models. For example, you can use aliases in inference + # aggregations and processors. + # An alias must be unique and refer to only a single trained model. However, + # you can have multiple aliases for each trained model. + # If you use this API to update an alias such that it references a different + # trained model ID and the model uses a different type of data frame analytics, + # an error occurs. For example, this situation occurs if you have a trained + # model for regression analysis and a trained model for classification + # analysis; you cannot reassign an alias from one type of trained model to + # another. + # If you use this API to update an alias and there are very few input fields in + # common between the old and new trained models for the model alias, the API + # returns a warning. # - # @option arguments [String] :model_alias The trained model alias to update - # @option arguments [String] :model_id The trained model where the model alias should be assigned - # @option arguments [Boolean] :reassign If the model_alias already exists and points to a separate model_id, this parameter must be true. Defaults to false. + # @option arguments [String] :model_alias The alias to create or update. This value cannot end in numbers. (*Required*) + # @option arguments [String] :model_id The identifier for the trained model that the alias refers to. (*Required*) + # @option arguments [Boolean] :reassign Specifies whether the alias gets reassigned to the specified trained + # model if it is already assigned to a different model. If the alias is + # already assigned and this parameter is false, the API returns an error. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models-aliases.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-trained-model-alias # def put_trained_model_alias(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_trained_model_alias' } + + defined_params = [:model_id, :model_alias].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] raise ArgumentError, "Required argument 'model_alias' missing" unless arguments[:model_alias] @@ -45,11 +70,11 @@ def put_trained_model_alias(arguments = {}) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/trained_models/#{Utils.__listify(_model_id)}/model_aliases/#{Utils.__listify(_model_alias)}" + path = "_ml/trained_models/#{Utils.listify(_model_id)}/model_aliases/#{Utils.listify(_model_alias)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part.rb index 0dfc798631..86b99c93c0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part.rb @@ -15,23 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Creates part of a trained model definition + # Create part of a trained model definition. # - # @option arguments [String] :model_id The ID of the trained model for this definition part - # @option arguments [Integer] :part The part number + # @option arguments [String] :model_id The unique identifier of the trained model. (*Required*) + # @option arguments [Integer] :part The definition part number. When the definition is loaded for inference the definition parts are streamed in the + # order of their part number. The first part must be +0+ and the final part must be +total_parts - 1+. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The trained model definition part (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-model-definition-part.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-trained-model-definition-part # def put_trained_model_definition_part(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_trained_model_definition_part' } + + defined_params = [:model_id, :part].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] raise ArgumentError, "Required argument 'part' missing" unless arguments[:part] @@ -46,11 +54,11 @@ def put_trained_model_definition_part(arguments = {}) _part = arguments.delete(:part) method = Elasticsearch::API::HTTP_PUT - path = "_ml/trained_models/#{Utils.__listify(_model_id)}/definition/#{Utils.__listify(_part)}" + path = "_ml/trained_models/#{Utils.listify(_model_id)}/definition/#{Utils.listify(_part)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_vocabulary.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_vocabulary.rb index f9d8566d3c..857bb3c395 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_vocabulary.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/put_trained_model_vocabulary.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Creates a trained model vocabulary + # Create a trained model vocabulary. + # This API is supported only for natural language processing (NLP) models. + # The vocabulary is stored in the index as described in +inference_config.*.vocabulary+ of the trained model definition. # - # @option arguments [String] :model_id The ID of the trained model for this vocabulary + # @option arguments [String] :model_id The unique identifier of the trained model. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The trained model vocabulary (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-model-vocabulary.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-put-trained-model-vocabulary # def put_trained_model_vocabulary(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.put_trained_model_vocabulary' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] @@ -42,11 +51,11 @@ def put_trained_model_vocabulary(arguments = {}) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_PUT - path = "_ml/trained_models/#{Utils.__listify(_model_id)}/vocabulary" + path = "_ml/trained_models/#{Utils.listify(_model_id)}/vocabulary" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/reset_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/reset_job.rb index 2155227ad9..4eed60c620 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/reset_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/reset_job.rb @@ -15,23 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Resets an existing anomaly detection job. + # Reset an anomaly detection job. + # All model state and results are deleted. The job is ready to start over as if + # it had just been created. + # It is not currently possible to reset multiple jobs using wildcards or a + # comma separated list. # - # @option arguments [String] :job_id The ID of the job to reset - # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning - # @option arguments [Boolean] :delete_user_annotations Should annotations added by the user be deleted + # @option arguments [String] :job_id The ID of the job to reset. (*Required*) + # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before + # returning. Server default: true. + # @option arguments [Boolean] :delete_user_annotations Specifies whether annotations that have been added by the + # user should be deleted along with any auto-generated annotations when the job is + # reset. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-reset-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-reset-job # def reset_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.reset_job' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] arguments = arguments.clone @@ -42,11 +56,11 @@ def reset_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_reset" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_reset" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/revert_model_snapshot.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/revert_model_snapshot.rb index 9dea6125aa..f89e841e8b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/revert_model_snapshot.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/revert_model_snapshot.rb @@ -15,24 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Reverts to a specific snapshot. + # Revert to a snapshot. + # The machine learning features react quickly to anomalous input, learning new + # behaviors in data. Highly anomalous input increases the variance in the + # models whilst the system learns whether this is a new step-change in behavior + # or a one-off event. In the case where this anomalous input is known to be a + # one-off, then it might be appropriate to reset the model state to a time + # before this event. For example, you might consider reverting to a saved + # snapshot after Black Friday or a critical system failure. # - # @option arguments [String] :job_id The ID of the job to fetch - # @option arguments [String] :snapshot_id The ID of the snapshot to revert to - # @option arguments [Boolean] :delete_intervening_results Should we reset the results back to the time of the snapshot? + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String] :snapshot_id You can specify +empty+ as the . Reverting to the empty + # snapshot means the anomaly detection job starts learning a new model from + # scratch when it is started. (*Required*) + # @option arguments [Boolean] :delete_intervening_results If true, deletes the results in the time period between the latest + # results and the time of the reverted snapshot. It also resets the model + # to accept records for this time period. If you choose not to delete + # intervening results when reverting a snapshot, the job will not accept + # input data that is older than the current time. If you want to resend + # data, then delete the intervening results. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Reversion options + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-revert-model-snapshot # def revert_model_snapshot(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.revert_model_snapshot' } + + defined_params = [:job_id, :snapshot_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] raise ArgumentError, "Required argument 'snapshot_id' missing" unless arguments[:snapshot_id] @@ -46,11 +67,11 @@ def revert_model_snapshot(arguments = {}) _snapshot_id = arguments.delete(:snapshot_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/model_snapshots/#{Utils.__listify(_snapshot_id)}/_revert" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/model_snapshots/#{Utils.listify(_snapshot_id)}/_revert" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/set_upgrade_mode.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/set_upgrade_mode.rb index 7e183cf4cb..6466ca4643 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/set_upgrade_mode.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/set_upgrade_mode.rb @@ -15,33 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Sets a cluster wide upgrade_mode setting that prepares machine learning indices for an upgrade. + # Set upgrade_mode for ML indices. + # Sets a cluster wide upgrade_mode setting that prepares machine learning + # indices for an upgrade. + # When upgrading your cluster, in some circumstances you must restart your + # nodes and reindex your machine learning indices. In those circumstances, + # there must be no machine learning jobs running. You can close the machine + # learning jobs, do the upgrade, then open all the jobs again. Alternatively, + # you can use this API to temporarily halt tasks associated with the jobs and + # datafeeds and prevent new jobs from opening. You can also use this API + # during upgrades that do not require you to reindex your machine learning + # indices, though stopping jobs is not a requirement in that case. + # You can see the current value for the upgrade_mode setting by using the get + # machine learning info API. # - # @option arguments [Boolean] :enabled Whether to enable upgrade_mode ML setting or not. Defaults to false. - # @option arguments [Time] :timeout Controls the time to wait before action times out. Defaults to 30 seconds + # @option arguments [Boolean] :enabled When +true+, it enables +upgrade_mode+ which temporarily halts all job + # and datafeed tasks and prohibits new job and datafeed tasks from + # starting. + # @option arguments [Time] :timeout The time to wait for the request to be completed. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-set-upgrade-mode # def set_upgrade_mode(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.set_upgrade_mode' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_ml/set_upgrade_mode" + path = '_ml/set_upgrade_mode' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_data_frame_analytics.rb index ef225f1514..cfc856a952 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_data_frame_analytics.rb @@ -15,38 +15,58 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Starts a data frame analytics job. + # Start a data frame analytics job. + # A data frame analytics job can be started and stopped multiple times + # throughout its lifecycle. + # If the destination index does not exist, it is created automatically the + # first time you start the data frame analytics job. The + # +index.number_of_shards+ and +index.number_of_replicas+ settings for the + # destination index are copied from the source index. If there are multiple + # source indices, the destination index copies the highest setting values. The + # mappings for the destination index are also copied from the source indices. + # If there are any mapping conflicts, the job fails to start. + # If the destination index exists, it is used as is. You can therefore set up + # the destination index in advance with custom settings and mappings. # - # @option arguments [String] :id The ID of the data frame analytics to start - # @option arguments [Time] :timeout Controls the time to wait until the task has started. Defaults to 20 seconds + # @option arguments [String] :id Identifier for the data frame analytics job. This identifier can contain + # lowercase alphanumeric characters (a-z and 0-9), hyphens, and + # underscores. It must start and end with alphanumeric characters. (*Required*) + # @option arguments [Time] :timeout Controls the amount of time to wait until the data frame analytics job + # starts. Server default: 20s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The start data frame analytics parameters # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-start-data-frame-analytics # def start_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.start_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = nil _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_POST - path = "_ml/data_frame/analytics/#{Utils.__listify(_id)}/_start" + path = "_ml/data_frame/analytics/#{Utils.listify(_id)}/_start" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb index 625a297763..315f2f7137 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_datafeed.rb @@ -15,25 +15,55 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Starts one or more datafeeds. + # Start datafeeds. + # A datafeed must be started in order to retrieve data from Elasticsearch. A datafeed can be started and stopped + # multiple times throughout its lifecycle. + # Before you can start a datafeed, the anomaly detection job must be open. Otherwise, an error occurs. + # If you restart a stopped datafeed, it continues processing input data from the next millisecond after it was stopped. + # If new data was indexed for that exact millisecond between stopping and starting, it will be ignored. + # When Elasticsearch security features are enabled, your datafeed remembers which roles the last user to create or + # update it had at the time of creation or update and runs the query using those same roles. If you provided secondary + # authorization headers when you created or updated the datafeed, those credentials are used instead. # - # @option arguments [String] :datafeed_id The ID of the datafeed to start - # @option arguments [String] :start The start time from where the datafeed should begin - # @option arguments [String] :end The end time when the datafeed should stop. When not set, the datafeed continues in real time - # @option arguments [Time] :timeout Controls the time to wait until a datafeed has started. Default to 20 seconds + # @option arguments [String] :datafeed_id A numerical character string that uniquely identifies the datafeed. This identifier can contain lowercase + # alphanumeric characters (a-z and 0-9), hyphens, and underscores. It must start and end with alphanumeric + # characters. (*Required*) + # @option arguments [String, Time] :end The time that the datafeed should end, which can be specified by using one of the following formats: + # - ISO 8601 format with milliseconds, for example +2017-01-22T06:00:00.000Z+ + # - ISO 8601 format without milliseconds, for example +2017-01-22T06:00:00+00:00+ + # - Milliseconds since the epoch, for example +1485061200000+ + # Date-time arguments using either of the ISO 8601 formats must have a time zone designator, where +Z+ is accepted + # as an abbreviation for UTC time. When a URL is expected (for example, in browsers), the +++ used in time zone + # designators must be encoded as +%2B+. + # The end time value is exclusive. If you do not specify an end time, the datafeed + # runs continuously. + # @option arguments [String, Time] :start The time that the datafeed should begin, which can be specified by using the same formats as the +end+ parameter. + # This value is inclusive. + # If you do not specify a start time and the datafeed is associated with a new anomaly detection job, the analysis + # starts from the earliest time for which data is available. + # If you restart a stopped datafeed and specify a start value that is earlier than the timestamp of the latest + # processed record, the datafeed continues from 1 millisecond after the timestamp of the latest processed record. + # @option arguments [Time] :timeout Specifies the amount of time to wait until a datafeed starts. Server default: 20s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The start datafeed parameters + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-start-datafeed # def start_datafeed(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.start_datafeed' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'datafeed_id' missing" unless arguments[:datafeed_id] arguments = arguments.clone @@ -44,11 +74,11 @@ def start_datafeed(arguments = {}) _datafeed_id = arguments.delete(:datafeed_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}/_start" + path = "_ml/datafeeds/#{Utils.listify(_datafeed_id)}/_start" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_trained_model_deployment.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_trained_model_deployment.rb index 155e5e673b..6af12449bb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_trained_model_deployment.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/start_trained_model_deployment.rb @@ -15,44 +15,66 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions # Start a trained model deployment. + # It allocates the model to every machine learning node. # - # @option arguments [String] :model_id The unique identifier of the trained model. (*Required*) - # @option arguments [String] :cache_size A byte-size value for configuring the inference cache size. For example, 20mb. - # @option arguments [String] :deployment_id The Id of the new deployment. Defaults to the model_id if not set. - # @option arguments [Integer] :number_of_allocations The total number of allocations this model is assigned across machine learning nodes. - # @option arguments [Integer] :threads_per_allocation The number of threads used by each model allocation during inference. + # @option arguments [String] :model_id The unique identifier of the trained model. Currently, only PyTorch models are supported. (*Required*) + # @option arguments [Integer, String] :cache_size The inference cache size (in memory outside the JVM heap) per node for the model. + # The default value is the same size as the +model_size_bytes+. To disable the cache, + # +0b+ can be provided. + # @option arguments [String] :deployment_id A unique identifier for the deployment of the model. + # @option arguments [Integer] :number_of_allocations The number of model allocations on each node where the model is deployed. + # All allocations on a node share the same copy of the model in memory but use + # a separate set of threads to evaluate the model. + # Increasing this value generally increases the throughput. + # If this setting is greater than the number of hardware threads + # it will automatically be changed to a value less than the number of hardware threads. + # If adaptive_allocations is enabled, do not set this value, because it’s automatically set. Server default: 1. # @option arguments [String] :priority The deployment priority. - # @option arguments [Integer] :queue_capacity Controls how many inference requests are allowed in the queue at a time. - # @option arguments [Time] :timeout Controls the amount of time to wait for the model to deploy. - # @option arguments [String] :wait_for The allocation status for which to wait (options: starting, started, fully_allocated) + # @option arguments [Integer] :queue_capacity Specifies the number of inference requests that are allowed in the queue. After the number of requests exceeds + # this value, new requests are rejected with a 429 error. Server default: 1024. + # @option arguments [Integer] :threads_per_allocation Sets the number of threads used by each model allocation during inference. This generally increases + # the inference speed. The inference process is a compute-bound process; any number + # greater than the number of available hardware threads on the machine does not increase the + # inference speed. If this setting is greater than the number of hardware threads + # it will automatically be changed to a value less than the number of hardware threads. Server default: 1. + # @option arguments [Time] :timeout Specifies the amount of time to wait for the model to deploy. Server default: 20s. + # @option arguments [String] :wait_for Specifies the allocation status to wait for before returning. Server default: started. # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-trained-model-deployment.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-start-trained-model-deployment # def start_trained_model_deployment(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.start_trained_model_deployment' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = arguments.delete(:body) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/trained_models/#{Utils.__listify(_model_id)}/deployment/_start" + path = "_ml/trained_models/#{Utils.listify(_model_id)}/deployment/_start" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_data_frame_analytics.rb index 805fc84dbe..8aa0ea5dc2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_data_frame_analytics.rb @@ -15,40 +15,59 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Stops one or more data frame analytics jobs. + # Stop data frame analytics jobs. + # A data frame analytics job can be started and stopped multiple times + # throughout its lifecycle. # - # @option arguments [String] :id The ID of the data frame analytics to stop - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) - # @option arguments [Boolean] :force True if the data frame analytics should be forcefully stopped - # @option arguments [Time] :timeout Controls the time to wait until the task has stopped. Defaults to 20 seconds + # @option arguments [String] :id Identifier for the data frame analytics job. This identifier can contain + # lowercase alphanumeric characters (a-z and 0-9), hyphens, and + # underscores. It must start and end with alphanumeric characters. (*Required*) + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no data frame analytics + # jobs that match. + # - Contains the _all string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # The default value is true, which returns an empty data_frame_analytics + # array when there are no matches and the subset of results when there are + # partial matches. If this parameter is false, the request returns a 404 + # status code when there are no matches or only partial matches. Server default: true. + # @option arguments [Boolean] :force If true, the data frame analytics job is stopped forcefully. + # @option arguments [Time] :timeout Controls the amount of time to wait until the data frame analytics job + # stops. Defaults to 20 seconds. Server default: 20s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The stop data frame analytics parameters # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-stop-data-frame-analytics # def stop_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.stop_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = nil _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_POST - path = "_ml/data_frame/analytics/#{Utils.__listify(_id)}/_stop" + path = "_ml/data_frame/analytics/#{Utils.listify(_id)}/_stop" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_datafeed.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_datafeed.rb index 8d908a4aaf..60907e993f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_datafeed.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_datafeed.rb @@ -15,26 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Stops one or more datafeeds. + # Stop datafeeds. + # A datafeed that is stopped ceases to retrieve data from Elasticsearch. A datafeed can be started and stopped + # multiple times throughout its lifecycle. # - # @option arguments [String] :datafeed_id The ID of the datafeed to stop - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - # @option arguments [Boolean] :allow_no_datafeeds Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) *Deprecated* - # @option arguments [Boolean] :force True if the datafeed should be forcefully stopped. - # @option arguments [Time] :timeout Controls the time to wait until a datafeed has stopped. Default to 20 seconds + # @option arguments [String] :datafeed_id Identifier for the datafeed. You can stop multiple datafeeds in a single API request by using a comma-separated + # list of datafeeds or a wildcard expression. You can close all datafeeds by using +_all+ or by specifying +*+ as + # the identifier. (*Required*) + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no datafeeds that match. + # - Contains the +_all+ string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If +true+, the API returns an empty datafeeds array when there are no matches and the subset of results when + # there are partial matches. If +false+, the API returns a 404 status code when there are no matches or only + # partial matches. Server default: true. + # @option arguments [Boolean] :force If +true+, the datafeed is stopped forcefully. + # @option arguments [Time] :timeout Specifies the amount of time to wait until a datafeed stops. Server default: 20s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The URL params optionally sent in the body + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-stop-datafeed # def stop_datafeed(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.stop_datafeed' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'datafeed_id' missing" unless arguments[:datafeed_id] arguments = arguments.clone @@ -45,11 +61,11 @@ def stop_datafeed(arguments = {}) _datafeed_id = arguments.delete(:datafeed_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}/_stop" + path = "_ml/datafeeds/#{Utils.listify(_datafeed_id)}/_stop" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_trained_model_deployment.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_trained_model_deployment.rb index 44c21207f7..9316c25ad1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_trained_model_deployment.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/stop_trained_model_deployment.rb @@ -15,9 +15,9 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning @@ -25,29 +25,39 @@ module Actions # Stop a trained model deployment. # # @option arguments [String] :model_id The unique identifier of the trained model. (*Required*) - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no deployments. (This includes `_all` string or when no deployments have been specified) - # @option arguments [Boolean] :force True if the deployment should be forcefully stopped + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: contains wildcard expressions and there are no deployments that match; + # contains the +_all+ string or no identifiers and there are no matches; or contains wildcard expressions and + # there are only partial matches. By default, it returns an empty array when there are no matches and the subset of results when there are partial matches. + # If +false+, the request returns a 404 status code when there are no matches or only partial matches. Server default: true. + # @option arguments [Boolean] :force Forcefully stops the deployment, even if it is used by ingest pipelines. You can't use these pipelines until you + # restart the model deployment. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The stop deployment parameters # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-trained-model-deployment.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-stop-trained-model-deployment # def stop_trained_model_deployment(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.stop_trained_model_deployment' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = nil _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/trained_models/#{Utils.__listify(_model_id)}/deployment/_stop" + path = "_ml/trained_models/#{Utils.listify(_model_id)}/deployment/_stop" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_data_frame_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_data_frame_analytics.rb index e938d30701..1059a58d58 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_data_frame_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_data_frame_analytics.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Updates certain properties of a data frame analytics job. + # Update a data frame analytics job. # - # @option arguments [String] :id The ID of the data frame analytics to update + # @option arguments [String] :id Identifier for the data frame analytics job. This identifier can contain + # lowercase alphanumeric characters (a-z and 0-9), hyphens, and + # underscores. It must start and end with alphanumeric characters. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The data frame analytics settings to update (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-dfanalytics.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-update-data-frame-analytics # def update_data_frame_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.update_data_frame_analytics' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -42,11 +51,11 @@ def update_data_frame_analytics(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_POST - path = "_ml/data_frame/analytics/#{Utils.__listify(_id)}/_update" + path = "_ml/data_frame/analytics/#{Utils.listify(_id)}/_update" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_datafeed.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_datafeed.rb index 1f1c1a8b30..85074eb75a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_datafeed.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_datafeed.rb @@ -15,26 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Updates certain properties of a datafeed. + # Update a datafeed. + # You must stop and start the datafeed for the changes to be applied. + # When Elasticsearch security features are enabled, your datafeed remembers which roles the user who updated it had at + # the time of the update and runs the query using those same roles. If you provide secondary authorization headers, + # those credentials are used instead. # - # @option arguments [String] :datafeed_id The ID of the datafeed to update - # @option arguments [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false) - # @option arguments [Boolean] :allow_no_indices Ignore if the source indices expressions resolves to no concrete indices (default: true) - # @option arguments [Boolean] :ignore_throttled Ignore indices that are marked as throttled (default: true) - # @option arguments [String] :expand_wildcards Whether source index expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all) + # @option arguments [String] :datafeed_id A numerical character string that uniquely identifies the datafeed. + # This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + # It must start and end with alphanumeric characters. (*Required*) + # @option arguments [Boolean] :allow_no_indices If +true+, wildcard indices expressions that resolve into no concrete indices are ignored. This includes the + # +_all+ string or when no indices are specified. Server default: true. + # @option arguments [String, Array] :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. Valid values are: + # - +all+: Match any data stream or index, including hidden ones. + # - +closed+: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed. + # - +hidden+: Match hidden data streams and hidden indices. Must be combined with +open+, +closed+, or both. + # - +none+: Wildcard patterns are not accepted. + # - +open+: Match open, non-hidden indices. Also matches any non-hidden data stream. Server default: open. + # @option arguments [Boolean] :ignore_throttled If +true+, concrete, expanded or aliased indices are ignored when frozen. Server default: true. + # @option arguments [Boolean] :ignore_unavailable If +true+, unavailable indices (missing or closed) are ignored. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The datafeed update settings (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-update-datafeed # def update_datafeed(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.update_datafeed' } + + defined_params = [:datafeed_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'datafeed_id' missing" unless arguments[:datafeed_id] @@ -46,11 +66,11 @@ def update_datafeed(arguments = {}) _datafeed_id = arguments.delete(:datafeed_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/datafeeds/#{Utils.__listify(_datafeed_id)}/_update" + path = "_ml/datafeeds/#{Utils.listify(_datafeed_id)}/_update" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_filter.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_filter.rb index 00ebc41e81..06ee47086e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_filter.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_filter.rb @@ -15,22 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Updates the description of a filter, adds items, or removes items. + # Update a filter. + # Updates the description of a filter, adds items, or removes items from the list. # - # @option arguments [String] :filter_id The ID of the filter to update + # @option arguments [String] :filter_id A string that uniquely identifies a filter. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The filter update (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-filter.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-update-filter # def update_filter(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.update_filter' } + + defined_params = [:filter_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'filter_id' missing" unless arguments[:filter_id] @@ -42,11 +50,11 @@ def update_filter(arguments = {}) _filter_id = arguments.delete(:filter_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/filters/#{Utils.__listify(_filter_id)}/_update" + path = "_ml/filters/#{Utils.listify(_filter_id)}/_update" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_job.rb index 0692dfd7eb..2d98a3019a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_job.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_job.rb @@ -15,22 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions + # Update an anomaly detection job. # Updates certain properties of an anomaly detection job. # - # @option arguments [String] :job_id The ID of the job to create + # @option arguments [String] :job_id Identifier for the job. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The job update settings (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-update-job # def update_job(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.update_job' } + + defined_params = [:job_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] @@ -42,11 +50,11 @@ def update_job(arguments = {}) _job_id = arguments.delete(:job_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/_update" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/_update" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_model_snapshot.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_model_snapshot.rb index 7cdf14a574..dfcaf0190b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_model_snapshot.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_model_snapshot.rb @@ -15,23 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions + # Update a snapshot. # Updates certain properties of a snapshot. # - # @option arguments [String] :job_id The ID of the job to fetch - # @option arguments [String] :snapshot_id The ID of the snapshot to update + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String] :snapshot_id Identifier for the model snapshot. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The model snapshot properties to update (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-update-model-snapshot # def update_model_snapshot(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.update_model_snapshot' } + + defined_params = [:job_id, :snapshot_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] raise ArgumentError, "Required argument 'snapshot_id' missing" unless arguments[:snapshot_id] @@ -46,11 +54,11 @@ def update_model_snapshot(arguments = {}) _snapshot_id = arguments.delete(:snapshot_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/model_snapshots/#{Utils.__listify(_snapshot_id)}/_update" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/model_snapshots/#{Utils.listify(_snapshot_id)}/_update" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_trained_model_deployment.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_trained_model_deployment.rb index 1b592c79f5..5461ecc3ef 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_trained_model_deployment.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/update_trained_model_deployment.rb @@ -15,27 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Updates certain properties of trained model deployment. - # This functionality is in Beta and is subject to change. The design and - # code is less mature than official GA features and is being provided - # as-is with no warranties. Beta features are not subject to the support - # SLA of official GA features. + # Update a trained model deployment. # - # @option arguments [String] :model_id The unique identifier of the trained model. + # @option arguments [String] :model_id The unique identifier of the trained model. Currently, only PyTorch models are supported. (*Required*) + # @option arguments [Integer] :number_of_allocations The number of model allocations on each node where the model is deployed. + # All allocations on a node share the same copy of the model in memory but use + # a separate set of threads to evaluate the model. + # Increasing this value generally increases the throughput. + # If this setting is greater than the number of hardware threads + # it will automatically be changed to a value less than the number of hardware threads. Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The updated trained model deployment settings (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-trained-model-deployment.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-update-trained-model-deployment # def update_trained_model_deployment(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + request_opts = { endpoint: arguments[:endpoint] || 'ml.update_trained_model_deployment' } + + defined_params = [:model_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id] arguments = arguments.clone @@ -46,11 +54,11 @@ def update_trained_model_deployment(arguments = {}) _model_id = arguments.delete(:model_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/trained_models/#{Utils.__listify(_model_id)}/deployment/_update" - params = {} + path = "_ml/trained_models/#{Utils.listify(_model_id)}/deployment/_update" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/upgrade_job_snapshot.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/upgrade_job_snapshot.rb index 9042b13be7..2d1ca46d0c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/upgrade_job_snapshot.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/upgrade_job_snapshot.rb @@ -15,24 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module MachineLearning module Actions - # Upgrades a given job snapshot to the current major version. + # Upgrade a snapshot. + # Upgrade an anomaly detection model snapshot to the latest major version. + # Over time, older snapshot formats are deprecated and removed. Anomaly + # detection jobs support only snapshots that are from the current or previous + # major version. + # This API provides a means to upgrade a snapshot to the current major version. + # This aids in preparing the cluster for an upgrade to the next major version. + # Only one snapshot per anomaly detection job can be upgraded at a time and the + # upgraded snapshot cannot be the current snapshot of the anomaly detection + # job. # - # @option arguments [String] :job_id The ID of the job - # @option arguments [String] :snapshot_id The ID of the snapshot - # @option arguments [Time] :timeout How long should the API wait for the job to be opened and the old snapshot to be loaded. - # @option arguments [Boolean] :wait_for_completion Should the request wait until the task is complete before responding to the caller. Default is false. + # @option arguments [String] :job_id Identifier for the anomaly detection job. (*Required*) + # @option arguments [String] :snapshot_id A numerical character string that uniquely identifies the model snapshot. (*Required*) + # @option arguments [Boolean] :wait_for_completion When true, the API won’t respond until the upgrade is complete. + # Otherwise, it responds as soon as the upgrade task is assigned to a node. + # @option arguments [Time] :timeout Controls the time to wait for the request to complete. Server default: 30m. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-upgrade-job-model-snapshot.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-upgrade-job-snapshot # def upgrade_job_snapshot(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ml.upgrade_job_snapshot' } + + defined_params = [:job_id, :snapshot_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'job_id' missing" unless arguments[:job_id] raise ArgumentError, "Required argument 'snapshot_id' missing" unless arguments[:snapshot_id] @@ -46,11 +63,11 @@ def upgrade_job_snapshot(arguments = {}) _snapshot_id = arguments.delete(:snapshot_id) method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/#{Utils.__listify(_job_id)}/model_snapshots/#{Utils.__listify(_snapshot_id)}/_upgrade" + path = "_ml/anomaly_detectors/#{Utils.listify(_job_id)}/model_snapshots/#{Utils.listify(_snapshot_id)}/_upgrade" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/validate.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/validate.rb deleted file mode 100644 index 7982cc8a9f..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/validate.rb +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module MachineLearning - module Actions - # Validates an anomaly detection job. - # - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The job config (*Required*) - # - # @see https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html - # - def validate(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/_validate" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/validate_detector.rb b/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/validate_detector.rb deleted file mode 100644 index 8a577a7ae9..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/machine_learning/validate_detector.rb +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module MachineLearning - module Actions - # Validates an anomaly detection detector. - # - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The detector (*Required*) - # - # @see https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html - # - def validate_detector(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - method = Elasticsearch::API::HTTP_POST - path = "_ml/anomaly_detectors/_validate/detector" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/mget.rb b/elasticsearch-api/lib/elasticsearch/api/actions/mget.rb index 64611bbb83..ddba03593c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/mget.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/mget.rb @@ -15,49 +15,72 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows to get multiple documents in one request. + # Get multiple documents. + # Get multiple JSON documents by ID from one or more indices. + # If you specify an index in the request URI, you only need to specify the document IDs in the request body. + # To ensure fast responses, this multi get (mget) API responds with partial results if one or more shards fail. + # **Filter source fields** + # By default, the +_source+ field is returned for every document (if stored). + # Use the +_source+ and +_source_include+ or +source_exclude+ attributes to filter what fields are returned for a particular document. + # You can include the +_source+, +_source_includes+, and +_source_excludes+ query parameters in the request URI to specify the defaults to use when there are no per-document instructions. + # **Get stored fields** + # Use the +stored_fields+ attribute to specify the set of stored fields you want to retrieve. + # Any requested fields that are not stored are ignored. + # You can include the +stored_fields+ query parameter in the request URI to specify the defaults to use when there are no per-document instructions. # - # @option arguments [String] :index The name of the index - # @option arguments [Boolean] :force_synthetic_source Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in 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 [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 arguments [Boolean] :force_synthetic_source Should this request force synthetic _source? + # Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. + # Fetches with this enabled will be slower the enabling synthetic source natively in the index. + # @option arguments [String] :preference Specifies the node or shard the operation should be performed on. Random by default. + # @option arguments [Boolean] :realtime If +true+, the request is real-time as opposed to near-real-time. Server default: true. + # @option arguments [Boolean] :refresh If +true+, the request refreshes relevant shards before retrieving documents. + # @option arguments [String] :routing Custom value used to route operations to a specific shard. + # @option arguments [Boolean, String, Array] :_source True or false to return the +_source+ field or not, or a list of fields to return. + # @option arguments [String, Array] :_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 arguments [String, Array] :_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 arguments [String, Array] :stored_fields If +true+, retrieves the document fields stored in the index rather than the document +_source+. Server default: false. # @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*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-mget # def mget(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'mget' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_mget" + "#{Utils.listify(_index)}/_mget" else - "_mget" + '_mget' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/migration/deprecations.rb b/elasticsearch-api/lib/elasticsearch/api/actions/migration/deprecations.rb index 7b29369a02..dcf94e965d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/migration/deprecations.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/migration/deprecations.rb @@ -15,38 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Migration module Actions - # Retrieves information about different cluster, node, and index level settings that use deprecated features that will be removed or changed in the next major version. + # Get deprecation information. + # Get information about different cluster, node, and index level settings that use deprecated features that will be removed or changed in the next major version. + # TIP: This APIs is designed for indirect use by the Upgrade Assistant. + # You are strongly recommended to use the Upgrade Assistant. # - # @option arguments [String] :index Index pattern + # @option arguments [String] :index Comma-separate list of data streams or indices to check. Wildcard (*) expressions are supported. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-migration-deprecations # def deprecations(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'migration.deprecations' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "#{Utils.__listify(_index)}/_migration/deprecations" + "#{Utils.listify(_index)}/_migration/deprecations" else - "_migration/deprecations" + '_migration/deprecations' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/migration/get_feature_upgrade_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/migration/get_feature_upgrade_status.rb index 0b3bbfa799..ea9e243fbf 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/migration/get_feature_upgrade_status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/migration/get_feature_upgrade_status.rb @@ -15,31 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Migration module Actions - # Find out whether system features need to be upgraded or not + # Get feature migration information. + # Version upgrades sometimes require changes to how features store configuration information and data in system indices. + # Check which features need to be migrated and the status of any migrations that are in progress. + # TIP: This API is designed for indirect use by the Upgrade Assistant. + # You are strongly recommended to use the Upgrade Assistant. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-migration-get-feature-upgrade-status # def get_feature_upgrade_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'migration.get_feature_upgrade_status' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_migration/system_features" + path = '_migration/system_features' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/migration/post_feature_upgrade.rb b/elasticsearch-api/lib/elasticsearch/api/actions/migration/post_feature_upgrade.rb index 7e81fe6a48..65a6253807 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/migration/post_feature_upgrade.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/migration/post_feature_upgrade.rb @@ -15,31 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Migration module Actions - # Begin upgrades for system features + # Start the feature migration. + # Version upgrades sometimes require changes to how features store configuration information and data in system indices. + # This API starts the automatic migration process. + # Some functionality might be temporarily unavailable during the migration process. + # TIP: The API is designed for indirect use by the Upgrade Assistant. We strongly recommend you use the Upgrade Assistant. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-feature-upgrade.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-migration-get-feature-upgrade-status # def post_feature_upgrade(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'migration.post_feature_upgrade' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_migration/system_features" + path = '_migration/system_features' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/monitoring/bulk.rb b/elasticsearch-api/lib/elasticsearch/api/actions/monitoring/bulk.rb deleted file mode 100644 index 5b3eab461c..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/monitoring/bulk.rb +++ /dev/null @@ -1,74 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Monitoring - module Actions - # Used by the monitoring features to send monitoring data. - # - # @option arguments [String] :type Default document type for items which don't provide one *Deprecated* - # @option arguments [String] :system_id Identifier of the monitored system - # @option arguments [String] :system_api_version API Version of the monitored system - # @option arguments [String] :interval Collection interval (e.g., '10s' or '10000ms') of the payload - # @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 Elasticsearch::API::Utils.__bulkify documentation. - # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 - # - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/monitor-elasticsearch-cluster.html - # - def bulk(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _type = arguments.delete(:type) - - method = Elasticsearch::API::HTTP_POST - path = if _type - "_monitoring/#{Utils.__listify(_type)}/bulk" - else - "_monitoring/bulk" - end - params = Utils.process_params(arguments) - - if body.is_a? Array - payload = Elasticsearch::API::Utils.__bulkify(body) - else - payload = body - end - - headers.merge!("Content-Type" => "application/x-ndjson") - Elasticsearch::API::Response.new( - perform_request(method, path, params, payload, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb index 7ee4ed4aa0..8a9ff5ce7e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb @@ -15,70 +15,99 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows to execute several search operations in one request. + # Run multiple searches. + # The format of the request is similar to the bulk API format and makes use of the newline delimited JSON (NDJSON) format. + # The structure is as follows: + # + + # header\n + # body\n + # header\n + # body\n + # + + # This structure is specifically optimized to reduce parsing if a specific search ends up redirected to another node. + # IMPORTANT: The final line of data must end with a newline character +\n+. + # Each newline character may be preceded by a carriage return +\r+. + # When sending requests to this endpoint the +Content-Type+ header should be set to +application/x-ndjson+. # - # @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 [String, Array] :index Comma-separated list of data streams, indices, and index aliases to search. + # @option arguments [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 indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. + # @option arguments [Boolean] :ccs_minimize_roundtrips If true, network roundtrips between the coordinating node and remote clusters are minimized for cross-cluster search requests. Server default: true. + # @option arguments [String, Array] :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. + # @option arguments [Boolean] :ignore_throttled If true, concrete, expanded or aliased indices are ignored when frozen. + # @option arguments [Boolean] :ignore_unavailable If true, missing or closed indices are not included in the response. + # @option arguments [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) + # This functionality reruns each named query on every hit in a search response. + # Typically, this adds a small overhead to a request. + # However, using computationally expensive named queries on a large number of hits may add significant overhead. + # @option arguments [Integer] :max_concurrent_searches Maximum number of concurrent searches the multi search API can execute. + # Defaults to +max(1, (# of data nodes * min(search thread pool size, 10)))+. + # @option arguments [Integer] :max_concurrent_shard_requests Maximum number of concurrent shard requests that each sub-search request executes per node. Server default: 5. + # @option arguments [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 arguments [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 arguments [String] :routing Custom routing value used to route search operations to a specific shard. + # @option arguments [String] :search_type Indicates whether global term and document frequencies should be used when scoring returned documents. + # @option arguments [Boolean] :typed_keys Specifies whether aggregation and suggester names should be prefixed by their respective types in the response. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request definitions (metadata-search request definition pairs), separated by newlines (*Required*) + # @option arguments [Hash] :body searches # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-msearch # def msearch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'msearch' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_msearch" + "#{Utils.listify(_index)}/_msearch" else - "_msearch" + '_msearch' end params = Utils.process_params(arguments) - case - when body.is_a?(Array) && body.any? { |d| d.has_key? :search } - payload = body - .inject([]) do |sum, item| - meta = item - data = meta.delete(:search) + 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 - sum - end - .map { |item| Elasticsearch::API.serializer.dump(item) } - payload << "" unless payload.empty? + sum << meta + sum << data + end.map { |item| Elasticsearch::API.serializer.dump(item) } + payload << '' unless payload.empty? payload = payload.join("\n") - when body.is_a?(Array) + elsif body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) } - payload << "" unless payload.empty? + payload << '' unless payload.empty? payload = payload.join("\n") else payload = body end - headers.merge!("Content-Type" => "application/x-ndjson") + headers.merge!({ + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + }) Elasticsearch::API::Response.new( - perform_request(method, path, params, payload, headers) + perform_request(method, path, params, payload, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb index f4e4457771..04e0cc75fb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb @@ -15,56 +15,77 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows to execute several search template operations in one request. + # Run multiple templated searches. + # Run multiple templated searches with a single request. + # If you are providing a text file or text input to +curl+, use the +--data-binary+ flag instead of +-d+ to preserve newlines. + # For example: + # + + # $ cat requests + # { "index": "my-index" } + # { "id": "my-search-template", "params": { "query_string": "hello world", "from": 0, "size": 10 }} + # { "index": "my-other-index" } + # { "id": "my-other-search-template", "params": { "query_type": "match_all" }} + # $ curl -H "Content-Type: application/x-ndjson" -XGET localhost:9200/_msearch/template --data-binary "@requests"; echo + # + # - # @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 [String, Array] :index A comma-separated list of data streams, indices, and aliases to search. + # It supports wildcards (+*+). + # To search all data streams and indices, omit this parameter or use +*+. + # @option arguments [Boolean] :ccs_minimize_roundtrips If +true+, network round-trips are minimized for cross-cluster search requests. Server default: true. + # @option arguments [Integer] :max_concurrent_searches The maximum number of concurrent searches the API can run. + # @option arguments [String] :search_type The type of the search operation. + # @option arguments [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 arguments [Boolean] :typed_keys If +true+, the response prefixes aggregation and suggester names with their respective types. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request definitions (metadata-search request definition pairs), separated by newlines (*Required*) + # @option arguments [Hash] :body search_templates # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-msearch-template # def msearch_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'msearch_template' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_msearch/template" + "#{Utils.listify(_index)}/_msearch/template" else - "_msearch/template" + '_msearch/template' end params = Utils.process_params(arguments) - case - when body.is_a?(Array) + if body.is_a?(Array) payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) } - payload << "" unless payload.empty? - payload = payload.join(" -") + payload << '' unless payload.empty? + payload = payload.join("\n") else payload = body end - headers.merge!("Content-Type" => "application/x-ndjson") + headers.merge!({ + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + }) Elasticsearch::API::Response.new( - perform_request(method, path, params, payload, headers) + perform_request(method, path, params, payload, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/mtermvectors.rb b/elasticsearch-api/lib/elasticsearch/api/actions/mtermvectors.rb index 968cf42a93..ecef716fb1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/mtermvectors.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/mtermvectors.rb @@ -15,41 +15,54 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns multiple termvectors in one request. + # Get multiple term vectors. + # Get multiple term vectors with a single request. + # You can specify existing documents by index and ID or provide artificial documents in the body of the request. + # You can specify the index in the request body or request URI. + # The response contains a +docs+ array with all the fetched termvectors. + # Each element has the structure provided by the termvectors API. + # **Artificial documents** + # You can also use +mtermvectors+ to generate term vectors for artificial documents provided in the body of the request. + # The mapping used is determined by the specified +_index+. # - # @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) + # @option arguments [String] :index The name of the index that contains the documents. + # @option arguments [Array] :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 [String, Array] :fields A comma-separated list or wildcard expressions of fields to include in the statistics. + # It is used as the default list unless a specific field list is provided in the +completion_fields+ or +fielddata_fields+ parameters. + # @option arguments [Boolean] :field_statistics If +true+, the response includes the document count, sum of document frequencies, and sum of total term frequencies. Server default: true. + # @option arguments [Boolean] :offsets If +true+, the response includes term offsets. Server default: true. + # @option arguments [Boolean] :payloads If +true+, the response includes term payloads. Server default: true. + # @option arguments [Boolean] :positions If +true+, the response includes term positions. Server default: true. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # It is random by default. + # @option arguments [Boolean] :realtime If true, the request is real-time as opposed to near-real-time. Server default: true. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Boolean] :term_statistics If true, the response includes term frequency and document frequency. + # @option arguments [Integer] :version If +true+, returns the document version as part of a hit. + # @option arguments [String] :version_type The version type. # @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. + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-mtermvectors # def mtermvectors(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'mtermvectors' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = if (ids = arguments.delete(:ids)) - { :ids => ids } - else - arguments.delete(:body) - end + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -60,14 +73,14 @@ def mtermvectors(arguments = {}) end path = if _index - "#{Utils.__listify(_index)}/_mtermvectors" + "#{Utils.listify(_index)}/_mtermvectors" else - "_mtermvectors" + '_mtermvectors' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/clear_repositories_metering_archive.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/clear_repositories_metering_archive.rb index 6e2856820d..bf24782511 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/clear_repositories_metering_archive.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/clear_repositories_metering_archive.rb @@ -15,30 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Nodes module Actions - # Removes the archived repositories metering information present in the cluster. + # Clear the archived repositories metering. + # Clear the archived repositories metering information in the cluster. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :node_id Comma-separated list of node IDs or names used to limit returned information. - # @option arguments [Long] :max_archive_version Specifies the maximum archive_version to be cleared from the archive. + # @option arguments [String, Array] :node_id Comma-separated list of node IDs or names used to limit returned information. (*Required*) + # @option arguments [Integer] :max_archive_version Specifies the maximum +archive_version+ to be cleared from the archive. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-repositories-metering-archive-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-clear-repositories-metering-archive # def clear_repositories_metering_archive(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'nodes.clear_repositories_metering_archive' } + + defined_params = [:node_id, :max_archive_version].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'node_id' missing" unless arguments[:node_id] - raise ArgumentError, - "Required argument 'max_archive_version' missing" unless arguments[:max_archive_version] + unless arguments[:max_archive_version] + raise ArgumentError, + "Required argument 'max_archive_version' missing" + end arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -50,11 +60,11 @@ def clear_repositories_metering_archive(arguments = {}) _max_archive_version = arguments.delete(:max_archive_version) method = Elasticsearch::API::HTTP_DELETE - path = "_nodes/#{Utils.__listify(_node_id)}/_repositories_metering/#{Utils.__listify(_max_archive_version)}" + path = "_nodes/#{Utils.listify(_node_id)}/_repositories_metering/#{Utils.listify(_max_archive_version)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/get_repositories_metering_info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/get_repositories_metering_info.rb index 9dfb0d96a1..65e3804c3f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/get_repositories_metering_info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/get_repositories_metering_info.rb @@ -15,25 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Nodes module Actions - # Returns cluster repositories metering information. + # Get cluster repositories metering. + # Get repositories metering information for a cluster. + # This API exposes monotonically non-decreasing counters and it is expected that clients would durably store the information needed to compute aggregations over a period of time. + # Additionally, the information exposed by this API is volatile, meaning that it will not be present after node restarts. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :node_id A comma-separated list of node IDs or names to limit the returned information. + # @option arguments [String, Array] :node_id Comma-separated list of node IDs or names used to limit returned information. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-get-repositories-metering-info # def get_repositories_metering_info(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'nodes.get_repositories_metering_info' } + + defined_params = [:node_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'node_id' missing" unless arguments[:node_id] arguments = arguments.clone @@ -44,11 +54,11 @@ def get_repositories_metering_info(arguments = {}) _node_id = arguments.delete(:node_id) method = Elasticsearch::API::HTTP_GET - path = "_nodes/#{Utils.__listify(_node_id)}/_repositories_metering" + path = "_nodes/#{Utils.listify(_node_id)}/_repositories_metering" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/hot_threads.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/hot_threads.rb index a6a51ffde1..3bdee5b48e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/hot_threads.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/hot_threads.rb @@ -15,28 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Nodes module Actions - # Returns information about hot threads on each node in the cluster. + # Get the hot threads for nodes. + # Get a breakdown of the hot threads on each selected node in the cluster. + # The output is plain text with a breakdown of the top hot threads for each node. # - # @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, mem) - # @option arguments [String] :sort The sort order for 'cpu' type (default: total) (options: cpu, total) - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [String, Array] :node_id List of node IDs or names used to limit returned information. + # @option arguments [Boolean] :ignore_idle_threads If true, known idle threads (e.g. waiting in a socket select, or to get + # a task from an empty queue) are filtered out. Server default: true. + # @option arguments [Time] :interval The interval to do the second sampling of threads. Server default: 500ms. + # @option arguments [Integer] :snapshots Number of samples of thread stacktrace. Server default: 10. + # @option arguments [Integer] :threads Specifies the number of hot threads to provide information for. Server default: 3. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received + # before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [String] :type The type to sample. Server default: cpu. + # @option arguments [String] :sort The sort order for 'cpu' type (default: total) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-hot-threads # def hot_threads(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'nodes.hot_threads' } + + defined_params = [:node_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -46,14 +57,14 @@ def hot_threads(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _node_id - "_nodes/#{Utils.__listify(_node_id)}/hot_threads" + "_nodes/#{Utils.listify(_node_id)}/hot_threads" else - "_nodes/hot_threads" + '_nodes/hot_threads' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/info.rb index 63a10d6a99..30581f8ae5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/info.rb @@ -15,24 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Nodes module Actions - # Returns information about nodes in the cluster. + # Get node information. + # By default, the API returns all attributes and core settings for cluster 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 A comma-separated list of metrics you wish returned. Use `_all` to retrieve all metrics and `_none` to retrieve the node identity without any additional metrics. (options: settings, os, process, jvm, thread_pool, transport, http, plugins, ingest, indices, aggregations, _all, _none) - # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [String, Array] :node_id Comma-separated list of node IDs or names used to limit returned information. + # @option arguments [String, Array] :metric Limits the information returned to the specific metrics. Supports a comma-separated list, such as http,ingest. + # @option arguments [Boolean] :flat_settings If true, returns settings in flat format. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-info # def info(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'nodes.info' } + + defined_params = [:node_id, :metric].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -44,18 +52,18 @@ def info(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _node_id && _metric - "_nodes/#{Utils.__listify(_node_id)}/#{Utils.__listify(_metric)}" + "_nodes/#{Utils.listify(_node_id)}/#{Utils.listify(_metric)}" elsif _node_id - "_nodes/#{Utils.__listify(_node_id)}" + "_nodes/#{Utils.listify(_node_id)}" elsif _metric - "_nodes/#{Utils.__listify(_metric)}" + "_nodes/#{Utils.listify(_metric)}" else - "_nodes" + '_nodes' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb index 3370c927c9..7305524369 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb @@ -15,23 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Nodes module Actions - # Reloads secure settings. + # Reload the keystore on nodes in the cluster. + # Secure settings are stored in an on-disk keystore. Certain of these settings are reloadable. + # That is, you can change them on disk and reload them without restarting any nodes in the cluster. + # When you have updated reloadable secure settings in your keystore, you can use this API to reload those settings on each node. + # When the Elasticsearch keystore is password protected and not simply obfuscated, you must provide the password for the keystore when you reload the secure settings. + # Reloading the settings for the whole cluster assumes that the keystores for all nodes are protected with the same password; this method is allowed only when inter-node communications are encrypted. + # Alternatively, you can reload the secure settings on each node by locally accessing the API and passing the node-specific Elasticsearch keystore password. # - # @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 [String, Array] :node_id The names of particular nodes in the cluster to target. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body An object containing the password for the elasticsearch keystore + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/secure-settings.html#reloadable-secure-settings + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-reload-secure-settings # def reload_secure_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'nodes.reload_secure_settings' } + + defined_params = [:node_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +55,14 @@ def reload_secure_settings(arguments = {}) method = Elasticsearch::API::HTTP_POST path = if _node_id - "_nodes/#{Utils.__listify(_node_id)}/reload_secure_settings" + "_nodes/#{Utils.listify(_node_id)}/reload_secure_settings" else - "_nodes/reload_secure_settings" + '_nodes/reload_secure_settings' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb index 706b73eb2d..35b99da1b6 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/stats.rb @@ -15,32 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Nodes module Actions - # Returns statistical information about nodes in the cluster. + # Get node statistics. + # Get statistics for nodes in a cluster. + # By default, all stats are returned. You can limit the returned information by using metrics. # - # @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, bulk, shard_stats) - # @option arguments [List] :completion_fields A comma-separated list of fields for the `completion` index metric (supports wildcards) - # @option arguments [List] :fielddata_fields A comma-separated list of fields for the `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 [String, Array] :node_id Comma-separated list of node IDs or names used to limit returned information. + # @option arguments [String, Array] :metric Limit the information returned to the specified metrics + # @option arguments [String, Array] :index_metric Limit the information returned for indices metric to the specific index metrics. It can be used only if indices (or all) metric is specified. + # @option arguments [String, Array] :completion_fields Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. + # @option arguments [String, Array] :fielddata_fields Comma-separated list or wildcard expressions of fields to include in fielddata statistics. + # @option arguments [String, Array] :fields Comma-separated list or wildcard expressions of fields to include in the statistics. + # @option arguments [Boolean] :groups Comma-separated list of search groups to include in the search statistics. + # @option arguments [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 arguments [String] :level Indicates whether statistics are aggregated at the cluster, index, or shard level. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Array] :types A comma-separated list of document types for the indexing index metric. + # @option arguments [Boolean] :include_unloaded_segments If +true+, the response includes information from segments that are not loaded into memory. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-stats # def stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'nodes.stats' } + + defined_params = [:node_id, :metric, :index_metric].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -54,22 +63,22 @@ def stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _node_id && _metric && _index_metric - "_nodes/#{Utils.__listify(_node_id)}/stats/#{Utils.__listify(_metric)}/#{Utils.__listify(_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)}" + "_nodes/stats/#{Utils.listify(_metric)}/#{Utils.listify(_index_metric)}" elsif _node_id && _metric - "_nodes/#{Utils.__listify(_node_id)}/stats/#{Utils.__listify(_metric)}" + "_nodes/#{Utils.listify(_node_id)}/stats/#{Utils.listify(_metric)}" elsif _node_id - "_nodes/#{Utils.__listify(_node_id)}/stats" + "_nodes/#{Utils.listify(_node_id)}/stats" elsif _metric - "_nodes/stats/#{Utils.__listify(_metric)}" + "_nodes/stats/#{Utils.listify(_metric)}" else - "_nodes/stats" + '_nodes/stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/usage.rb b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/usage.rb index 4b54a7fbe2..e28f8c4b22 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/nodes/usage.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/nodes/usage.rb @@ -15,23 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Nodes module Actions - # Returns low-level information about REST actions usage on nodes. + # Get feature usage information. # - # @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 [String, Array] :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 [String, Array] :metric Limits the information returned to the specific metrics. + # A comma-separated list of the following options: +_all+, +rest_actions+. + # @option arguments [Time] :timeout Period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-usage.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-nodes-usage # def usage(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'nodes.usage' } + + defined_params = [:node_id, :metric].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -43,18 +52,18 @@ def usage(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _node_id && _metric - "_nodes/#{Utils.__listify(_node_id)}/usage/#{Utils.__listify(_metric)}" + "_nodes/#{Utils.listify(_node_id)}/usage/#{Utils.listify(_metric)}" elsif _node_id - "_nodes/#{Utils.__listify(_node_id)}/usage" + "_nodes/#{Utils.listify(_node_id)}/usage" elsif _metric - "_nodes/usage/#{Utils.__listify(_metric)}" + "_nodes/usage/#{Utils.listify(_metric)}" else - "_nodes/usage" + '_nodes/usage' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb b/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb index 82d6ecd10f..f77430ed07 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb @@ -15,40 +15,80 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Open a point in time that can be used in subsequent searches + # Open a point in time. + # A search request by default runs against the most recent visible data of the target indices, + # which is called point in time. Elasticsearch pit (point in time) is a lightweight view into the + # state of the data as it existed when initiated. In some cases, it’s preferred to perform multiple + # search requests using the same point in time. For example, if refreshes happen between + # +search_after+ requests, then the results of those requests might not be consistent as changes happening + # between searches are only visible to the more recent point in time. + # A point in time must be opened explicitly before being used in search requests. + # A subsequent search request with the +pit+ parameter must not specify +index+, +routing+, or +preference+ values as these parameters are copied from the point in time. + # Just like regular searches, you can use +from+ and +size+ to page through point in time search results, up to the first 10,000 hits. + # If you want to retrieve more hits, use PIT with +search_after+. + # IMPORTANT: The open point in time request and each subsequent search request can return different identifiers; always use the most recently received ID for the next search request. + # When a PIT that contains shard failures is used in a search request, the missing are always reported in the search response as a +NoShardAvailableActionException+ exception. + # To get rid of these exceptions, a new PIT needs to be created so that shards missing from the previous PIT can be handled, assuming they become available in the meantime. + # **Keeping point in time alive** + # The +keep_alive+ parameter, which is passed to a open point in time request and search request, extends the time to live of the corresponding point in time. + # The value does not need to be long enough to process all data — it just needs to be long enough for the next request. + # Normally, the background merge process optimizes the index by merging together smaller segments to create new, bigger segments. + # Once the smaller segments are no longer needed they are deleted. + # However, open point-in-times prevent the old segments from being deleted since they are still in use. + # TIP: Keeping older segments alive means that more disk space and file handles are needed. + # Ensure that you have configured your nodes to have ample free file handles. + # Additionally, if a segment contains deleted or updated documents then the point in time must keep track of whether each document in the segment was live at the time of the initial search request. + # Ensure that your nodes have sufficient heap space if you have many open point-in-times on an index that is subject to ongoing deletes or updates. + # Note that a point-in-time doesn't prevent its associated indices from being deleted. + # You can check how many point-in-times (that is, search contexts) are open with the nodes stats API. # - # @option arguments [List] :index A comma-separated list of index names to open point in time; 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] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) - # @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] :keep_alive Specific the time to live for the point in time (*Required*) + # @option arguments [String, Array] :index A comma-separated list of index names to open point in time; use +_all+ or empty string to perform the operation on all indices (*Required*) + # @option arguments [Time] :keep_alive Extend the length of time that the point in time persists. (*Required*) + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # By default, it is random. + # @option arguments [String] :routing A custom value that is used to route operations to a specific shard. + # @option arguments [String, Array] :expand_wildcards The 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. + # It supports comma-separated values, such as +open,hidden+. Valid values are: +all+, +open+, +closed+, +hidden+, +none+. Server default: open. + # @option arguments [Boolean] :allow_partial_search_results Indicates whether the point in time tolerates unavailable shards or shard failures when initially creating the PIT. + # If +false+, creating a point in time request when a shard is missing or unavailable will throw an exception. + # If +true+, the point in time will contain all the shards that are available at the time of the request. + # @option arguments [Integer] :max_concurrent_shard_requests Maximum number of concurrent shard requests that each sub-search request executes per node. Server default: 5. # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/point-in-time-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-open-point-in-time # def open_point_in_time(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'open_point_in_time' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_pit" + path = "#{Utils.listify(_index)}/_pit" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ping.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ping.rb index d8ed048ff1..afa4759727 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/ping.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ping.rb @@ -15,36 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns whether the cluster is running. + # Ping the cluster. + # Get information about whether the cluster is running. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-cluster # def ping(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ping' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_HEAD - path = "" + path = '' params = {} begin - perform_request(method, path, params, body, headers).status == 200 ? true : false + perform_request(method, path, params, body, headers, request_opts).status == 200 rescue Exception => e - if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i - false - else - raise e - end + raise e unless e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i + + false end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/put_script.rb b/elasticsearch-api/lib/elasticsearch/api/actions/put_script.rb index d2d33c424a..8f992288d0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/put_script.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/put_script.rb @@ -15,24 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Creates or updates a script. + # Create or update a script or search template. + # Creates or updates a stored script or search template. # - # @option arguments [String] :id Script ID - # @option arguments [String] :context Script context - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Time] :master_timeout Specify timeout for connection to master + # @option arguments [String] :id The identifier for the stored script or search template. + # It must be unique within the cluster. (*Required*) + # @option arguments [String] :context The 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 arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. + # It can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The document (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-put-script # def put_script(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'put_script' } + + defined_params = [:id, :context].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -47,14 +61,14 @@ def put_script(arguments = {}) method = Elasticsearch::API::HTTP_PUT path = if _id && _context - "_scripts/#{Utils.__listify(_id)}/#{Utils.__listify(_context)}" + "_scripts/#{Utils.listify(_id)}/#{Utils.listify(_context)}" else - "_scripts/#{Utils.__listify(_id)}" + "_scripts/#{Utils.listify(_id)}" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/delete_rule.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/delete_rule.rb new file mode 100644 index 0000000000..086e5e6849 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/delete_rule.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module QueryRules + module Actions + # Delete a query rule. + # Delete a query rule within a query ruleset. + # This is a destructive action that is only recoverable by re-adding the same rule with the create or update query rule API. + # + # @option arguments [String] :ruleset_id The unique identifier of the query ruleset containing the rule to delete (*Required*) + # @option arguments [String] :rule_id The unique identifier of the query rule within the specified ruleset to delete (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-delete-rule + # + def delete_rule(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'query_rules.delete_rule' } + + defined_params = [:ruleset_id, :rule_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] + raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _ruleset_id = arguments.delete(:ruleset_id) + + _rule_id = arguments.delete(:rule_id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_query_rules/#{Utils.listify(_ruleset_id)}/_rule/#{Utils.listify(_rule_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/delete_ruleset.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/delete_ruleset.rb new file mode 100644 index 0000000000..c28dd90c99 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/delete_ruleset.rb @@ -0,0 +1,70 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module QueryRules + module Actions + # Delete a query ruleset. + # Remove a query ruleset and its associated data. + # This is a destructive action that is not recoverable. + # + # @option arguments [String] :ruleset_id The unique identifier of the query ruleset to delete (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-delete-ruleset + # + def delete_ruleset(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'query_rules.delete_ruleset' } + + defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _ruleset_id = arguments.delete(:ruleset_id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_query_rules/#{Utils.listify(_ruleset_id)}" + params = Utils.process_params(arguments) + + if Array(arguments[:ignore]).include?(404) + Utils.rescue_from_not_found do + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + else + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/get_rule.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/get_rule.rb new file mode 100644 index 0000000000..4dcdd82ae5 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/get_rule.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module QueryRules + module Actions + # Get a query rule. + # Get details about a query rule within a query ruleset. + # + # @option arguments [String] :ruleset_id The unique identifier of the query ruleset containing the rule to retrieve (*Required*) + # @option arguments [String] :rule_id The unique identifier of the query rule within the specified ruleset to retrieve (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-get-rule + # + def get_rule(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'query_rules.get_rule' } + + defined_params = [:ruleset_id, :rule_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] + raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _ruleset_id = arguments.delete(:ruleset_id) + + _rule_id = arguments.delete(:rule_id) + + method = Elasticsearch::API::HTTP_GET + path = "_query_rules/#{Utils.listify(_ruleset_id)}/_rule/#{Utils.listify(_rule_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/get_ruleset.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/get_ruleset.rb new file mode 100644 index 0000000000..32b7605928 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/get_ruleset.rb @@ -0,0 +1,61 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module QueryRules + module Actions + # Get a query ruleset. + # Get details about a query ruleset. + # + # @option arguments [String] :ruleset_id The unique identifier of the query ruleset (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-get-ruleset + # + def get_ruleset(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'query_rules.get_ruleset' } + + defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _ruleset_id = arguments.delete(:ruleset_id) + + method = Elasticsearch::API::HTTP_GET + path = "_query_rules/#{Utils.listify(_ruleset_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/list_rulesets.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/list_rulesets.rb new file mode 100644 index 0000000000..af790eabcd --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/list_rulesets.rb @@ -0,0 +1,53 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module QueryRules + module Actions + # Get all query rulesets. + # Get summarized information about the query rulesets. + # + # @option arguments [Integer] :from The offset from the first result to fetch. Server default: 0. + # @option arguments [Integer] :size The maximum number of results to retrieve. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-list-rulesets + # + def list_rulesets(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'query_rules.list_rulesets' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_query_rules' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/put_rule.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/put_rule.rb new file mode 100644 index 0000000000..6137eb3aa5 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/put_rule.rb @@ -0,0 +1,71 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module QueryRules + module Actions + # Create or update a query rule. + # Create or update a query rule within a query ruleset. + # IMPORTANT: Due to limitations within pinned queries, you can only pin documents using ids or docs, but cannot use both in single rule. + # It is advised to use one or the other in query rulesets, to avoid errors. + # Additionally, pinned queries have a maximum limit of 100 pinned hits. + # If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset. + # + # @option arguments [String] :ruleset_id The unique identifier of the query ruleset containing the rule to be created or updated. (*Required*) + # @option arguments [String] :rule_id The unique identifier of the query rule within the specified ruleset to be created or updated. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-put-rule + # + def put_rule(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'query_rules.put_rule' } + + defined_params = [:ruleset_id, :rule_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] + raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _ruleset_id = arguments.delete(:ruleset_id) + + _rule_id = arguments.delete(:rule_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_query_rules/#{Utils.listify(_ruleset_id)}/_rule/#{Utils.listify(_rule_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/put_ruleset.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/put_ruleset.rb new file mode 100644 index 0000000000..3c6c94365d --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/put_ruleset.rb @@ -0,0 +1,68 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module QueryRules + module Actions + # Create or update a query ruleset. + # There is a limit of 100 rules per ruleset. + # This limit can be increased by using the +xpack.applications.rules.max_rules_per_ruleset+ cluster setting. + # IMPORTANT: Due to limitations within pinned queries, you can only select documents using +ids+ or +docs+, but cannot use both in single rule. + # It is advised to use one or the other in query rulesets, to avoid errors. + # Additionally, pinned queries have a maximum limit of 100 pinned hits. + # If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset. + # + # @option arguments [String] :ruleset_id The unique identifier of the query ruleset to be created or updated. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-put-ruleset + # + def put_ruleset(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'query_rules.put_ruleset' } + + defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _ruleset_id = arguments.delete(:ruleset_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_query_rules/#{Utils.listify(_ruleset_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/test.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/test.rb new file mode 100644 index 0000000000..9f994a3ed4 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/query_rules/test.rb @@ -0,0 +1,63 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module QueryRules + module Actions + # Test a query ruleset. + # Evaluate match criteria against a query ruleset to identify the rules that would match that criteria. + # + # @option arguments [String] :ruleset_id The unique identifier of the query ruleset to be created or updated (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-query-rules-test + # + def test(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'query_rules.test' } + + defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _ruleset_id = arguments.delete(:ruleset_id) + + method = Elasticsearch::API::HTTP_POST + path = "_query_rules/#{Utils.listify(_ruleset_id)}/_test" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/delete.rb deleted file mode 100644 index 0558c5fac5..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/delete.rb +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module QueryRuleset - module Actions - # Deletes a query ruleset. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :ruleset_id The unique identifier of the query ruleset to delete - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-query-ruleset.html - # - def delete(arguments = {}) - raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _ruleset_id = arguments.delete(:ruleset_id) - - method = Elasticsearch::API::HTTP_DELETE - path = "_query_rules/#{Utils.__listify(_ruleset_id)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/get.rb deleted file mode 100644 index c6d3fe2e72..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/get.rb +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module QueryRuleset - module Actions - # Returns the details about a query ruleset. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :ruleset_id The unique identifier of the query ruleset - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-query-ruleset.html - # - def get(arguments = {}) - raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _ruleset_id = arguments.delete(:ruleset_id) - - method = Elasticsearch::API::HTTP_GET - path = "_query_rules/#{Utils.__listify(_ruleset_id)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/list.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/list.rb deleted file mode 100644 index 06c425809b..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/list.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module QueryRuleset - module Actions - # Lists query rulesets. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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 [Integer] :from Starting offset (default: 0) - # @option arguments [Integer] :size specifies a max number of results to get (default: 100) - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/list-query-rulesets.html - # - def list(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - method = Elasticsearch::API::HTTP_GET - path = "_query_rules" - params = Utils.process_params(arguments) - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/put.rb b/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/put.rb deleted file mode 100644 index ec6ef648d2..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/query_ruleset/put.rb +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module QueryRuleset - module Actions - # Creates or updates a query ruleset. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :ruleset_id The unique identifier of the ruleset to be created or updated. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The query ruleset configuration, including `rules` (*Required*) - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-query-ruleset.html - # - def put(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _ruleset_id = arguments.delete(:ruleset_id) - - method = Elasticsearch::API::HTTP_PUT - path = "_query_rules/#{Utils.__listify(_ruleset_id)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rank_eval.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rank_eval.rb index bf4a92afdb..d7f4a5f210 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rank_eval.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/rank_eval.rb @@ -15,44 +15,54 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows to evaluate the quality of ranked search results over a set of typical search queries + # Evaluate ranked search results. + # Evaluate the quality of ranked search results over a set of typical search queries. # - # @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 [String, Array] :index A comma-separated list of data streams, indices, and index aliases used to limit the request. + # Wildcard (+*+) expressions are supported. + # To target all data streams and indices in a cluster, omit this parameter or use +_all+ or +*+. + # @option arguments [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 indices. This behavior applies even if the request targets other open indices. For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. + # @option arguments [String, Array] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. + # @option arguments [Boolean] :ignore_unavailable If +true+, missing or closed indices are not included in the response. + # @option arguments [String] :search_type Search operation type # @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*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-rank-eval.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-rank-eval # def rank_eval(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'rank_eval' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_rank_eval" + "#{Utils.listify(_index)}/_rank_eval" else - "_rank_eval" + '_rank_eval' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/reindex.rb b/elasticsearch-api/lib/elasticsearch/api/actions/reindex.rb index 72d44efb4f..c79b5b9950 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/reindex.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/reindex.rb @@ -15,43 +15,184 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch 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. + # Reindex documents. + # Copy documents from a source to a destination. + # You can copy all documents to the destination index or reindex a subset of the documents. + # The source can be any existing index, alias, or data stream. + # The destination must differ from the source. + # For example, you cannot reindex a data stream into itself. + # IMPORTANT: Reindex requires +_source+ to be enabled for all documents in the source. + # The destination should be configured as wanted before calling the reindex API. + # Reindex does not copy the settings from the source or its associated template. + # Mappings, shard counts, and replicas, for example, must be configured ahead of time. + # If the Elasticsearch security features are enabled, you must have the following security privileges: + # * The +read+ index privilege for the source data stream, index, or alias. + # * The +write+ index privilege for the destination data stream, index, or index alias. + # * To automatically create a data stream or index with a reindex API request, you must have the +auto_configure+, +create_index+, or +manage+ index privilege for the destination data stream, index, or alias. + # * If reindexing from a remote cluster, the +source.remote.user+ must have the +monitor+ cluster privilege and the +read+ index privilege for the source data stream, index, or alias. + # If reindexing from a remote cluster, you must explicitly allow the remote host in the +reindex.remote.whitelist+ setting. + # Automatic data stream creation requires a matching index template with data stream enabled. + # The +dest+ element can be configured like the index API to control optimistic concurrency control. + # Omitting +version_type+ or setting it to +internal+ causes Elasticsearch to blindly dump documents into the destination, overwriting any that happen to have the same ID. + # Setting +version_type+ to +external+ causes Elasticsearch to preserve the +version+ from the source, create any documents that are missing, and update any documents that have an older version in the destination than they do in the source. + # Setting +op_type+ to +create+ causes the reindex API to create only missing documents in the destination. + # All existing documents will cause a version conflict. + # IMPORTANT: Because data streams are append-only, any reindex request to a destination data stream must have an +op_type+ of +create+. + # A reindex can only add new documents to a destination data stream. + # It cannot update existing documents in a destination data stream. + # By default, version conflicts abort the reindex process. + # To continue reindexing if there are conflicts, set the +conflicts+ request body property to +proceed+. + # In this case, the response includes a count of the version conflicts that were encountered. + # Note that the handling of other error types is unaffected by the +conflicts+ property. + # Additionally, if you opt to count version conflicts, the operation could attempt to reindex more documents from the source than +max_docs+ until it has successfully indexed +max_docs+ documents into the target or it has gone through every document in the source query. + # NOTE: The reindex API makes no effort to handle ID collisions. + # The last document written will "win" but the order isn't usually predictable so it is not a good idea to rely on this behavior. + # Instead, make sure that IDs are unique by using a script. + # **Running reindex asynchronously** + # If the request contains +wait_for_completion=false+, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to cancel or get the status of the task. + # Elasticsearch creates a record of this task as a document at +_tasks/+. + # **Reindex from multiple sources** + # If you have many sources to reindex it is generally better to reindex them one at a time rather than using a glob pattern to pick up multiple sources. + # That way you can resume the process if there are any errors by removing the partially completed source and starting over. + # It also makes parallelizing the process fairly simple: split the list of sources to reindex and run each list in parallel. + # For example, you can use a bash script like this: + # + + # for index in i1 i2 i3 i4 i5; do + # curl -HContent-Type:application/json -XPOST localhost:9200/_reindex?pretty -d'{ + # "source": { + # "index": "'$index'" + # }, + # "dest": { + # "index": "'$index'-reindexed" + # } + # }' + # done + # + + # **Throttling** + # Set +requests_per_second+ to any positive decimal number (+1.4+, +6+, +1000+, for example) to throttle the rate at which reindex issues batches of index operations. + # Requests are throttled by padding each batch with a wait time. + # To turn off throttling, set +requests_per_second+ to +-1+. + # The throttling is done by waiting between batches so that the scroll that reindex uses internally can be given a timeout that takes into account the padding. + # The padding time is the difference between the batch size divided by the +requests_per_second+ and the time spent writing. + # By default the batch size is +1000+, so if +requests_per_second+ is set to +500+: + # + + # target_time = 1000 / 500 per second = 2 seconds + # wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds + # + + # Since the batch is issued as a single bulk request, large batch sizes cause Elasticsearch to create many requests and then wait for a while before starting the next set. + # This is "bursty" instead of "smooth". + # **Slicing** + # Reindex supports sliced scroll to parallelize the reindexing process. + # This parallelization can improve efficiency and provide a convenient way to break the request down into smaller parts. + # NOTE: Reindexing from remote clusters does not support manual or automatic slicing. + # You can slice a reindex request manually by providing a slice ID and total number of slices to each request. + # You can also let reindex automatically parallelize by using sliced scroll to slice on +_id+. + # The +slices+ parameter specifies the number of slices to use. + # Adding +slices+ to the reindex request just automates the manual process, creating sub-requests which means it has some quirks: + # * You can see these requests in the tasks API. These sub-requests are "child" tasks of the task for the request with slices. + # * Fetching the status of the task for the request with +slices+ only contains the status of completed slices. + # * These sub-requests are individually addressable for things like cancellation and rethrottling. + # * Rethrottling the request with +slices+ will rethrottle the unfinished sub-request proportionally. + # * Canceling the request with +slices+ will cancel each sub-request. + # * Due to the nature of +slices+, each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution. + # * Parameters like +requests_per_second+ and +max_docs+ on a request with +slices+ are distributed proportionally to each sub-request. Combine that with the previous point about distribution being uneven and you should conclude that using +max_docs+ with +slices+ might not result in exactly +max_docs+ documents being reindexed. + # * Each sub-request gets a slightly different snapshot of the source, though these are all taken at approximately the same time. + # If slicing automatically, setting +slices+ to +auto+ will choose a reasonable number for most indices. + # If slicing manually or otherwise tuning automatic slicing, use the following guidelines. + # Query performance is most efficient when the number of slices is equal to the number of shards in the index. + # If that number is large (for example, +500+), choose a lower number as too many slices will hurt performance. + # Setting slices higher than the number of shards generally does not improve efficiency and adds overhead. + # Indexing performance scales linearly across available resources with the number of slices. + # Whether query or indexing performance dominates the runtime depends on the documents being reindexed and cluster resources. + # **Modify documents during reindexing** + # Like +_update_by_query+, reindex operations support a script that modifies the document. + # Unlike +_update_by_query+, the script is allowed to modify the document's metadata. + # Just as in +_update_by_query+, you can set +ctx.op+ to change the operation that is run on the destination. + # For example, set +ctx.op+ to +noop+ if your script decides that the document doesn’t have to be indexed in the destination. This "no operation" will be reported in the +noop+ counter in the response body. + # Set +ctx.op+ to +delete+ if your script decides that the document must be deleted from the destination. + # The deletion will be reported in the +deleted+ counter in the response body. + # Setting +ctx.op+ to anything else will return an error, as will setting any other field in +ctx+. + # Think of the possibilities! Just be careful; you are able to change: + # * +_id+ + # * +_index+ + # * +_version+ + # * +_routing+ + # Setting +_version+ to +null+ or clearing it from the +ctx+ map is just like not sending the version in an indexing request. + # It will cause the document to be overwritten in the destination regardless of the version on the target or the version type you use in the reindex API. + # **Reindex from remote** + # Reindex supports reindexing from a remote Elasticsearch cluster. + # The +host+ parameter must contain a scheme, host, port, and optional path. + # The +username+ and +password+ parameters are optional and when they are present the reindex operation will connect to the remote Elasticsearch node using basic authentication. + # Be sure to use HTTPS when using basic authentication or the password will be sent in plain text. + # There are a range of settings available to configure the behavior of the HTTPS connection. + # When using Elastic Cloud, it is also possible to authenticate against the remote cluster through the use of a valid API key. + # Remote hosts must be explicitly allowed with the +reindex.remote.whitelist+ setting. + # It can be set to a comma delimited list of allowed remote host and port combinations. + # Scheme is ignored; only the host and port are used. + # For example: + # + + # reindex.remote.whitelist: [otherhost:9200, another:9200, 127.0.10.*:9200, localhost:*"] + # + + # The list of allowed hosts must be configured on any nodes that will coordinate the reindex. + # This feature should work with remote clusters of any version of Elasticsearch. + # This should enable you to upgrade from any version of Elasticsearch to the current version by reindexing from a cluster of the old version. + # WARNING: Elasticsearch does not support forward compatibility across major versions. + # For example, you cannot reindex from a 7.x cluster into a 6.x cluster. + # To enable queries sent to older versions of Elasticsearch, the +query+ parameter is sent directly to the remote host without validation or modification. + # NOTE: Reindexing from remote clusters does not support manual or automatic slicing. + # Reindexing from a remote server uses an on-heap buffer that defaults to a maximum size of 100mb. + # If the remote index includes very large documents you'll need to use a smaller batch size. + # It is also possible to set the socket read timeout on the remote connection with the +socket_timeout+ field and the connection timeout with the +connect_timeout+ field. + # Both default to 30 seconds. + # **Configuring SSL parameters** + # Reindex from remote supports configurable SSL settings. + # These must be specified in the +elasticsearch.yml+ file, with the exception of the secure settings, which you add in the Elasticsearch keystore. + # It is not possible to configure SSL in the body of the reindex request. # - # @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 [Boolean] :refresh If +true+, the request refreshes affected shards to make this operation visible to search. + # @option arguments [Float] :requests_per_second The throttle for this request in sub-requests per second. + # By default, there is no throttle. Server default: -1. + # @option arguments [Time] :scroll The period of time that a consistent view of the index should be maintained for scrolled search. + # @option arguments [Integer, String] :slices The number of slices this task should be divided into. + # It defaults to one slice, which means the task isn't sliced into subtasks.Reindex supports sliced scroll to parallelize the reindexing process. + # This parallelization can improve efficiency and provide a convenient way to break the request down into smaller parts.NOTE: Reindexing from remote clusters does not support manual or automatic slicing.If set to +auto+, Elasticsearch chooses the number of slices to use. + # This setting will use one slice per shard, up to a certain limit. + # If there are multiple sources, it will choose the number of slices based on the index or backing index with the smallest number of shards. Server default: 1. + # @option arguments [Time] :timeout The period each indexing waits for automatic index creation, dynamic mapping updates, and waiting for active shards. + # By default, Elasticsearch waits for at least one minute before failing. + # The actual wait time could be longer, particularly when multiple waits occur. Server default: 1m. + # @option arguments [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. + # Set it to +all+ or any positive integer up to the total number of shards in the index (+number_of_replicas+1+). + # The default value is one, which means it waits for each primary shard to be active. Server default: 1. + # @option arguments [Boolean] :wait_for_completion If +true+, the request blocks until the operation is complete. Server default: true. + # @option arguments [Boolean] :require_alias If +true+, the destination must be an index alias. # @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*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex # def reindex(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'reindex' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_reindex" + path = '_reindex' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/reindex_rethrottle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/reindex_rethrottle.rb index aa6f493642..251b0ddcfd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/reindex_rethrottle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/reindex_rethrottle.rb @@ -15,21 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Changes the number of requests per second for a particular Reindex operation. + # Throttle a reindex operation. + # Change the number of requests per second for a particular reindex operation. + # For example: + # + + # POST _reindex/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1 + # + + # Rethrottling that speeds up the query takes effect immediately. + # Rethrottling that slows down the query will take effect after completing the current batch. + # This behavior prevents scroll timeouts. # - # @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 [String] :task_id The task identifier, which can be found by using the tasks API. (*Required*) + # @option arguments [Float] :requests_per_second The throttle for this request in sub-requests per second. + # It can be either +-1+ to turn off throttling or any decimal number like +1.7+ or +12+ to throttle to that level. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex # def reindex_rethrottle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'reindex_rethrottle' } + + defined_params = [:task_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone @@ -40,11 +56,11 @@ def reindex_rethrottle(arguments = {}) _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST - path = "_reindex/#{Utils.__listify(_task_id)}/_rethrottle" + path = "_reindex/#{Utils.listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/render_search_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/render_search_template.rb index 7b7f3e2e30..0d73feedac 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/render_search_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/render_search_template.rb @@ -15,21 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows to use the Mustache language to pre-render a search definition. + # Render a search template. + # Render a search template as a search request body. # - # @option arguments [String] :id The id of the stored search template + # @option arguments [String] :id The ID of the search template to render. + # If no +source+ is specified, this or the +id+ request body parameter is required. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition template and its params + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/render-search-template-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-render-search-template # def render_search_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'render_search_template' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -44,14 +53,14 @@ def render_search_template(arguments = {}) end path = if _id - "_render/template/#{Utils.__listify(_id)}" + "_render/template/#{Utils.listify(_id)}" else - "_render/template" + '_render/template' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/delete_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rollup/delete_job.rb deleted file mode 100644 index df5481d092..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/delete_job.rb +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Rollup - module Actions - # Deletes an existing rollup job. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :id The ID of the job to delete - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-delete-job.html - # - def delete_job(arguments = {}) - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _id = arguments.delete(:id) - - method = Elasticsearch::API::HTTP_DELETE - path = "_rollup/job/#{Utils.__listify(_id)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_jobs.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_jobs.rb deleted file mode 100644 index f07d6bc358..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_jobs.rb +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Rollup - module Actions - # Retrieves the configuration, stats, and status of rollup jobs. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :id The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-get-job.html - # - def get_jobs(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _id = arguments.delete(:id) - - method = Elasticsearch::API::HTTP_GET - path = if _id - "_rollup/job/#{Utils.__listify(_id)}" - else - "_rollup/job" - end - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_rollup_caps.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_rollup_caps.rb deleted file mode 100644 index 3047e45a2e..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_rollup_caps.rb +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Rollup - module Actions - # Returns the capabilities of any rollup jobs that have been configured for a specific index or index pattern. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :id The ID of the index to check rollup capabilities on, or left blank for all jobs - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-get-rollup-caps.html - # - def get_rollup_caps(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _id = arguments.delete(:id) - - method = Elasticsearch::API::HTTP_GET - path = if _id - "_rollup/data/#{Utils.__listify(_id)}" - else - "_rollup/data" - end - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_rollup_index_caps.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_rollup_index_caps.rb deleted file mode 100644 index c1e5264a7d..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/get_rollup_index_caps.rb +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Rollup - module Actions - # Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored). - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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 The rollup index or index pattern to obtain rollup capabilities from. - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-get-rollup-index-caps.html - # - def get_rollup_index_caps(arguments = {}) - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _index = arguments.delete(:index) - - method = Elasticsearch::API::HTTP_GET - path = "#{Utils.__listify(_index)}/_rollup/data" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/put_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rollup/put_job.rb deleted file mode 100644 index fdb9616f4b..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/put_job.rb +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Rollup - module Actions - # Creates a rollup job. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :id The ID of the job to create - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The job configuration (*Required*) - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-put-job.html - # - def put_job(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _id = arguments.delete(:id) - - method = Elasticsearch::API::HTTP_PUT - path = "_rollup/job/#{Utils.__listify(_id)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/rollup_search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rollup/rollup_search.rb deleted file mode 100644 index 832db0da11..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/rollup_search.rb +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Rollup - module Actions - # Enables searching rolled-up data using the standard query DSL. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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 The indices or index-pattern(s) (containing rollup or regular data) that should be searched - # @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 [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search request body (*Required*) - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-search.html - # - def rollup_search(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _index = arguments.delete(:index) - - method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_rollup_search" - params = Utils.process_params(arguments) - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/start_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rollup/start_job.rb deleted file mode 100644 index 768b461fb4..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/start_job.rb +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Rollup - module Actions - # Starts an existing, stopped rollup job. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :id The ID of the job to start - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-start-job.html - # - def start_job(arguments = {}) - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _id = arguments.delete(:id) - - method = Elasticsearch::API::HTTP_POST - path = "_rollup/job/#{Utils.__listify(_id)}/_start" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/stop_job.rb b/elasticsearch-api/lib/elasticsearch/api/actions/rollup/stop_job.rb deleted file mode 100644 index bad3231161..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/rollup/stop_job.rb +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Rollup - module Actions - # Stops an existing, started rollup job. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :id The ID of the job to stop - # @option arguments [Boolean] :wait_for_completion True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. - # @option arguments [Time] :timeout Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-stop-job.html - # - def stop_job(arguments = {}) - raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _id = arguments.delete(:id) - - method = Elasticsearch::API::HTTP_POST - path = "_rollup/job/#{Utils.__listify(_id)}/_stop" - params = Utils.process_params(arguments) - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/scripts_painless_execute.rb b/elasticsearch-api/lib/elasticsearch/api/actions/scripts_painless_execute.rb index 07e39dcb8f..560e47f575 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/scripts_painless_execute.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/scripts_painless_execute.rb @@ -15,28 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows an arbitrary script to be executed and a result to be returned + # Run a script. + # Runs a script and returns a result. + # Use this API to build and test scripts, such as when defining a script for a runtime field. + # This API requires very few dependencies and is especially useful if you don't have permissions to write documents on a cluster. + # The API uses several _contexts_, which control how scripts are run, what variables are available at runtime, and what the return type is. + # Each context requires a script, but additional parameters depend on the context you're using for that script. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-execute-api.html + # @see https://www.elastic.co/docs/reference/scripting-languages/painless/painless-api-examples # def scripts_painless_execute(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'scripts_painless_execute' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = if body Elasticsearch::API::HTTP_POST @@ -44,11 +51,11 @@ def scripts_painless_execute(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_scripts/painless/_execute" + path = '_scripts/painless/_execute' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb b/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb index c3b4bf52b4..6aef1c7613 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/scroll.rb @@ -15,28 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows to retrieve a large numbers of results from a single search request. + # Run a scrolling search. + # IMPORTANT: The scroll API is no longer recommend for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the +search_after+ parameter with a point in time (PIT). + # The scroll API gets large sets of results from a single scrolling search request. + # To get the necessary scroll ID, submit a search API request that includes an argument for the +scroll+ query parameter. + # The +scroll+ parameter indicates how long Elasticsearch should retain the search context for the request. + # The search response returns a scroll ID in the +_scroll_id+ response body parameter. + # You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request. + # If the Elasticsearch security features are enabled, the access to the results of a specific scroll ID is restricted to the user or API key that submitted the search. + # You can also use the scroll API to specify a new scroll parameter that extends or shortens the retention period for the search context. + # IMPORTANT: Results from a scrolling search reflect the state of the index at the time of the initial search request. Subsequent indexing or document changes only affect later search and scroll requests. # - # @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 [String] :scroll_id The scroll ID + # @option arguments [Time] :scroll The period to retain the search context for scrolling. Server default: 1d. + # @option arguments [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 arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter. + # @option arguments [Hash] :body request body # # *Deprecation notice*: # A scroll id can be quite large and should be specified as part of the body # Deprecated since version 7.0.0 # # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-scroll + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-scroll # def scroll(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'scroll' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -50,15 +61,11 @@ def scroll(arguments = {}) Elasticsearch::API::HTTP_GET end - path = if _scroll_id - "_search/scroll/#{Utils.__listify(_scroll_id)}" - else - "_search/scroll" - end + path = '_search/scroll' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search.rb index d278fcb4a4..44808d4708 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search.rb @@ -15,70 +15,155 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns results matching a query. + # Run a search. + # Get search hits that match the query defined in the request. + # You can provide search queries using the +q+ query string parameter or the request body. + # If both are specified, only the query parameter is used. + # If the Elasticsearch security features are enabled, you must have the read index privilege for the target data stream, index, or alias. For cross-cluster search, refer to the documentation about configuring CCS privileges. + # To search a point in time (PIT) for an alias, you must have the +read+ index privilege for the alias's data streams or indices. + # **Search slicing** + # When paging through a large number of documents, it can be helpful to split the search into multiple slices to consume them independently with the +slice+ and +pit+ properties. + # By default the splitting is done first on the shards, then locally on each shard. + # The local splitting partitions the shard into contiguous ranges based on Lucene document IDs. + # For instance if the number of shards is equal to 2 and you request 4 slices, the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 are assigned to the second shard. + # IMPORTANT: The same point-in-time ID should be used for all slices. + # If different PIT IDs are used, slices can overlap and miss documents. + # This situation can occur because the splitting criterion is based on Lucene document IDs, which are not stable across changes to the index. # - # @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] :force_synthetic_source Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index. - # @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_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|long] :track_total_hits Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. - # @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 [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 arguments [String, Array] :index A comma-separated list of data streams, indices, and aliases to search. + # It supports wildcards (+*+). + # To search all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. + # @option arguments [Boolean] :allow_partial_search_results If +true+ and there are shard request timeouts or shard failures, the request returns partial results. + # If +false+, it returns an error with no partial results.To override the default behavior, you can set the +search.default_allow_partial_results+ cluster setting to +false+. Server default: true. + # @option arguments [String] :analyzer The analyzer to use for the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [Boolean] :analyze_wildcard If +true+, wildcard and prefix queries are analyzed. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [Integer] :batched_reduce_size The number of shard results that should be reduced at once on the coordinating node. + # If the potential number of shards in the request can be large, this value should be used as a protection mechanism to reduce the memory overhead per search request. Server default: 512. + # @option arguments [Boolean] :ccs_minimize_roundtrips If +true+, network round-trips between the coordinating node and the remote clusters are minimized when running cross-cluster search (CCS) requests. Server default: true. + # @option arguments [String] :default_operator The default operator for the query string query: +AND+ or +OR+. + # This parameter can be used only when the +q+ query string parameter is specified. Server default: OR. + # @option arguments [String] :df The field to use as a default when no field prefix is given in the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [String, Array] :docvalue_fields A comma-separated list of fields to return as the docvalue representation of a field for each hit. + # @option arguments [String, Array] :expand_wildcards The 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. + # It supports comma-separated values such as +open,hidden+. Server default: open. + # @option arguments [Boolean] :explain If +true+, the request returns detailed information about score computation as part of a hit. + # @option arguments [Boolean] :ignore_throttled If +true+, concrete, expanded or aliased indices will be ignored when frozen. Server default: true. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :include_named_queries_score If +true+, the response includes the score contribution from any named queries.This functionality reruns each named query on every hit in a search response. + # Typically, this adds a small overhead to a request. + # However, using computationally expensive named queries on a large number of hits may add significant overhead. + # @option arguments [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 be used only when the +q+ query string parameter is specified. + # @option arguments [Integer] :max_concurrent_shard_requests The number of concurrent shard requests per node that the search runs 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. Server default: 5. + # @option arguments [String] :preference The nodes and shards used for the search. + # By default, Elasticsearch 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. If suitable shards exist on more than one selected node, use shards on those nodes using the default method. 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. If not, select shards using the default method. + # +_shards:,+ to run the search only on the specified shards. You can combine this value with other +preference+ values. However, the +_shards+ value must come first. For example: +_shards:2,3|_local+. + # ++ (any string that does not start with +_+) to route searches with the same ++ to the same shards in the same order. + # @option arguments [Integer] :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 (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 arguments [Boolean] :request_cache If +true+, the caching of search results is enabled for requests where +size+ is +0+. + # It defaults to index level settings. + # @option arguments [String] :routing A custom value that is used to route operations to a specific shard. + # @option arguments [Time] :scroll The period to retain the search context for scrolling. + # By default, this value cannot exceed +1d+ (24 hours). + # You can change this limit by using the +search.max_keep_alive+ cluster-level setting. + # @option arguments [String] :search_type Indicates how distributed term frequencies are calculated for relevance scoring. + # @option arguments [Array] :stats Specific +tag+ of the request for logging and statistical purposes. + # @option arguments [String, Array] :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 arguments [String] :suggest_field The field to use for suggestions. + # @option arguments [String] :suggest_mode The suggest mode. + # This parameter can be used only when the +suggest_field+ and +suggest_text+ query string parameters are specified. Server default: missing. + # @option arguments [Integer] :suggest_size The number of suggestions to return. + # This parameter can be used only when the +suggest_field+ and +suggest_text+ query string parameters are specified. + # @option arguments [String] :suggest_text The source text for which the suggestions should be returned. + # This parameter can be used only when the +suggest_field+ and +suggest_text+ query string parameters are specified. + # @option arguments [Integer] :terminate_after The maximum number of documents to collect for each shard. + # If a query reaches this limit, Elasticsearch terminates the query early. + # Elasticsearch collects documents before sorting.IMPORTANT: Use with caution. + # Elasticsearch applies this parameter to each shard handling the request. + # When possible, let Elasticsearch perform early termination automatically. + # Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + # If set to +0+ (default), the query does not terminate early. Server default: 0. + # @option arguments [Time] :timeout 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. + # It defaults to no timeout. + # @option arguments [Boolean, Integer] :track_total_hits The 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. Server default: 10000. + # @option arguments [Boolean] :track_scores If +true+, the request calculates and returns document scores, even if the scores are not used for sorting. + # @option arguments [Boolean] :typed_keys If +true+, aggregation and suggester names are 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] :version If +true+, the request returns the document version as part of a hit. + # @option arguments [Boolean, String, Array] :_source The source fields that 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 that supports wildcard (+*+) patterns. Server default: true. + # @option arguments [String, Array] :_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 arguments [String, Array] :_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 arguments [Boolean] :seq_no_primary_term If +true+, the request returns the sequence number and primary term of the last modification of each hit. + # @option arguments [String] :q A query in the Lucene query string syntax. + # Query parameter searches do not support the full Elasticsearch Query DSL but are handy for testing.IMPORTANT: This parameter overrides the query parameter in the request body. + # If both parameters are specified, documents matching the query request body parameter are not returned. + # @option arguments [Integer] :size 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. Server default: 10. + # @option arguments [Integer] :from The starting document offset, which must 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. Server default: 0. + # @option arguments [String] :sort A comma-separated list of +:+ pairs. + # @option arguments [Boolean] :force_synthetic_source Should this request force synthetic _source? + # Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. + # Fetches with this enabled will be slower the enabling synthetic source natively in the index. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search # def search(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -89,14 +174,14 @@ def search(arguments = {}) end path = if _index - "#{Utils.__listify(_index)}/_search" + "#{Utils.listify(_index)}/_search" else - "_search" + '_search' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete.rb index ac9ff6b3fa..0258e382df 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete.rb @@ -15,25 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Deletes a search application. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Delete a search application. + # Remove a search application and its associated alias. Indices attached to the search application are not removed. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. # - # @option arguments [String] :name The name of the search application + # @option arguments [String] :name The name of the search application to delete. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-search-application.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-delete # def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.delete' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -44,11 +52,11 @@ def delete(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_application/search_application/#{Utils.__listify(_name)}" + path = "_application/search_application/#{Utils.listify(_name)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete_behavioral_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete_behavioral_analytics.rb index 5565e636ec..f61dbcc479 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete_behavioral_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete_behavioral_analytics.rb @@ -15,25 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions # Delete a behavioral analytics collection. + # The associated data stream is also deleted. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :name The name of the analytics collection to be deleted + # @option arguments [String] :name The name of the analytics collection to be deleted (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-analytics-collection.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-delete-behavioral-analytics # def delete_behavioral_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.delete_behavioral_analytics' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -44,11 +52,11 @@ def delete_behavioral_analytics(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_application/analytics/#{Utils.__listify(_name)}" + path = "_application/analytics/#{Utils.listify(_name)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/get.rb index 328f3f0dc4..ec1512cee1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/get.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/get.rb @@ -15,25 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Returns the details about a search application. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Get search application details. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. # - # @option arguments [String] :name The name of the search application + # @option arguments [String] :name The name of the search application (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-search-application.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-get # def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.get' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -44,11 +51,11 @@ def get(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_GET - path = "_application/search_application/#{Utils.__listify(_name)}" + path = "_application/search_application/#{Utils.listify(_name)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/get_behavioral_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/get_behavioral_analytics.rb index 3b916a6d87..4b3fbb6518 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/get_behavioral_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/get_behavioral_analytics.rb @@ -15,25 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Returns the existing behavioral analytics collections. + # Get behavioral analytics collections. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :name A comma-separated list of analytics collections to limit the returned information + # @option arguments [Array] :name A list of analytics collections to limit the returned information # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/list-analytics-collection.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-get-behavioral-analytics # def get_behavioral_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.get_behavioral_analytics' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -43,14 +50,14 @@ def get_behavioral_analytics(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_application/analytics/#{Utils.__listify(_name)}" + "_application/analytics/#{Utils.listify(_name)}" else - "_application/analytics" + '_application/analytics' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/list.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/list.rb index 8f97e322f7..d13f52fe89 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/list.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/list.rb @@ -15,38 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Returns the existing search applications. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Get search applications. + # Get information about search applications. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. # - # @option arguments [String] :q Query in the Lucene query string syntax - # @option arguments [Integer] :from Starting offset (default: 0) - # @option arguments [Integer] :size specifies a max number of results to get + # @option arguments [String] :q Query in the Lucene query string syntax. + # @option arguments [Integer] :from Starting offset. Server default: 0. + # @option arguments [Integer] :size Specifies a max number of results to get. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/list-search-applications.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-get-behavioral-analytics # def list(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.list' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_application/search_application" + path = '_application/search_application' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/post_behavioral_analytics_event.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/post_behavioral_analytics_event.rb index ee71ab3785..1bf1b2ffba 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/post_behavioral_analytics_event.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/post_behavioral_analytics_event.rb @@ -15,28 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Creates a behavioral analytics event for existing collection. + # Create a behavioral analytics collection event. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :collection_name The name of behavioral analytics collection - # @option arguments [String] :event_type Behavioral analytics event type. Available: page_view, search, search_click - # @option arguments [Boolean] :debug If true, returns event information that will be stored + # @option arguments [String] :collection_name The name of the behavioral analytics collection. (*Required*) + # @option arguments [String] :event_type The analytics event type. (*Required*) + # @option arguments [Boolean] :debug Whether the response type has to include more details # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The event definition (*Required*) + # @option arguments [Hash] :body payload # - # @see http://todo.com/tbd + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-post-behavioral-analytics-event # def post_behavioral_analytics_event(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.post_behavioral_analytics_event' } + + defined_params = [:collection_name, :event_type].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'collection_name' missing" unless arguments[:collection_name] raise ArgumentError, "Required argument 'event_type' missing" unless arguments[:event_type] @@ -51,11 +58,11 @@ def post_behavioral_analytics_event(arguments = {}) _event_type = arguments.delete(:event_type) method = Elasticsearch::API::HTTP_POST - path = "_application/analytics/#{Utils.__listify(_collection_name)}/event/#{Utils.__listify(_event_type)}" + path = "_application/analytics/#{Utils.listify(_collection_name)}/event/#{Utils.listify(_event_type)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/put.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/put.rb index 9a3f7e566e..aa31b7b375 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/put.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/put.rb @@ -15,27 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Creates or updates a search application. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Create or update a search application. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. # - # @option arguments [String] :name The name of the search application to be created or updated - # @option arguments [Boolean] :create If true, requires that a search application with the specified resource_id does not already exist. (default: false) + # @option arguments [String] :name The name of the search application to be created or updated. (*Required*) + # @option arguments [Boolean] :create If +true+, this request cannot replace or update existing Search Applications. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search application configuration, including `indices` (*Required*) + # @option arguments [Hash] :body search_application # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-search-application.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-put # def put(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.put' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -47,11 +54,11 @@ def put(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_application/search_application/#{Utils.__listify(_name)}" + path = "_application/search_application/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/put_behavioral_analytics.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/put_behavioral_analytics.rb index 5551f9b9ab..0b6789da76 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/put_behavioral_analytics.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/put_behavioral_analytics.rb @@ -15,25 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Creates a behavioral analytics collection. + # Create a behavioral analytics collection. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :name The name of the analytics collection to be created or updated + # @option arguments [String] :name The name of the analytics collection to be created or updated. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-analytics-collection.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-put-behavioral-analytics # def put_behavioral_analytics(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.put_behavioral_analytics' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -44,11 +51,11 @@ def put_behavioral_analytics(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_application/analytics/#{Utils.__listify(_name)}" + path = "_application/analytics/#{Utils.listify(_name)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/render_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/render_query.rb index 91f27e67f8..a2183ec60f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/render_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/render_query.rb @@ -15,26 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Renders a query for given search application search parameters + # Render a search application query. + # Generate an Elasticsearch query using the specified query parameters and the search template associated with the search application or a default template if none is specified. + # If a parameter used in the search template is not specified in +params+, the parameter's default value will be used. + # The API returns the specific Elasticsearch query that would be generated and run by calling the search application search API. + # You must have +read+ privileges on the backing alias of the search application. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :name The name of the search application to render the query for + # @option arguments [String] :name The name of the search application to render teh query for. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Search parameters, which will override any default search parameters defined in the search application template + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-application-render-query.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-render-query # def render_query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.render_query' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -45,11 +56,11 @@ def render_query(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_POST - path = "_application/search_application/#{Utils.__listify(_name)}/_render_query" + path = "_application/search_application/#{Utils.listify(_name)}/_render_query" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/search.rb index 0a9c36381f..296541707e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_application/search.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_application/search.rb @@ -15,26 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchApplication module Actions - # Perform a search against a search application - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Run a search application search. + # Generate and run an Elasticsearch query that uses the specified query parameteter and the search template associated with the search application or default template. + # Unspecified template parameters are assigned their default values if applicable. + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. # - # @option arguments [String] :name The name of the search application to be searched + # @option arguments [String] :name The name of the search application to be searched. (*Required*) + # @option arguments [Boolean] :typed_keys Determines whether aggregation names are prefixed by their respective types in the response. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Search parameters, including template parameters that override defaults + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-application-search.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-search # def search(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_application.search' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -50,11 +60,11 @@ def search(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_application/search_application/#{Utils.__listify(_name)}/_search" - params = {} + path = "_application/search_application/#{Utils.listify(_name)}/_search" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_mvt.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_mvt.rb index a19695770b..8a5850b60d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_mvt.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_mvt.rb @@ -15,36 +15,174 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Search a vector tile. + # Search a vector tile for geospatial values. + # Before using this API, you should be familiar with the Mapbox vector tile specification. + # The API returns results as a binary mapbox vector tile. + # Internally, Elasticsearch translates a vector tile search API request into a search containing: + # * A +geo_bounding_box+ query on the ++. The query uses the +//+ tile as a bounding box. + # * A +geotile_grid+ or +geohex_grid+ aggregation on the ++. The +grid_agg+ parameter determines the aggregation type. The aggregation uses the +//+ tile as a bounding box. + # * Optionally, a +geo_bounds+ aggregation on the ++. The search only includes this aggregation if the +exact_bounds+ parameter is +true+. + # * If the optional parameter +with_labels+ is +true+, the internal search will include a dynamic runtime field that calls the +getLabelPosition+ function of the geometry doc value. This enables the generation of new point features containing suggested geometry labels, so that, for example, multi-polygons will have only one label. + # For example, Elasticsearch may translate a vector tile search API request with a +grid_agg+ argument of +geotile+ and an +exact_bounds+ argument of +true+ into the following search + # + + # GET my-index/_search + # { + # "size": 10000, + # "query": { + # "geo_bounding_box": { + # "my-geo-field": { + # "top_left": { + # "lat": -40.979898069620134, + # "lon": -45 + # }, + # "bottom_right": { + # "lat": -66.51326044311186, + # "lon": 0 + # } + # } + # } + # }, + # "aggregations": { + # "grid": { + # "geotile_grid": { + # "field": "my-geo-field", + # "precision": 11, + # "size": 65536, + # "bounds": { + # "top_left": { + # "lat": -40.979898069620134, + # "lon": -45 + # }, + # "bottom_right": { + # "lat": -66.51326044311186, + # "lon": 0 + # } + # } + # } + # }, + # "bounds": { + # "geo_bounds": { + # "field": "my-geo-field", + # "wrap_longitude": false + # } + # } + # } + # } + # + + # The API returns results as a binary Mapbox vector tile. + # Mapbox vector tiles are encoded as Google Protobufs (PBF). By default, the tile contains three layers: + # * A +hits+ layer containing a feature for each ++ value matching the +geo_bounding_box+ query. + # * An +aggs+ layer containing a feature for each cell of the +geotile_grid+ or +geohex_grid+. The layer only contains features for cells with matching data. + # * A meta layer containing: + # * A feature containing a bounding box. By default, this is the bounding box of the tile. + # * Value ranges for any sub-aggregations on the +geotile_grid+ or +geohex_grid+. + # * Metadata for the search. + # The API only returns features that can display at its zoom level. + # For example, if a polygon feature has no area at its zoom level, the API omits it. + # The API returns errors as UTF-8 encoded JSON. + # IMPORTANT: You can specify several options for this API as either a query parameter or request body parameter. + # If you specify both parameters, the query parameter takes precedence. + # **Grid precision for geotile** + # For a +grid_agg+ of +geotile+, you can use cells in the +aggs+ layer as tiles for lower zoom levels. + # +grid_precision+ represents the additional zoom levels available through these cells. The final precision is computed by as follows: + + grid_precision+. + # For example, if ++ is 7 and +grid_precision+ is 8, then the +geotile_grid+ aggregation will use a precision of 15. + # The maximum final precision is 29. + # The +grid_precision+ also determines the number of cells for the grid as follows: +(2^grid_precision) x (2^grid_precision)+. + # For example, a value of 8 divides the tile into a grid of 256 x 256 cells. + # The +aggs+ layer only contains features for cells with matching data. + # **Grid precision for geohex** + # For a +grid_agg+ of +geohex+, Elasticsearch uses ++ and +grid_precision+ to calculate a final precision as follows: + + grid_precision+. + # This precision determines the H3 resolution of the hexagonal cells produced by the +geohex+ aggregation. + # The following table maps the H3 resolution for each precision. + # For example, if ++ is 3 and +grid_precision+ is 3, the precision is 6. + # At a precision of 6, hexagonal cells have an H3 resolution of 2. + # If ++ is 3 and +grid_precision+ is 4, the precision is 7. + # At a precision of 7, hexagonal cells have an H3 resolution of 3. + # | Precision | Unique tile bins | H3 resolution | Unique hex bins | Ratio | + # | --------- | ---------------- | ------------- | ----------------| ----- | + # | 1 | 4 | 0 | 122 | 30.5 | + # | 2 | 16 | 0 | 122 | 7.625 | + # | 3 | 64 | 1 | 842 | 13.15625 | + # | 4 | 256 | 1 | 842 | 3.2890625 | + # | 5 | 1024 | 2 | 5882 | 5.744140625 | + # | 6 | 4096 | 2 | 5882 | 1.436035156 | + # | 7 | 16384 | 3 | 41162 | 2.512329102 | + # | 8 | 65536 | 3 | 41162 | 0.6280822754 | + # | 9 | 262144 | 4 | 288122 | 1.099098206 | + # | 10 | 1048576 | 4 | 288122 | 0.2747745514 | + # | 11 | 4194304 | 5 | 2016842 | 0.4808526039 | + # | 12 | 16777216 | 6 | 14117882 | 0.8414913416 | + # | 13 | 67108864 | 6 | 14117882 | 0.2103728354 | + # | 14 | 268435456 | 7 | 98825162 | 0.3681524172 | + # | 15 | 1073741824 | 8 | 691776122 | 0.644266719 | + # | 16 | 4294967296 | 8 | 691776122 | 0.1610666797 | + # | 17 | 17179869184 | 9 | 4842432842 | 0.2818666889 | + # | 18 | 68719476736 | 10 | 33897029882 | 0.4932667053 | + # | 19 | 274877906944 | 11 | 237279209162 | 0.8632167343 | + # | 20 | 1099511627776 | 11 | 237279209162 | 0.2158041836 | + # | 21 | 4398046511104 | 12 | 1660954464122 | 0.3776573213 | + # | 22 | 17592186044416 | 13 | 11626681248842 | 0.6609003122 | + # | 23 | 70368744177664 | 13 | 11626681248842 | 0.165225078 | + # | 24 | 281474976710656 | 14 | 81386768741882 | 0.2891438866 | + # | 25 | 1125899906842620 | 15 | 569707381193162 | 0.5060018015 | + # | 26 | 4503599627370500 | 15 | 569707381193162 | 0.1265004504 | + # | 27 | 18014398509482000 | 15 | 569707381193162 | 0.03162511259 | + # | 28 | 72057594037927900 | 15 | 569707381193162 | 0.007906278149 | + # | 29 | 288230376151712000 | 15 | 569707381193162 | 0.001976569537 | + # Hexagonal cells don't align perfectly on a vector tile. + # Some cells may intersect more than one vector tile. + # To compute the H3 resolution for each precision, Elasticsearch compares the average density of hexagonal bins at each resolution with the average density of tile bins at each zoom level. + # Elasticsearch uses the H3 resolution that is closest to the corresponding geotile density. # - # @option arguments [List] :index Comma-separated list of data streams, indices, or aliases to search - # @option arguments [String] :field Field containing geospatial data to return - # @option arguments [Integer] :zoom Zoom level for the vector tile to search - # @option arguments [Integer] :x X coordinate for the vector tile to search - # @option arguments [Integer] :y Y coordinate for the vector tile to search - # @option arguments [Boolean] :exact_bounds If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation. - # @option arguments [Integer] :extent Size, in pixels, of a side of the vector tile. - # @option arguments [Integer] :grid_precision Additional zoom levels available through the aggs layer. Accepts 0-8. - # @option arguments [String] :grid_type Determines the geometry type for features in the aggs layer. (options: grid, point, centroid) + # @option arguments [String, Array] :index Comma-separated list of data streams, indices, or aliases to search (*Required*) + # @option arguments [String] :field Field containing geospatial data to return (*Required*) + # @option arguments [Integer] :zoom Zoom level for the vector tile to search (*Required*) + # @option arguments [Integer] :x X coordinate for the vector tile to search (*Required*) + # @option arguments [Integer] :y Y coordinate for the vector tile to search (*Required*) + # @option arguments [Boolean] :exact_bounds If +false+, the meta layer's feature is the bounding box of the tile. + # If true, the meta layer's feature is a bounding box resulting from a + # geo_bounds aggregation. The aggregation runs on values that intersect + # the // tile with wrap_longitude set to false. The resulting + # bounding box may be larger than the vector tile. + # @option arguments [Integer] :extent The size, in pixels, of a side of the tile. Vector tiles are square with equal sides. Server default: 4096. + # @option arguments [String] :grid_agg Aggregation used to create a grid for +field+. + # @option arguments [Integer] :grid_precision Additional zoom levels available through the aggs layer. For example, if is 7 + # and grid_precision is 8, you can zoom in up to level 15. Accepts 0-8. If 0, results + # don't include the aggs layer. Server default: 8. + # @option arguments [String] :grid_type Determines the geometry type for features in the aggs layer. In the aggs layer, + # each feature represents a geotile_grid cell. If 'grid' each feature is a Polygon + # of the cells bounding box. If 'point' each feature is a Point that is the centroid + # of the cell. Server default: grid. # @option arguments [Integer] :size Maximum number of features to return in the hits layer. Accepts 0-10000. - # @option arguments [Boolean|long] :track_total_hits Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. - # @option arguments [Boolean] :with_labels If true, the hits and aggs layers will contain additional point features with suggested label positions for the original features. + # If 0, results don't include the hits layer. Server default: 10000. + # @option arguments [Boolean] :with_labels If +true+, the hits and aggs layers will contain additional point features representing + # suggested label positions for the original features. + # - +Point+ and +MultiPoint+ features will have one of the points selected. + # - +Polygon+ and +MultiPolygon+ features will have a single point generated, either the centroid, if it is within the polygon, or another point within the polygon selected from the sorted triangle-tree. + # - +LineString+ features will likewise provide a roughly central point selected from the triangle-tree. + # - The aggregation results will provide one central point for each aggregation bucket. + # All attributes from the original features will also be copied to the new label features. + # In addition, the new features will be distinguishable using the tag +_mvt_label_position+. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Search request body. + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-vector-tile-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-mvt # def search_mvt(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_mvt' } + + defined_params = [:index, :field, :zoom, :x, :y].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'field' missing" unless arguments[:field] raise ArgumentError, "Required argument 'zoom' missing" unless arguments[:zoom] @@ -54,7 +192,7 @@ def search_mvt(arguments = {}) arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -67,11 +205,11 @@ def search_mvt(arguments = {}) _y = arguments.delete(:y) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_mvt/#{Utils.__listify(_field)}/#{Utils.__listify(_zoom)}/#{Utils.__listify(_x)}/#{Utils.__listify(_y)}" + path = "#{Utils.listify(_index)}/_mvt/#{Utils.listify(_field)}/#{Utils.listify(_zoom)}/#{Utils.listify(_x)}/#{Utils.listify(_y)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_shards.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_shards.rb index 8b03109690..650d78a078 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_shards.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_shards.rb @@ -15,43 +15,65 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns information about the indices and shards that a search request would be executed against. + # Get the search shards. + # Get the indices and shards that a search request would be run against. + # This information can be useful for working out issues or planning optimizations with routing and shard preferences. + # When filtered aliases are used, the filter is returned as part of the +indices+ section. + # If the Elasticsearch security features are enabled, you must have the +view_index_metadata+ or +manage+ index privilege for the target data stream, index, or alias. # - # @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 master 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 [String, Array] :index A comma-separated list of data streams, indices, and aliases to search. + # It supports wildcards (+*+). + # To search all data streams and indices, omit this parameter or use +*+ or +_all+. + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. + # @option arguments [String, Array] :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+. Server default: open. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [Boolean] :local If +true+, the request retrieves information from the local node only. + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # IT can also be set to +-1+ to indicate that the request should never timeout. Server default: 30s. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # It is random by default. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-shards.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-shards # def search_shards(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_shards' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "#{Utils.__listify(_index)}/_search_shards" + "#{Utils.listify(_index)}/_search_shards" else - "_search_shards" + '_search_shards' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/search_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/search_template.rb index c3a2dd7ece..eedc6b23d8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/search_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/search_template.rb @@ -15,53 +15,69 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Allows to use the Mustache language to pre-render a search definition. + # Run a search with a search template. # - # @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 [String, Array] :index A comma-separated list of data streams, indices, and aliases to search. + # It supports wildcards (+*+). + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. + # @option arguments [Boolean] :ccs_minimize_roundtrips If +true+, network round-trips are minimized for cross-cluster search requests. + # @option arguments [String, Array] :expand_wildcards The 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 arguments [Boolean] :explain If +true+, the response includes additional details about score computation as part of a hit. + # @option arguments [Boolean] :ignore_throttled If +true+, specified concrete, expanded, or aliased indices are not included in the response when throttled. Server default: true. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # It is random by default. + # @option arguments [Boolean] :profile If +true+, the query execution is profiled. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Time] :scroll Specifies how long a consistent view of the index + # should be maintained for scrolled search. + # @option arguments [String] :search_type The type of the search operation. + # @option arguments [Boolean] :rest_total_hits_as_int If +true+, +hits.total+ is rendered as an integer in the response. + # If +false+, it is rendered as an object. + # @option arguments [Boolean] :typed_keys If +true+, the response prefixes aggregation and suggester names with their respective types. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition template and its params (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-template # def search_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'search_template' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_search/template" + "#{Utils.listify(_index)}/_search/template" else - "_search/template" + '_search/template' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/cache_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/cache_stats.rb index 7c194bdc0a..aba29a4436 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/cache_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/cache_stats.rb @@ -15,25 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchableSnapshots module Actions - # Retrieve node-level cache statistics about searchable snapshots. + # Get cache statistics. + # Get statistics about the shared cache for partially mounted indices. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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] :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 [String, Array] :node_id The names of the nodes in the cluster to target. + # @option arguments [Time] :master_timeout [TODO] # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-searchable-snapshots-cache-stats # def cache_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'searchable_snapshots.cache_stats' } + + defined_params = [:node_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -43,14 +52,14 @@ def cache_stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _node_id - "_searchable_snapshots/#{Utils.__listify(_node_id)}/cache/stats" + "_searchable_snapshots/#{Utils.listify(_node_id)}/cache/stats" else - "_searchable_snapshots/cache/stats" + '_searchable_snapshots/cache/stats' end - params = {} + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/clear_cache.rb b/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/clear_cache.rb index 63e42e7cbd..9f6e8b6232 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/clear_cache.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/clear_cache.rb @@ -15,45 +15,54 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchableSnapshots module Actions - # Clear the cache of searchable snapshots. + # Clear the cache. + # Clear indices and data streams from the shared cache for partially mounted indices. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 + # @option arguments [String, Array] :index A comma-separated list of data streams, indices, and aliases to clear from the cache. + # It supports wildcards (+*+). + # @option arguments [String, Array] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. + # @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 [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, none, all) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-searchable-snapshots-clear-cache # def clear_cache(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'searchable_snapshots.clear_cache' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST path = if _index - "#{Utils.__listify(_index)}/_searchable_snapshots/cache/clear" + "#{Utils.listify(_index)}/_searchable_snapshots/cache/clear" else - "_searchable_snapshots/cache/clear" + '_searchable_snapshots/cache/clear' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/mount.rb b/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/mount.rb index 08f1b0e198..14cbc50f68 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/mount.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/mount.rb @@ -15,26 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchableSnapshots module Actions - # Mount a snapshot as a searchable index. + # Mount a snapshot. + # Mount a snapshot as a searchable snapshot index. + # Do not use this API for snapshots managed by index lifecycle management (ILM). + # Manually mounting ILM-managed snapshots can interfere with ILM processes. # - # @option arguments [String] :repository The name of the repository containing the snapshot of the index to mount - # @option arguments [String] :snapshot The name of the snapshot of the index to mount - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning - # @option arguments [String] :storage Selects the kind of local storage used to accelerate searches. Experimental, and defaults to `full_copy` + # @option arguments [String] :repository The name of the repository containing the snapshot of the index to mount. (*Required*) + # @option arguments [String] :snapshot The name of the snapshot of the index to mount. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Boolean] :wait_for_completion If true, the request blocks until the operation is complete. + # @option arguments [String] :storage The mount option for the searchable snapshot index. Server default: full_copy. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The restore configuration for mounting the snapshot as searchable (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-api-mount-snapshot.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-searchable-snapshots-mount # def mount(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'searchable_snapshots.mount' } + + defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + 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] @@ -49,11 +61,11 @@ def mount(arguments = {}) _snapshot = arguments.delete(:snapshot) method = Elasticsearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}/_mount" + path = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}/_mount" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/stats.rb index 0a214885f4..b14cc08e11 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/searchable_snapshots/stats.rb @@ -15,39 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SearchableSnapshots module Actions - # Retrieve shard-level statistics about searchable snapshots. + # Get searchable snapshot statistics. # - # @option arguments [List] :index A comma-separated list of index names - # @option arguments [String] :level Return stats aggregated at cluster, index or shard level (options: cluster, indices, shards) + # @option arguments [String, Array] :index A comma-separated list of data streams and indices to retrieve statistics for. + # @option arguments [String] :level Return stats aggregated at cluster, index or shard level # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/searchable-snapshots-apis.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-searchable-snapshots-stats # def stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'searchable_snapshots.stats' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_GET path = if _index - "#{Utils.__listify(_index)}/_searchable_snapshots/stats" + "#{Utils.listify(_index)}/_searchable_snapshots/stats" else - "_searchable_snapshots/stats" + '_searchable_snapshots/stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/activate_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/activate_user_profile.rb index de2b478aca..1820a7862e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/activate_user_profile.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/activate_user_profile.rb @@ -15,34 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates or updates the user profile on behalf of another user. + # Activate a user profile. + # Create or update a user profile on behalf of another user. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # The calling application must have either an +access_token+ or a combination of +username+ and +password+ for the user that the profile document is intended for. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # This API creates or updates a profile document for end users with information that is extracted from the user's authentication object including +username+, +full_name,+ +roles+, and the authentication realm. + # For example, in the JWT +access_token+ case, the profile user's +username+ is extracted from the JWT token claim pointed to by the +claims.principal+ setting of the JWT realm that authenticated the token. + # When updating a profile document, the API enables the document if it was disabled. + # Any updates do not change existing content for either the +labels+ or +data+ fields. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The grant type and user's credential (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-activate-user-profile.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-activate-user-profile # def activate_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.activate_user_profile' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/profile/_activate" + path = '_security/profile/_activate' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/authenticate.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/authenticate.rb index eed4a29a5e..d343ed41ed 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/authenticate.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/authenticate.rb @@ -15,31 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Enables authentication as a user and retrieve information about the authenticated user. + # Authenticate a user. + # Authenticates a user and returns information about the authenticated user. + # Include the user information in a {https://en.wikipedia.org/wiki/Basic_access_authentication basic auth header}. + # A successful call returns a JSON structure that shows user information such as their username, the roles that are assigned to the user, any assigned metadata, and information about the realms that authenticated and authorized the user. + # If the user cannot be authenticated, this API returns a 401 status code. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-authenticate # def authenticate(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.authenticate' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_security/_authenticate" + path = '_security/_authenticate' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_delete_role.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_delete_role.rb new file mode 100644 index 0000000000..16181fe490 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_delete_role.rb @@ -0,0 +1,56 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Security + module Actions + # Bulk delete roles. + # The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. + # The bulk delete roles API cannot delete roles that are defined in roles files. + # + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-bulk-delete-role + # + def bulk_delete_role(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.bulk_delete_role' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_DELETE + path = '_security/role' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_put_role.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_put_role.rb new file mode 100644 index 0000000000..464bdfe127 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_put_role.rb @@ -0,0 +1,56 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Security + module Actions + # Bulk create or update roles. + # The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. + # The bulk create or update roles API cannot update roles that are defined in roles files. + # + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-bulk-put-role + # + def bulk_put_role(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.bulk_put_role' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_security/role' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_update_api_keys.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_update_api_keys.rb index 5b0f12419b..5fd4b57238 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_update_api_keys.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/bulk_update_api_keys.rb @@ -15,34 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Updates the attributes of multiple existing API keys. + # Bulk update API keys. + # Update the attributes for multiple API keys. + # IMPORTANT: It is not possible to use an API key as the authentication credential for this API. To update API keys, the owner user's credentials are required. + # This API is similar to the update API key API but enables you to apply the same update to multiple API keys in one API call. This operation can greatly improve performance over making individual updates. + # It is not possible to update expired or invalidated API keys. + # This API supports updates to API key access scope, metadata and expiration. + # The access scope of each API key is derived from the +role_descriptors+ you specify in the request and a snapshot of the owner user's permissions at the time of the request. + # The snapshot of the owner's permissions is updated automatically on every call. + # IMPORTANT: If you don't specify +role_descriptors+ in the request, a call to this API might still change an API key's access scope. This change can occur if the owner user's permissions have changed since the API key was created or last modified. + # A successful request returns a JSON structure that contains the IDs of all updated API keys, the IDs of API keys that already had the requested changes and did not require an update, and error details for any failed update. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The API key request to update the attributes of multiple API keys. (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-update-api-keys.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-bulk-update-api-keys # def bulk_update_api_keys(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.bulk_update_api_keys' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/api_key/_bulk_update" + path = '_security/api_key/_bulk_update' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/change_password.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/change_password.rb index 239a8f38e6..296ef4fd8a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/change_password.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/change_password.rb @@ -15,23 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Changes the passwords of users in the native realm and built-in users. + # Change passwords. + # Change the passwords of users in the native realm and built-in users. # - # @option arguments [String] :username The username of the user to change the password for - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :username The user whose password you want to change. If you do not specify this + # parameter, the password is changed for the current user. + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body the new password for the user (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-change-password # def change_password(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.change_password' } + + defined_params = [:username].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone @@ -43,14 +52,14 @@ def change_password(arguments = {}) method = Elasticsearch::API::HTTP_PUT path = if _username - "_security/user/#{Utils.__listify(_username)}/_password" + "_security/user/#{Utils.listify(_username)}/_password" else - "_security/user/_password" + '_security/user/_password' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_api_key_cache.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_api_key_cache.rb index aba6705fbf..e24496f632 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_api_key_cache.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_api_key_cache.rb @@ -15,36 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Clear a subset or all entries from the API key cache. + # Clear the API key cache. + # Evict a subset of all entries from the API key cache. + # The cache is also automatically cleared on state changes of the security index. # - # @option arguments [List] :ids A comma-separated list of IDs of API keys to clear from the cache + # @option arguments [String, Array] :ids Comma-separated list of API key IDs to evict from the API key cache. + # To evict all API keys, use +*+. + # Does not support other wildcard patterns. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-api-key-cache.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-clear-api-key-cache # def clear_api_key_cache(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.clear_api_key_cache' } + + defined_params = [:ids].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'ids' missing" unless arguments[:ids] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _ids = arguments.delete(:ids) method = Elasticsearch::API::HTTP_POST - path = "_security/api_key/#{Utils.__listify(_ids)}/_clear_cache" + path = "_security/api_key/#{Utils.listify(_ids)}/_clear_cache" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_privileges.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_privileges.rb index abd6699fae..5007b253b7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_privileges.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_privileges.rb @@ -15,21 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Evicts application privileges from the native application privileges cache. + # Clear the privileges cache. + # Evict privileges from the native application privilege cache. + # The cache is also automatically cleared for applications that have their privileges updated. # - # @option arguments [List] :application A comma-separated list of application names + # @option arguments [String] :application A comma-separated list of applications. + # To clear all applications, use an asterism (+*+). + # It does not support other wildcard patterns. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-privilege-cache.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-clear-cached-privileges # def clear_cached_privileges(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.clear_cached_privileges' } + + defined_params = [:application].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'application' missing" unless arguments[:application] arguments = arguments.clone @@ -40,11 +51,11 @@ def clear_cached_privileges(arguments = {}) _application = arguments.delete(:application) method = Elasticsearch::API::HTTP_POST - path = "_security/privilege/#{Utils.__listify(_application)}/_clear_cache" + path = "_security/privilege/#{Utils.listify(_application)}/_clear_cache" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_realms.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_realms.rb index 4e039ebea5..b4df7c77b7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_realms.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_realms.rb @@ -15,22 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Evicts users from the user cache. Can completely clear the cache or evict specific users. + # Clear the user cache. + # Evict users from the user cache. + # You can completely clear the cache or evict specific users. + # User credentials are cached in memory on each node to avoid connecting to a remote authentication service or hitting the disk for every incoming request. + # There are realm settings that you can use to configure the user cache. + # For more information, refer to the documentation about controlling the user cache. # - # @option arguments [List] :realms Comma-separated list of realms to clear - # @option arguments [List] :usernames Comma-separated list of usernames to clear from the cache + # @option arguments [String, Array] :realms A comma-separated list of realms. + # To clear all realms, use an asterisk (+*+). + # It does not support other wildcard patterns. (*Required*) + # @option arguments [Array] :usernames A comma-separated list of the users to clear from the cache. + # If you do not specify this parameter, the API evicts all users from the user cache. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-clear-cached-realms # def clear_cached_realms(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.clear_cached_realms' } + + defined_params = [:realms].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'realms' missing" unless arguments[:realms] arguments = arguments.clone @@ -41,11 +56,11 @@ def clear_cached_realms(arguments = {}) _realms = arguments.delete(:realms) method = Elasticsearch::API::HTTP_POST - path = "_security/realm/#{Utils.__listify(_realms)}/_clear_cache" + path = "_security/realm/#{Utils.listify(_realms)}/_clear_cache" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_roles.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_roles.rb index 5b8cf1b848..cc4443f1ad 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_roles.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_roles.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Evicts roles from the native role cache. + # Clear the roles cache. + # Evict roles from the native role cache. # - # @option arguments [List] :name Role name + # @option arguments [String, Array] :name A comma-separated list of roles to evict from the role cache. + # To evict all roles, use an asterisk (+*+). + # It does not support other wildcard patterns. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-clear-cached-roles # def clear_cached_roles(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.clear_cached_roles' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -40,11 +50,11 @@ def clear_cached_roles(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_POST - path = "_security/role/#{Utils.__listify(_name)}/_clear_cache" + path = "_security/role/#{Utils.listify(_name)}/_clear_cache" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_service_tokens.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_service_tokens.rb index 6ca1f72b4a..9c75240a35 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_service_tokens.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/clear_cached_service_tokens.rb @@ -15,23 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Evicts tokens from the service account token caches. + # Clear service account token caches. + # Evict a subset of all entries from the service account token caches. + # Two separate caches exist for service account tokens: one cache for tokens backed by the +service_tokens+ file, and another for tokens backed by the +.security+ index. + # This API clears matching entries from both caches. + # The cache for service account tokens backed by the +.security+ index is cleared automatically on state changes of the security index. + # The cache for tokens backed by the +service_tokens+ file is cleared automatically on file changes. # - # @option arguments [String] :namespace An identifier for the namespace - # @option arguments [String] :service An identifier for the service name - # @option arguments [List] :name A comma-separated list of service token names + # @option arguments [String] :namespace The namespace, which is a top-level grouping of service accounts. (*Required*) + # @option arguments [String] :service The name of the service, which must be unique within its namespace. (*Required*) + # @option arguments [String, Array] :name A comma-separated list of token names to evict from the service account token caches. + # Use a wildcard (+*+) to evict all tokens that belong to a service account. + # It does not support other wildcard patterns. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-service-token-caches.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-clear-cached-service-tokens # def clear_cached_service_tokens(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.clear_cached_service_tokens' } + + defined_params = [:namespace, :service, :name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'namespace' missing" unless arguments[:namespace] raise ArgumentError, "Required argument 'service' missing" unless arguments[:service] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -48,11 +62,11 @@ def clear_cached_service_tokens(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_POST - path = "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token/#{Utils.__listify(_name)}/_clear_cache" + path = "_security/service/#{Utils.listify(_namespace)}/#{Utils.listify(_service)}/credential/token/#{Utils.listify(_name)}/_clear_cache" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/create_api_key.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/create_api_key.rb index 5d0fc93ddb..3810fba2bc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/create_api_key.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/create_api_key.rb @@ -15,35 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates an API key for access without requiring basic authentication. + # Create an API key. + # Create an API key for access without requiring basic authentication. + # IMPORTANT: If the credential that is used to authenticate this request is an API key, the derived API key cannot have any privileges. + # If you specify privileges, the API returns an error. + # A successful request returns a JSON structure that contains the API key, its unique id, and its name. + # If applicable, it also returns expiration information for the API key in milliseconds. + # NOTE: By default, API keys never expire. You can specify expiration information when you create the API keys. + # The API keys are created by the Elasticsearch API key service, which is automatically enabled. + # To configure or turn off the API key service, refer to API key service setting documentation. # - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The api key request to create an API key (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-api-key # def create_api_key(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.create_api_key' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_PUT - path = "_security/api_key" + path = '_security/api_key' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/create_cross_cluster_api_key.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/create_cross_cluster_api_key.rb index ee3a6125b2..939ec2f287 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/create_cross_cluster_api_key.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/create_cross_cluster_api_key.rb @@ -15,38 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates a cross-cluster API key for API key based remote cluster access. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Create a cross-cluster API key. + # Create an API key of the +cross_cluster+ type for the API key based remote cluster access. + # A +cross_cluster+ API key cannot be used to authenticate through the REST interface. + # IMPORTANT: To authenticate this request you must use a credential that is not an API key. Even if you use an API key that has the required privilege, the API returns an error. + # Cross-cluster API keys are created by the Elasticsearch API key service, which is automatically enabled. + # NOTE: Unlike REST API keys, a cross-cluster API key does not capture permissions of the authenticated user. The API key’s effective permission is exactly as specified with the +access+ property. + # A successful request returns a JSON structure that contains the API key, its unique ID, and its name. If applicable, it also returns expiration information for the API key in milliseconds. + # By default, API keys never expire. You can specify expiration information when you create the API keys. + # Cross-cluster API keys can only be updated with the update cross-cluster API key API. + # Attempting to update them with the update REST API key API or the bulk update REST API keys API will result in an error. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request to create a cross-cluster API key (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-cross-cluster-api-key.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-cross-cluster-api-key # def create_cross_cluster_api_key(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.create_cross_cluster_api_key' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/cross_cluster/api_key" + path = '_security/cross_cluster/api_key' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/create_service_token.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/create_service_token.rb index 42bc6d73fa..3315f2d18f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/create_service_token.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/create_service_token.rb @@ -15,24 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates a service account token for access without requiring basic authentication. + # Create a service account token. + # Create a service accounts token for access without requiring basic authentication. + # NOTE: Service account tokens never expire. + # You must actively delete them if they are no longer needed. # - # @option arguments [String] :namespace An identifier for the namespace - # @option arguments [String] :service An identifier for the service name - # @option arguments [String] :name An identifier for the token name - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :namespace The name of the namespace, which is a top-level grouping of service accounts. (*Required*) + # @option arguments [String] :service The name of the service. (*Required*) + # @option arguments [String] :name The name for the service account token. + # If omitted, a random name will be generated.Token names must be at least one and no more than 256 characters. + # They can contain alphanumeric characters (a-z, A-Z, 0-9), dashes (+-+), and underscores (+_+), but cannot begin with an underscore.NOTE: Token names must be unique in the context of the associated service account. + # They must also be globally unique with their fully qualified names, which are comprised of the service account principal and token name, such as +//+. + # @option arguments [String] :refresh If +true+ then refresh the affected shards to make this operation visible to search, if +wait_for+ (the default) then wait for a refresh to make this operation visible to search, if +false+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-service-token.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-service-token # def create_service_token(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.create_service_token' } + + defined_params = [:namespace, :service, :name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'namespace' missing" unless arguments[:namespace] raise ArgumentError, "Required argument 'service' missing" unless arguments[:service] @@ -49,14 +62,14 @@ def create_service_token(arguments = {}) method = _name ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST path = if _namespace && _service && _name - "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token/#{Utils.__listify(_name)}" + "_security/service/#{Utils.listify(_namespace)}/#{Utils.listify(_service)}/credential/token/#{Utils.listify(_name)}" else - "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token" + "_security/service/#{Utils.listify(_namespace)}/#{Utils.listify(_service)}/credential/token" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/delegate_pki.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/delegate_pki.rb new file mode 100644 index 0000000000..e02386aaf6 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/delegate_pki.rb @@ -0,0 +1,60 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Security + module Actions + # Delegate PKI authentication. + # This API implements the exchange of an X509Certificate chain for an Elasticsearch access token. + # The certificate chain is validated, according to RFC 5280, by sequentially considering the trust configuration of every installed PKI realm that has +delegation.enabled+ set to +true+. + # A successfully trusted client certificate is also subject to the validation of the subject distinguished name according to thw +username_pattern+ of the respective realm. + # This API is called by smart and trusted proxies, such as Kibana, which terminate the user's TLS session but still want to authenticate the user by using a PKI realm—-​as if the user connected directly to Elasticsearch. + # IMPORTANT: The association between the subject public key in the target certificate and the corresponding private key is not validated. + # This is part of the TLS authentication process and it is delegated to the proxy that calls this API. + # The proxy is trusted to have performed the TLS authentication and this API translates that authentication into an Elasticsearch access token. + # + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-delegate-pki + # + def delegate_pki(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.delegate_pki' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_security/delegate_pki' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_privileges.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_privileges.rb index d25c5b95e3..494c5608e8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_privileges.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_privileges.rb @@ -15,23 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Removes application privileges. + # Delete application privileges. + # To use this API, you must have one of the following privileges: + # * The +manage_security+ cluster privilege (or a greater privilege such as +all+). + # * The "Manage Application Privileges" global privilege for the application being referenced in the request. # - # @option arguments [String] :application Application name - # @option arguments [String] :name Privilege name - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :application The name of the application. + # Application privileges are always associated with exactly one application. (*Required*) + # @option arguments [String, Array] :name The name of the privilege. (*Required*) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-privilege.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-delete-privileges # def delete_privileges(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.delete_privileges' } + + defined_params = [:application, :name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'application' missing" unless arguments[:application] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -45,11 +56,11 @@ def delete_privileges(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_security/privilege/#{Utils.__listify(_application)}/#{Utils.__listify(_name)}" + path = "_security/privilege/#{Utils.listify(_application)}/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_role.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_role.rb index d4902cf9e9..b1d73aa58c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_role.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_role.rb @@ -15,22 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Removes roles in the native realm. + # Delete roles. + # Delete roles in the native realm. + # The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. + # The delete roles API cannot remove roles that are defined in roles files. # - # @option arguments [String] :name Role name - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :name The name of the role. (*Required*) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-delete-role # def delete_role(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.delete_role' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -41,11 +51,11 @@ def delete_role(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_security/role/#{Utils.__listify(_name)}" + path = "_security/role/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_role_mapping.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_role_mapping.rb index 2cc199f560..b8a11535d0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_role_mapping.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_role_mapping.rb @@ -15,22 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Removes role mappings. + # Delete role mappings. + # Role mappings define which roles are assigned to each user. + # The role mapping APIs are generally the preferred way to manage role mappings rather than using role mapping files. + # The delete role mappings API cannot remove role mappings that are defined in role mapping files. # - # @option arguments [String] :name Role-mapping name - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :name The distinct name that identifies the role mapping. + # The name is used solely as an identifier to facilitate interaction via the API; it does not affect the behavior of the mapping in any way. (*Required*) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-delete-role-mapping # def delete_role_mapping(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.delete_role_mapping' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] arguments = arguments.clone @@ -41,11 +52,11 @@ def delete_role_mapping(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_security/role_mapping/#{Utils.__listify(_name)}" + path = "_security/role_mapping/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_service_token.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_service_token.rb index eb89dfc7d9..67b74f02ad 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_service_token.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_service_token.rb @@ -15,24 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Deletes a service account token. + # Delete service account tokens. + # Delete service account tokens for a service in a specified namespace. # - # @option arguments [String] :namespace An identifier for the namespace - # @option arguments [String] :service An identifier for the service name - # @option arguments [String] :name An identifier for the token name - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :namespace The namespace, which is a top-level grouping of service accounts. (*Required*) + # @option arguments [String] :service The service name. (*Required*) + # @option arguments [String] :name The name of the service account token. (*Required*) + # @option arguments [String] :refresh If +true+ then refresh the affected shards to make this operation visible to search, if +wait_for+ (the default) then wait for a refresh to make this operation visible to search, if +false+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-service-token.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-delete-service-token # def delete_service_token(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.delete_service_token' } + + defined_params = [:namespace, :service, :name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'namespace' missing" unless arguments[:namespace] raise ArgumentError, "Required argument 'service' missing" unless arguments[:service] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -49,11 +57,11 @@ def delete_service_token(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_DELETE - path = "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential/token/#{Utils.__listify(_name)}" + path = "_security/service/#{Utils.listify(_namespace)}/#{Utils.listify(_service)}/credential/token/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_user.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_user.rb index 1729c6ffd1..614c4c6501 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_user.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/delete_user.rb @@ -15,22 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Deletes users from the native realm. + # Delete users. + # Delete users from the native realm. # - # @option arguments [String] :username username - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :username An identifier for the user. (*Required*) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-delete-user # def delete_user(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.delete_user' } + + defined_params = [:username].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'username' missing" unless arguments[:username] arguments = arguments.clone @@ -41,11 +49,11 @@ def delete_user(arguments = {}) _username = arguments.delete(:username) method = Elasticsearch::API::HTTP_DELETE - path = "_security/user/#{Utils.__listify(_username)}" + path = "_security/user/#{Utils.listify(_username)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user.rb index 1d756e2048..1111e9af70 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user.rb @@ -15,22 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Disables users in the native realm. + # Disable users. + # Disable users in the native realm. + # By default, when you create users, they are enabled. + # You can use this API to revoke a user's access to Elasticsearch. # - # @option arguments [String] :username The username of the user to disable - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :username An identifier for the user. (*Required*) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-disable-user # def disable_user(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.disable_user' } + + defined_params = [:username].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'username' missing" unless arguments[:username] arguments = arguments.clone @@ -41,11 +51,11 @@ def disable_user(arguments = {}) _username = arguments.delete(:username) method = Elasticsearch::API::HTTP_PUT - path = "_security/user/#{Utils.__listify(_username)}/_disable" + path = "_security/user/#{Utils.listify(_username)}/_disable" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user_profile.rb index b5228f47dc..15990f220d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user_profile.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user_profile.rb @@ -15,37 +15,52 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Disables a user profile so it's not visible in user profile searches. + # Disable a user profile. + # Disable user profiles so that they are not visible in user profile searches. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # When you activate a user profile, its automatically enabled and visible in user profile searches. You can use the disable user profile API to disable a user profile so it’s not visible in these searches. + # To re-enable a disabled user profile, use the enable user profile API . # - # @option arguments [String] :uid Unique identifier for the user profile - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :uid Unique identifier for the user profile. (*Required*) + # @option arguments [String] :refresh If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search. + # If 'wait_for', it waits for a refresh to make this operation visible to search. + # If 'false', it does nothing with refreshes. Server default: false. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user-profile.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-disable-user-profile # def disable_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.disable_user_profile' } + + defined_params = [:uid].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'uid' missing" unless arguments[:uid] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _uid = arguments.delete(:uid) method = Elasticsearch::API::HTTP_PUT - path = "_security/profile/#{Utils.__listify(_uid)}/_disable" + path = "_security/profile/#{Utils.listify(_uid)}/_disable" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user.rb index 926b295fa0..cf5fefa7da 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Enables users in the native realm. + # Enable users. + # Enable users in the native realm. + # By default, when you create users, they are enabled. # - # @option arguments [String] :username The username of the user to enable - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :username An identifier for the user. (*Required*) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-enable-user # def enable_user(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.enable_user' } + + defined_params = [:username].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'username' missing" unless arguments[:username] arguments = arguments.clone @@ -41,11 +50,11 @@ def enable_user(arguments = {}) _username = arguments.delete(:username) method = Elasticsearch::API::HTTP_PUT - path = "_security/user/#{Utils.__listify(_username)}/_enable" + path = "_security/user/#{Utils.listify(_username)}/_enable" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user_profile.rb index 42c61217d9..7ba93281ea 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user_profile.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user_profile.rb @@ -15,37 +15,53 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Enables a user profile so it's visible in user profile searches. + # Enable a user profile. + # Enable user profiles to make them visible in user profile searches. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # When you activate a user profile, it's automatically enabled and visible in user profile searches. + # If you later disable the user profile, you can use the enable user profile API to make the profile visible in these searches again. # - # @option arguments [String] :uid An unique identifier of the user profile - # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` (the default) then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :uid A unique identifier for the user profile. (*Required*) + # @option arguments [String] :refresh If 'true', Elasticsearch refreshes the affected shards to make this operation + # visible to search. + # If 'wait_for', it waits for a refresh to make this operation visible to search. + # If 'false', nothing is done with refreshes. Server default: false. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user-profile.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-enable-user-profile # def enable_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.enable_user_profile' } + + defined_params = [:uid].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'uid' missing" unless arguments[:uid] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _uid = arguments.delete(:uid) method = Elasticsearch::API::HTTP_PUT - path = "_security/profile/#{Utils.__listify(_uid)}/_enable" + path = "_security/profile/#{Utils.listify(_uid)}/_enable" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/enroll_kibana.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/enroll_kibana.rb index 1ac392de4e..a85a0bb38c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/enroll_kibana.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/enroll_kibana.rb @@ -15,31 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Allows a kibana instance to configure itself to communicate with a secured elasticsearch cluster. + # Enroll Kibana. + # Enable a Kibana instance to configure itself for communication with a secured Elasticsearch cluster. + # NOTE: This API is currently intended for internal use only by Kibana. + # Kibana uses this API internally to configure itself for communications with an Elasticsearch cluster that already has security features enabled. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-kibana-enrollment.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-enroll-kibana # def enroll_kibana(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.enroll_kibana' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_security/enroll/kibana" + path = '_security/enroll/kibana' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/enroll_node.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/enroll_node.rb index 9c33882787..d29ac10913 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/enroll_node.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/enroll_node.rb @@ -15,31 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Allows a new node to enroll to an existing cluster with security enabled. + # Enroll a node. + # Enroll a new node to allow it to join an existing cluster with security features enabled. + # The response contains all the necessary information for the joining node to bootstrap discovery and security related settings so that it can successfully join the cluster. + # The response contains key and certificate material that allows the caller to generate valid signed certificates for the HTTP layer of all nodes in the cluster. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-node-enrollment.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-enroll-node # def enroll_node(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.enroll_node' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_security/enroll/node" + path = '_security/enroll/node' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_api_key.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_api_key.rb index 7ffb39ba07..259c0643a8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_api_key.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_api_key.rb @@ -15,37 +15,53 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions + # Get API key information. # Retrieves information for one or more API keys. + # NOTE: If you have only the +manage_own_api_key+ privilege, this API returns only the API keys that you own. + # If you have +read_security+, +manage_api_key+ or greater privileges (including +manage_security+), this API returns all API keys regardless of ownership. # - # @option arguments [String] :id API key id of the API key to be retrieved - # @option arguments [String] :name API key name of the API key to be retrieved - # @option arguments [String] :username user name of the user who created this API key to be retrieved - # @option arguments [String] :realm_name realm name of the user who created this API key to be retrieved - # @option arguments [Boolean] :owner flag to query API keys owned by the currently authenticated user - # @option arguments [Boolean] :with_limited_by flag to show the limited-by role descriptors of API Keys + # @option arguments [String] :id An API key id. + # This parameter cannot be used with any of +name+, +realm_name+ or +username+. + # @option arguments [String] :name An API key name. + # This parameter cannot be used with any of +id+, +realm_name+ or +username+. + # It supports prefix search with wildcard. + # @option arguments [Boolean] :owner A boolean flag that can be used to query API keys owned by the currently authenticated user. + # The +realm_name+ or +username+ parameters cannot be specified when this parameter is set to +true+ as they are assumed to be the currently authenticated ones. + # @option arguments [String] :realm_name The name of an authentication realm. + # This parameter cannot be used with either +id+ or +name+ or when +owner+ flag is set to +true+. + # @option arguments [String] :username The username of a user. + # This parameter cannot be used with either +id+ or +name+ or when +owner+ flag is set to +true+. + # @option arguments [Boolean] :with_limited_by Return the snapshot of the owner user's role descriptors + # associated with the API key. An API key's actual + # permission is the intersection of its assigned role + # descriptors and the owner user's role descriptors. + # @option arguments [Boolean] :active_only A boolean flag that can be used to query API keys that are currently active. An API key is considered active if it is neither invalidated, nor expired at query time. You can specify this together with other parameters such as +owner+ or +name+. If +active_only+ is false, the response will include both active and inactive (expired or invalidated) keys. + # @option arguments [Boolean] :with_profile_uid Determines whether to also retrieve the profile uid, for the API key owner principal, if it exists. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-api-key # def get_api_key(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_api_key' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_security/api_key" + path = '_security/api_key' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_builtin_privileges.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_builtin_privileges.rb index b4983e21f5..68fdc06bcb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_builtin_privileges.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_builtin_privileges.rb @@ -15,31 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch. + # Get builtin privileges. + # Get the list of cluster privileges and index privileges that are available in this version of Elasticsearch. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-builtin-privileges.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-builtin-privileges # def get_builtin_privileges(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_builtin_privileges' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_security/privilege/_builtin" + path = '_security/privilege/_builtin' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_privileges.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_privileges.rb index 9b09f3c75b..e592c8bf51 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_privileges.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_privileges.rb @@ -15,22 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves application privileges. + # Get application privileges. + # To use this API, you must have one of the following privileges: + # * The +read_security+ cluster privilege (or a greater privilege such as +manage_security+ or +all+). + # * The "Manage Application Privileges" global privilege for the application being referenced in the request. # - # @option arguments [String] :application Application name - # @option arguments [String] :name Privilege name + # @option arguments [String] :application The name of the application. + # Application privileges are always associated with exactly one application. + # If you do not specify this parameter, the API returns information about all privileges for all applications. + # @option arguments [String, Array] :name The name of the privilege. + # If you do not specify this parameter, the API returns information about all privileges for the requested application. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-privileges # def get_privileges(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_privileges' } + + defined_params = [:application, :name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -42,16 +55,16 @@ def get_privileges(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _application && _name - "_security/privilege/#{Utils.__listify(_application)}/#{Utils.__listify(_name)}" + "_security/privilege/#{Utils.listify(_application)}/#{Utils.listify(_name)}" elsif _application - "_security/privilege/#{Utils.__listify(_application)}" + "_security/privilege/#{Utils.listify(_application)}" else - "_security/privilege" + '_security/privilege' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_role.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_role.rb index 2d4c5e4992..47daddc981 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_role.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_role.rb @@ -15,21 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves roles in the native realm. + # Get roles. + # Get roles in the native realm. + # The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. + # The get roles API cannot retrieve roles that are defined in roles files. # - # @option arguments [List] :name A comma-separated list of role names + # @option arguments [String, Array] :name The name of the role. + # You can specify multiple roles as a comma-separated list. + # If you do not specify this parameter, the API returns information about all roles. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-role # def get_role(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_role' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -39,21 +51,21 @@ def get_role(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_security/role/#{Utils.__listify(_name)}" + "_security/role/#{Utils.listify(_name)}" else - "_security/role" + '_security/role' end params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_role_mapping.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_role_mapping.rb index 8c4571c8bd..ecc7d53032 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_role_mapping.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_role_mapping.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves role mappings. + # Get role mappings. + # Role mappings define which roles are assigned to each user. + # The role mapping APIs are generally the preferred way to manage role mappings rather than using role mapping files. + # The get role mappings API cannot retrieve role mappings that are defined in role mapping files. # - # @option arguments [List] :name A comma-separated list of role-mapping names + # @option arguments [String, Array] :name The distinct name that identifies the role mapping. The name is used solely as an identifier to facilitate interaction via the API; it does not affect the behavior of the mapping in any way. You can specify multiple mapping names as a comma-separated list. If you do not specify this parameter, the API returns information about all role mappings. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-role-mapping # def get_role_mapping(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_role_mapping' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -39,14 +49,14 @@ def get_role_mapping(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _name - "_security/role_mapping/#{Utils.__listify(_name)}" + "_security/role_mapping/#{Utils.listify(_name)}" else - "_security/role_mapping" + '_security/role_mapping' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_service_accounts.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_service_accounts.rb index d48a0b13e9..869557efd2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_service_accounts.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_service_accounts.rb @@ -15,22 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves information about service accounts. + # Get service accounts. + # Get a list of service accounts that match the provided path parameters. + # NOTE: Currently, only the +elastic/fleet-server+ service account is available. # - # @option arguments [String] :namespace An identifier for the namespace - # @option arguments [String] :service An identifier for the service name + # @option arguments [String] :namespace The name of the namespace. + # Omit this parameter to retrieve information about all service accounts. + # If you omit this parameter, you must also omit the +service+ parameter. + # @option arguments [String] :service The service name. + # Omit this parameter to retrieve information about all service accounts that belong to the specified +namespace+. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-service-accounts.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-service-accounts # def get_service_accounts(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_service_accounts' } + + defined_params = [:namespace, :service].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -42,16 +54,16 @@ def get_service_accounts(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _namespace && _service - "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}" + "_security/service/#{Utils.listify(_namespace)}/#{Utils.listify(_service)}" elsif _namespace - "_security/service/#{Utils.__listify(_namespace)}" + "_security/service/#{Utils.listify(_namespace)}" else - "_security/service" + '_security/service' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_service_credentials.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_service_credentials.rb index 4b28035cb9..b3e62afdb7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_service_credentials.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_service_credentials.rb @@ -15,22 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves information of all service credentials for a service account. + # Get service account credentials. + # To use this API, you must have at least the +read_security+ cluster privilege (or a greater privilege such as +manage_service_account+ or +manage_security+). + # The response includes service account tokens that were created with the create service account tokens API as well as file-backed tokens from all nodes of the cluster. + # NOTE: For tokens backed by the +service_tokens+ file, the API collects them from all nodes of the cluster. + # Tokens with the same name from different nodes are assumed to be the same token and are only counted once towards the total number of service tokens. # - # @option arguments [String] :namespace An identifier for the namespace - # @option arguments [String] :service An identifier for the service name + # @option arguments [String] :namespace The name of the namespace. (*Required*) + # @option arguments [String] :service The service name. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-service-credentials.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-service-credentials # def get_service_credentials(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_service_credentials' } + + defined_params = [:namespace, :service].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'namespace' missing" unless arguments[:namespace] raise ArgumentError, "Required argument 'service' missing" unless arguments[:service] @@ -44,11 +55,11 @@ def get_service_credentials(arguments = {}) _service = arguments.delete(:service) method = Elasticsearch::API::HTTP_GET - path = "_security/service/#{Utils.__listify(_namespace)}/#{Utils.__listify(_service)}/credential" + path = "_security/service/#{Utils.listify(_namespace)}/#{Utils.listify(_service)}/credential" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_settings.rb new file mode 100644 index 0000000000..3f880b7671 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_settings.rb @@ -0,0 +1,57 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Security + module Actions + # Get security index settings. + # Get the user-configurable settings for the security internal index (+.security+ and associated indices). + # Only a subset of the index settings — those that are user-configurable—will be shown. + # This includes: + # * +index.auto_expand_replicas+ + # * +index.number_of_replicas+ + # + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-settings + # + def get_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_settings' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_security/settings' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_token.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_token.rb index f96a03978a..18ec4c54fd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_token.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_token.rb @@ -15,34 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates a bearer token for access without requiring basic authentication. + # Get a token. + # Create a bearer token for access without requiring basic authentication. + # The tokens are created by the Elasticsearch Token Service, which is automatically enabled when you configure TLS on the HTTP interface. + # Alternatively, you can explicitly enable the +xpack.security.authc.token.enabled+ setting. + # When you are running in production mode, a bootstrap check prevents you from enabling the token service unless you also enable TLS on the HTTP interface. + # The get token API takes the same parameters as a typical OAuth 2.0 token API except for the use of a JSON request body. + # A successful get token API call returns a JSON structure that contains the access token, the amount of time (seconds) that the token expires in, the type, and the scope if available. + # The tokens returned by the get token API have a finite period of time for which they are valid and after that time period, they can no longer be used. + # That time period is defined by the +xpack.security.authc.token.timeout+ setting. + # If you want to invalidate a token immediately, you can do so by using the invalidate token API. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The token request to get (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-token # def get_token(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_token' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/oauth2/token" + path = '_security/oauth2/token' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user.rb index 68254b014c..718ef8b6a2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user.rb @@ -15,22 +15,30 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves information about users in the native realm and built-in users. + # Get users. + # Get information about users in the native realm and built-in users. # - # @option arguments [List] :username A comma-separated list of usernames - # @option arguments [Boolean] :with_profile_uid flag to retrieve profile uid (if exists) associated to the user + # @option arguments [Username] :username An identifier for the user. You can specify multiple usernames as a comma-separated list. If you omit this parameter, the API retrieves information about all users. + # @option arguments [Boolean] :with_profile_uid Determines whether to retrieve the user profile UID, if it exists, for the users. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-user # def get_user(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_user' } + + defined_params = [:username].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -40,21 +48,21 @@ def get_user(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _username - "_security/user/#{Utils.__listify(_username)}" + "_security/user/#{Utils.listify(_username)}" else - "_security/user" + '_security/user' end params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_privileges.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_privileges.rb index 826e3cdf3a..bf8a58eb27 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_privileges.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_privileges.rb @@ -15,31 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves security privileges for the logged in user. + # Get user privileges. + # Get the security privileges for the logged in user. + # All users can use this API, but only to determine their own privileges. + # To check the privileges of other users, you must use the run as feature. + # To check whether a user has a specific list of privileges, use the has privileges API. # + # @option arguments [String] :application The name of the application. Application privileges are always associated with exactly one application. If you do not specify this parameter, the API returns information about all privileges for all applications. + # @option arguments [String] :priviledge The name of the privilege. If you do not specify this parameter, the API returns information about all privileges for the requested application. + # @option arguments [Name, Null] :username [TODO] # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-user-privileges # def get_user_privileges(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_user_privileges' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_security/user/_privileges" - params = {} + path = '_security/user/_privileges' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_profile.rb index 836794286f..5ff39cbae5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_profile.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_profile.rb @@ -15,37 +15,51 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves user profiles for the given unique ID(s). + # Get a user profile. + # Get a user's profile using the unique profile ID. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. # - # @option arguments [List] :uid A comma-separated list of unique identifier for user profiles - # @option arguments [List] :data A comma-separated list of keys for which the corresponding application data are retrieved. + # @option arguments [Userprofileid] :uid A unique identifier for the user profile. (*Required*) + # @option arguments [String] :data A comma-separated list of filters for the +data+ field of the profile document. + # To return all content use +data=*+. + # To return a subset of content use +data=+ to retrieve content nested under the specified ++. + # By default returns no +data+ content. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-profile.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-user-profile # def get_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_user_profile' } + + defined_params = [:uid].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'uid' missing" unless arguments[:uid] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil _uid = arguments.delete(:uid) method = Elasticsearch::API::HTTP_GET - path = "_security/profile/#{Utils.__listify(_uid)}" + path = "_security/profile/#{Utils.listify(_uid)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/grant_api_key.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/grant_api_key.rb index bf1803e561..929cb91918 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/grant_api_key.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/grant_api_key.rb @@ -15,35 +15,51 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates an API key on behalf of another user. + # Grant an API key. + # Create an API key on behalf of another user. + # This API is similar to the create API keys API, however it creates the API key for a user that is different than the user that runs the API. + # The caller must have authentication credentials for the user on whose behalf the API key will be created. + # It is not possible to use this API to create an API key without that user's credentials. + # The supported user authentication credential types are: + # * username and password + # * Elasticsearch access tokens + # * JWTs + # The user, for whom the authentication credentials is provided, can optionally "run as" (impersonate) another user. + # In this case, the API key will be created on behalf of the impersonated user. + # This API is intended be used by applications that need to create and manage API keys for end users, but cannot guarantee that those users have permission to create API keys on their own behalf. + # The API keys are created by the Elasticsearch API key service, which is automatically enabled. + # A successful grant API key API call returns a JSON structure that contains the API key, its unique id, and its name. + # If applicable, it also returns expiration information for the API key in milliseconds. + # By default, API keys never expire. You can specify expiration information when you create the API keys. # - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The api key request to create an API key (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-grant-api-key.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-grant-api-key # def grant_api_key(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.grant_api_key' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/api_key/grant" - params = Utils.process_params(arguments) + path = '_security/api_key/grant' + params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges.rb index f607ce5d2a..2e5ed520f8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges.rb @@ -15,22 +15,32 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Determines whether the specified user has a specified list of privileges. + # Check user privileges. + # Determine whether the specified user has a specified list of privileges. + # All users can use this API, but only to determine their own privileges. + # To check the privileges of other users, you must use the run as feature. # # @option arguments [String] :user Username # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The privileges to test (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-has-privileges # def has_privileges(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.has_privileges' } + + defined_params = [:user].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone @@ -42,14 +52,14 @@ def has_privileges(arguments = {}) method = Elasticsearch::API::HTTP_POST path = if _user - "_security/user/#{Utils.__listify(_user)}/_has_privileges" + "_security/user/#{Utils.listify(_user)}/_has_privileges" else - "_security/user/_has_privileges" + '_security/user/_has_privileges' end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges_user_profile.rb index e292fad425..4c9e5c5fec 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges_user_profile.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges_user_profile.rb @@ -15,34 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Determines whether the users associated with the specified profile IDs have all the requested privileges. + # Check user profile privileges. + # Determine whether the users associated with the specified user profile IDs have all the requested privileges. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The privileges to check and the list of profile IDs (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges-user-profile.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-has-privileges-user-profile # def has_privileges_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.has_privileges_user_profile' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/profile/_has_privileges" + path = '_security/profile/_has_privileges' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/invalidate_api_key.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/invalidate_api_key.rb index 4c6af6d104..951f2ca7a0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/invalidate_api_key.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/invalidate_api_key.rb @@ -15,34 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Invalidates one or more API keys. + # Invalidate API keys. + # This API invalidates API keys created by the create API key or grant API key APIs. + # Invalidated API keys fail authentication, but they can still be viewed using the get API key information and query API key information APIs, for at least the configured retention period, until they are automatically deleted. + # To use this API, you must have at least the +manage_security+, +manage_api_key+, or +manage_own_api_key+ cluster privileges. + # The +manage_security+ privilege allows deleting any API key, including both REST and cross cluster API keys. + # The +manage_api_key+ privilege allows deleting any REST API key, but not cross cluster API keys. + # The +manage_own_api_key+ only allows deleting REST API keys that are owned by the user. + # In addition, with the +manage_own_api_key+ privilege, an invalidation request must be issued in one of the three formats: + # - Set the parameter +owner=true+. + # - Or, set both +username+ and +realm_name+ to match the user's identity. + # - Or, if the request is issued by an API key, that is to say an API key invalidates itself, specify its ID in the +ids+ field. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The api key request to invalidate API key(s) (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-invalidate-api-key # def invalidate_api_key(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.invalidate_api_key' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_DELETE - path = "_security/api_key" + path = '_security/api_key' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/invalidate_token.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/invalidate_token.rb index 00c7321015..a10a433d20 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/invalidate_token.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/invalidate_token.rb @@ -15,34 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Invalidates one or more access tokens or refresh tokens. + # Invalidate a token. + # The access tokens returned by the get token API have a finite period of time for which they are valid. + # After that time period, they can no longer be used. + # The time period is defined by the +xpack.security.authc.token.timeout+ setting. + # The refresh tokens returned by the get token API are only valid for 24 hours. + # They can also be used exactly once. + # If you want to invalidate one or more access or refresh tokens immediately, use this invalidate token API. + # NOTE: While all parameters are optional, at least one of them is required. + # More specifically, either one of +token+ or +refresh_token+ parameters is required. + # If none of these two are specified, then +realm_name+ and/or +username+ need to be specified. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The token to invalidate (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-invalidate-token # def invalidate_token(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.invalidate_token' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_DELETE - path = "_security/oauth2/token" + path = '_security/oauth2/token' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_authenticate.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_authenticate.rb index e2e0d93456..b117faf7e8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_authenticate.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_authenticate.rb @@ -15,34 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Exchanges an OpenID Connection authentication response message for an Elasticsearch access token and refresh token pair + # Authenticate OpenID Connect. + # Exchange an OpenID Connect authentication response message for an Elasticsearch internal access token and refresh token that can be subsequently used for authentication. + # Elasticsearch exposes all the necessary OpenID Connect related functionality with the OpenID Connect APIs. + # These APIs are used internally by Kibana in order to provide OpenID Connect based authentication, but can also be used by other, custom web applications or other clients. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The OpenID Connect response to authenticate (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-authenticate.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-oidc-authenticate # def oidc_authenticate(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.oidc_authenticate' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/oidc/authenticate" + path = '_security/oidc/authenticate' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_logout.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_logout.rb index 93985d9fde..e0faf9bbfb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_logout.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_logout.rb @@ -15,34 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Invalidates a refresh token and access token that was generated from the OpenID Connect Authenticate API + # Logout of OpenID Connect. + # Invalidate an access token and a refresh token that were generated as a response to the +/_security/oidc/authenticate+ API. + # If the OpenID Connect authentication realm in Elasticsearch is accordingly configured, the response to this call will contain a URI pointing to the end session endpoint of the OpenID Connect Provider in order to perform single logout. + # Elasticsearch exposes all the necessary OpenID Connect related functionality with the OpenID Connect APIs. + # These APIs are used internally by Kibana in order to provide OpenID Connect based authentication, but can also be used by other, custom web applications or other clients. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Access token and refresh token to invalidate (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-logout.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-oidc-logout # def oidc_logout(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.oidc_logout' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/oidc/logout" + path = '_security/oidc/logout' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_prepare_authentication.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_prepare_authentication.rb index b79da8ad73..8accec4a05 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_prepare_authentication.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/oidc_prepare_authentication.rb @@ -15,34 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates an OAuth 2.0 authentication request as a URL string + # Prepare OpenID connect authentication. + # Create an oAuth 2.0 authentication request as a URL string based on the configuration of the OpenID Connect authentication realm in Elasticsearch. + # The response of this API is a URL pointing to the Authorization Endpoint of the configured OpenID Connect Provider, which can be used to redirect the browser of the user in order to continue the authentication process. + # Elasticsearch exposes all the necessary OpenID Connect related functionality with the OpenID Connect APIs. + # These APIs are used internally by Kibana in order to provide OpenID Connect based authentication, but can also be used by other, custom web applications or other clients. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The OpenID Connect authentication realm configuration (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-oidc-prepare-authentication.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-oidc-prepare-authentication # def oidc_prepare_authentication(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.oidc_prepare_authentication' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/oidc/prepare" + path = '_security/oidc/prepare' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/put_privileges.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/put_privileges.rb index d2cfd8dd15..fc6c9765ab 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/put_privileges.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/put_privileges.rb @@ -15,35 +15,49 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Adds or updates application privileges. + # Create or update application privileges. + # To use this API, you must have one of the following privileges: + # * The +manage_security+ cluster privilege (or a greater privilege such as +all+). + # * The "Manage Application Privileges" global privilege for the application being referenced in the request. + # Application names are formed from a prefix, with an optional suffix that conform to the following rules: + # * The prefix must begin with a lowercase ASCII letter. + # * The prefix must contain only ASCII letters or digits. + # * The prefix must be at least 3 characters long. + # * If the suffix exists, it must begin with either a dash +-+ or +_+. + # * The suffix cannot contain any of the following characters: +\+, +/+, +*+, +?+, +"+, +<+, +>+, +|+, +,+, +*+. + # * No part of the name can contain whitespace. + # Privilege names must begin with a lowercase ASCII letter and must contain only ASCII letters and digits along with the characters +_+, +-+, and +.+. + # Action names can contain any number of printable ASCII characters and must contain at least one of the following characters: +/+, +*+, +:+. # - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The privilege(s) to add (*Required*) + # @option arguments [Hash] :body privileges # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-privileges.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-put-privileges # def put_privileges(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.put_privileges' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_PUT - path = "_security/privilege" + path = '_security/privilege' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/put_role.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/put_role.rb index b8e7ca155c..70bddd7c69 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/put_role.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/put_role.rb @@ -15,23 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Adds and updates roles in the native realm. + # Create or update roles. + # The role management APIs are generally the preferred way to manage roles in the native realm, rather than using file-based role management. + # The create or update roles API cannot update roles that are defined in roles files. + # File-based role management is not available in Elastic Serverless. # - # @option arguments [String] :name Role name - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :name The name of the role that is being created or updated. On Elasticsearch Serverless, the role name must begin with a letter or digit and can only contain letters, digits and the characters '_', '-', and '.'. Each role must have a unique name, as this will serve as the identifier for that role. (*Required*) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The role to add (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-put-role # def put_role(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.put_role' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -43,11 +53,11 @@ def put_role(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_security/role/#{Utils.__listify(_name)}" + path = "_security/role/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/put_role_mapping.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/put_role_mapping.rb index 7de6143ab4..7e6c1f3bf3 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/put_role_mapping.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/put_role_mapping.rb @@ -15,23 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates and updates role mappings. + # Create or update role mappings. + # Role mappings define which roles are assigned to each user. + # Each mapping has rules that identify users and a list of roles that are granted to those users. + # The role mapping APIs are generally the preferred way to manage role mappings rather than using role mapping files. The create or update role mappings API cannot update role mappings that are defined in role mapping files. + # NOTE: This API does not create roles. Rather, it maps users to existing roles. + # Roles can be created by using the create or update roles API or roles files. + # **Role templates** + # The most common use for role mappings is to create a mapping from a known value on the user to a fixed role name. + # For example, all users in the +cn=admin,dc=example,dc=com+ LDAP group should be given the superuser role in Elasticsearch. + # The +roles+ field is used for this purpose. + # For more complex needs, it is possible to use Mustache templates to dynamically determine the names of the roles that should be granted to the user. + # The +role_templates+ field is used for this purpose. + # NOTE: To use role templates successfully, the relevant scripting feature must be enabled. + # Otherwise, all attempts to create a role mapping with role templates fail. + # All of the user fields that are available in the role mapping rules are also available in the role templates. + # Thus it is possible to assign a user to a role that reflects their username, their groups, or the name of the realm to which they authenticated. + # By default a template is evaluated to produce a single string that is the name of the role which should be assigned to the user. + # If the format of the template is set to "json" then the template is expected to produce a JSON string or an array of JSON strings for the role names. # - # @option arguments [String] :name Role-mapping name - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :name The distinct name that identifies the role mapping. + # The name is used solely as an identifier to facilitate interaction via the API; it does not affect the behavior of the mapping in any way. (*Required*) + # @option arguments [String] :refresh If +true+ (the default) 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+ then do nothing with refreshes. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The role mapping to add (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-put-role-mapping # def put_role_mapping(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.put_role_mapping' } + + defined_params = [:name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'name' missing" unless arguments[:name] @@ -43,11 +68,11 @@ def put_role_mapping(arguments = {}) _name = arguments.delete(:name) method = Elasticsearch::API::HTTP_PUT - path = "_security/role_mapping/#{Utils.__listify(_name)}" + path = "_security/role_mapping/#{Utils.listify(_name)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/put_user.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/put_user.rb index 966d8131ef..a525745c97 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/put_user.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/put_user.rb @@ -15,23 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Adds and updates users in the native realm. These users are commonly referred to as native users. + # Create or update users. + # Add and update users in the native realm. + # A password is required for adding a new user but is optional when updating an existing user. + # To change a user's password without updating any other fields, use the change password API. # - # @option arguments [String] :username The username of the User - # @option arguments [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :username An identifier for the user.NOTE: Usernames must be at least 1 and no more than 507 characters. + # They can contain alphanumeric characters (a-z, A-Z, 0-9), spaces, punctuation, and printable symbols in the Basic Latin (ASCII) block. + # Leading or trailing whitespace is not allowed. (*Required*) + # @option arguments [String] :refresh Valid values are +true+, +false+, and +wait_for+. + # These values have the same meaning as in the index API, but the default value for this API is true. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The user to add (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-put-user # def put_user(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.put_user' } + + defined_params = [:username].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'username' missing" unless arguments[:username] @@ -43,11 +56,11 @@ def put_user(arguments = {}) _username = arguments.delete(:username) method = Elasticsearch::API::HTTP_PUT - path = "_security/user/#{Utils.__listify(_username)}" + path = "_security/user/#{Utils.listify(_username)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/query_api_keys.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/query_api_keys.rb index d60d86253b..19812f21cd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/query_api_keys.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/query_api_keys.rb @@ -15,26 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Retrieves information for API keys using a subset of query DSL + # Find API keys with a query. + # Get a paginated list of API keys and their information. + # You can optionally filter the results with a query. + # To use this API, you must have at least the +manage_own_api_key+ or the +read_security+ cluster privileges. + # If you have only the +manage_own_api_key+ privilege, this API returns only the API keys that you own. + # If you have the +read_security+, +manage_api_key+, or greater privileges (including +manage_security+), this API returns all API keys regardless of ownership. # - # @option arguments [Boolean] :with_limited_by flag to show the limited-by role descriptors of API Keys + # @option arguments [Boolean] :with_limited_by Return the snapshot of the owner user's role descriptors associated with the API key. + # An API key's actual permission is the intersection of its assigned role descriptors and the owner user's role descriptors (effectively limited by it). + # An API key cannot retrieve any API key’s limited-by role descriptors (including itself) unless it has +manage_api_key+ or higher privileges. + # @option arguments [Boolean] :with_profile_uid Determines whether to also retrieve the profile UID for the API key owner principal. + # If it exists, the profile UID is returned under the +profile_uid+ response field for each API key. + # @option arguments [Boolean] :typed_keys Determines whether aggregation names are prefixed by their respective types in the response. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body From, size, query, sort and search_after + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-api-key.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-query-api-keys # def query_api_keys(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.query_api_keys' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = if body Elasticsearch::API::HTTP_POST @@ -42,11 +54,11 @@ def query_api_keys(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_security/_query/api_key" + path = '_security/_query/api_key' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/query_role.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/query_role.rb new file mode 100644 index 0000000000..357240df7e --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/query_role.rb @@ -0,0 +1,61 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Security + module Actions + # Find roles with a query. + # Get roles in a paginated manner. + # The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. + # The query roles API does not retrieve roles that are defined in roles files, nor built-in ones. + # You can optionally filter the results with a query. + # Also, the results can be paginated and sorted. + # + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-query-role + # + def query_role(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.query_role' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = if body + Elasticsearch::API::HTTP_POST + else + Elasticsearch::API::HTTP_GET + end + + path = '_security/_query/role' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/query_user.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/query_user.rb new file mode 100644 index 0000000000..5f0e917d24 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/query_user.rb @@ -0,0 +1,61 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Security + module Actions + # Find users with a query. + # Get information for users in a paginated manner. + # You can optionally filter the results with a query. + # NOTE: As opposed to the get user API, built-in users are excluded from the result. + # This API is only for native users. + # + # @option arguments [Boolean] :with_profile_uid Determines whether to retrieve the user profile UID, if it exists, for the users. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-query-user + # + def query_user(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.query_user' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = if body + Elasticsearch::API::HTTP_POST + else + Elasticsearch::API::HTTP_GET + end + + path = '_security/_query/user' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_authenticate.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_authenticate.rb index d743628c83..4bdbef1763 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_authenticate.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_authenticate.rb @@ -15,34 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Exchanges a SAML Response message for an Elasticsearch access token and refresh token pair + # Authenticate SAML. + # Submit a SAML response message to Elasticsearch for consumption. + # NOTE: This API is intended for use by custom web applications other than Kibana. + # If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack. + # The SAML message that is submitted can be: + # * A response to a SAML authentication request that was previously created using the SAML prepare authentication API. + # * An unsolicited SAML message in the case of an IdP-initiated single sign-on (SSO) flow. + # In either case, the SAML message needs to be a base64 encoded XML document with a root element of ++. + # After successful validation, Elasticsearch responds with an Elasticsearch internal access token and refresh token that can be subsequently used for authentication. + # This API endpoint essentially exchanges SAML responses that indicate successful authentication in the IdP for Elasticsearch access and refresh tokens, which can be used for authentication against Elasticsearch. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The SAML response to authenticate (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-authenticate.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-saml-authenticate # def saml_authenticate(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.saml_authenticate' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/saml/authenticate" + path = '_security/saml/authenticate' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_complete_logout.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_complete_logout.rb index f78b2278e7..a048172eeb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_complete_logout.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_complete_logout.rb @@ -15,34 +15,44 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Verifies the logout response sent from the SAML IdP + # Logout of SAML completely. + # Verifies the logout response sent from the SAML IdP. + # NOTE: This API is intended for use by custom web applications other than Kibana. + # If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack. + # The SAML IdP may send a logout response back to the SP after handling the SP-initiated SAML Single Logout. + # This API verifies the response by ensuring the content is relevant and validating its signature. + # An empty response is returned if the verification process is successful. + # The response can be sent by the IdP with either the HTTP-Redirect or the HTTP-Post binding. + # The caller of this API must prepare the request accordingly so that this API can handle either of them. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The logout response to verify (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-complete-logout.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-saml-complete-logout # def saml_complete_logout(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.saml_complete_logout' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/saml/complete_logout" + path = '_security/saml/complete_logout' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_invalidate.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_invalidate.rb index 264dfad171..5a80c1adcd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_invalidate.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_invalidate.rb @@ -15,34 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Consumes a SAML LogoutRequest + # Invalidate SAML. + # Submit a SAML LogoutRequest message to Elasticsearch for consumption. + # NOTE: This API is intended for use by custom web applications other than Kibana. + # If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack. + # The logout request comes from the SAML IdP during an IdP initiated Single Logout. + # The custom web application can use this API to have Elasticsearch process the +LogoutRequest+. + # After successful validation of the request, Elasticsearch invalidates the access token and refresh token that corresponds to that specific SAML principal and provides a URL that contains a SAML LogoutResponse message. + # Thus the user can be redirected back to their IdP. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The LogoutRequest message (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-invalidate.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-saml-invalidate # def saml_invalidate(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.saml_invalidate' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/saml/invalidate" + path = '_security/saml/invalidate' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_logout.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_logout.rb index c3a9b3ed53..5318467a53 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_logout.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_logout.rb @@ -15,34 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Invalidates an access token and a refresh token that were generated via the SAML Authenticate API + # Logout of SAML. + # Submits a request to invalidate an access token and refresh token. + # NOTE: This API is intended for use by custom web applications other than Kibana. + # If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack. + # This API invalidates the tokens that were generated for a user by the SAML authenticate API. + # If the SAML realm in Elasticsearch is configured accordingly and the SAML IdP supports this, the Elasticsearch response contains a URL to redirect the user to the IdP that contains a SAML logout request (starting an SP-initiated SAML Single Logout). # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The tokens to invalidate (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-logout.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-saml-logout # def saml_logout(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.saml_logout' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/saml/logout" + path = '_security/saml/logout' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_prepare_authentication.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_prepare_authentication.rb index 38ada9f603..5a634cbae0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_prepare_authentication.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_prepare_authentication.rb @@ -15,34 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Creates a SAML authentication request + # Prepare SAML authentication. + # Create a SAML authentication request (++) as a URL string based on the configuration of the respective SAML realm in Elasticsearch. + # NOTE: This API is intended for use by custom web applications other than Kibana. + # If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack. + # This API returns a URL pointing to the SAML Identity Provider. + # You can use the URL to redirect the browser of the user in order to continue the authentication process. + # The URL includes a single parameter named +SAMLRequest+, which contains a SAML Authentication request that is deflated and Base64 encoded. + # If the configuration dictates that SAML authentication requests should be signed, the URL has two extra parameters named +SigAlg+ and +Signature+. + # These parameters contain the algorithm used for the signature and the signature value itself. + # It also returns a random string that uniquely identifies this SAML Authentication request. + # The caller of this API needs to store this identifier as it needs to be used in a following step of the authentication process. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The realm for which to create the authentication request, identified by either its name or the ACS URL (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-prepare-authentication.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-saml-prepare-authentication # def saml_prepare_authentication(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.saml_prepare_authentication' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_security/saml/prepare" + path = '_security/saml/prepare' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_service_provider_metadata.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_service_provider_metadata.rb index ef67353889..cc1699b02a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_service_provider_metadata.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/saml_service_provider_metadata.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Generates SAML metadata for the Elastic stack SAML 2.0 Service Provider + # Create SAML service provider metadata. + # Generate SAML metadata for a SAML 2.0 Service Provider. + # The SAML 2.0 specification provides a mechanism for Service Providers to describe their capabilities and configuration using a metadata file. + # This API generates Service Provider metadata based on the configuration of a SAML realm in Elasticsearch. # - # @option arguments [String] :realm_name The name of the SAML realm to get the metadata for + # @option arguments [String] :realm_name The name of the SAML realm in Elasticsearch. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-sp-metadata.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-saml-service-provider-metadata # def saml_service_provider_metadata(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.saml_service_provider_metadata' } + + defined_params = [:realm_name].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'realm_name' missing" unless arguments[:realm_name] arguments = arguments.clone @@ -40,11 +50,11 @@ def saml_service_provider_metadata(arguments = {}) _realm_name = arguments.delete(:realm_name) method = Elasticsearch::API::HTTP_GET - path = "_security/saml/metadata/#{Utils.__listify(_realm_name)}" + path = "_security/saml/metadata/#{Utils.listify(_realm_name)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/suggest_user_profiles.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/suggest_user_profiles.rb index 8f11761af6..87e497b3c2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/suggest_user_profiles.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/suggest_user_profiles.rb @@ -15,26 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions + # Suggest a user profile. # Get suggestions for user profiles that match specified search criteria. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. # - # @option arguments [List] :data A comma-separated list of keys for which the corresponding application data are retrieved. + # @option arguments [String] :data A comma-separated list of filters for the +data+ field of the profile document. + # To return all content use +data=*+. + # To return a subset of content, use +data=+ to retrieve content nested under the specified ++. + # By default, the API returns no +data+ content. + # It is an error to specify +data+ as both the query parameter and the request body field. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The suggestion definition for user profiles + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-suggest-user-profile.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-suggest-user-profiles # def suggest_user_profiles(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.suggest_user_profiles' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = if body Elasticsearch::API::HTTP_POST @@ -42,11 +52,11 @@ def suggest_user_profiles(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_security/profile/_suggest" + path = '_security/profile/_suggest' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/update_api_key.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_api_key.rb index 2939d02627..b272f66cd5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/update_api_key.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_api_key.rb @@ -15,22 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Updates attributes of an existing API key. + # Update an API key. + # Update attributes of an existing API key. + # This API supports updates to an API key's access scope, expiration, and metadata. + # To use this API, you must have at least the +manage_own_api_key+ cluster privilege. + # Users can only update API keys that they created or that were granted to them. + # To update another user’s API key, use the +run_as+ feature to submit a request on behalf of another user. + # IMPORTANT: It's not possible to use an API key as the authentication credential for this API. The owner user’s credentials are required. + # Use this API to update API keys created by the create API key or grant API Key APIs. + # If you need to apply the same update to many API keys, you can use the bulk update API keys API to reduce overhead. + # It's not possible to update expired API keys or API keys that have been invalidated by the invalidate API key API. + # The access scope of an API key is derived from the +role_descriptors+ you specify in the request and a snapshot of the owner user's permissions at the time of the request. + # The snapshot of the owner's permissions is updated automatically on every call. + # IMPORTANT: If you don't specify +role_descriptors+ in the request, a call to this API might still change the API key's access scope. + # This change can occur if the owner user's permissions have changed since the API key was created or last modified. # - # @option arguments [String] :id The ID of the API key to update + # @option arguments [String] :id The ID of the API key to update. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The API key request to update attributes of an API key. + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-api-key.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-update-api-key # def update_api_key(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.update_api_key' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -41,11 +61,11 @@ def update_api_key(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_PUT - path = "_security/api_key/#{Utils.__listify(_id)}" + path = "_security/api_key/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/update_cross_cluster_api_key.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_cross_cluster_api_key.rb index 4d677d39c2..ee6ff96b8c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/update_cross_cluster_api_key.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_cross_cluster_api_key.rb @@ -15,26 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Updates attributes of an existing cross-cluster API key. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. + # Update a cross-cluster API key. + # Update the attributes of an existing cross-cluster API key, which is used for API key based remote cluster access. + # To use this API, you must have at least the +manage_security+ cluster privilege. + # Users can only update API keys that they created. + # To update another user's API key, use the +run_as+ feature to submit a request on behalf of another user. + # IMPORTANT: It's not possible to use an API key as the authentication credential for this API. + # To update an API key, the owner user's credentials are required. + # It's not possible to update expired API keys, or API keys that have been invalidated by the invalidate API key API. + # This API supports updates to an API key's access scope, metadata, and expiration. + # The owner user's information, such as the +username+ and +realm+, is also updated automatically on every call. + # NOTE: This API cannot update REST API keys, which should be updated by either the update API key or bulk update API keys API. # - # @option arguments [String] :id The ID of the cross-cluster API key to update + # @option arguments [String] :id The ID of the cross-cluster API key to update. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request to update attributes of a cross-cluster API key. (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-cross-cluster-api-key.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-update-cross-cluster-api-key # def update_cross_cluster_api_key(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.update_cross_cluster_api_key' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] @@ -46,11 +59,11 @@ def update_cross_cluster_api_key(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_PUT - path = "_security/cross_cluster/api_key/#{Utils.__listify(_id)}" + path = "_security/cross_cluster/api_key/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/update_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_settings.rb new file mode 100644 index 0000000000..5d26dbb8f3 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_settings.rb @@ -0,0 +1,61 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Security + module Actions + # Update security index settings. + # Update the user-configurable settings for the security internal index (+.security+ and associated indices). Only a subset of settings are allowed to be modified. This includes +index.auto_expand_replicas+ and +index.number_of_replicas+. + # NOTE: If +index.auto_expand_replicas+ is set, +index.number_of_replicas+ will be ignored during updates. + # If a specific index is not in use on the system and settings are provided for it, the request will be rejected. + # This API does not yet support configuring the settings for indices before they are in use. + # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-update-settings + # + def update_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.update_settings' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_PUT + path = '_security/settings' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/update_user_profile_data.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_user_profile_data.rb index 41d7f5bf3d..4344974745 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/security/update_user_profile_data.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_user_profile_data.rb @@ -15,41 +15,62 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Security module Actions - # Update application specific data for the user profile of the given unique ID. + # Update user profile data. + # Update specific data for the user profile that is associated with a unique ID. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # To use this API, you must have one of the following privileges: + # * The +manage_user_profile+ cluster privilege. + # * The +update_profile_data+ global privilege for the namespaces that are referenced in the request. + # This API updates the +labels+ and +data+ fields of an existing user profile document with JSON objects. + # New keys and their values are added to the profile document and conflicting keys are replaced by data that's included in the request. + # For both labels and data, content is namespaced by the top-level fields. + # The +update_profile_data+ global privilege grants privileges for updating only the allowed namespaces. # - # @option arguments [String] :uid An unique identifier of the user profile - # @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 [String] :refresh If `true` (the default) 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` then do nothing with refreshes. (options: true, false, wait_for) + # @option arguments [String] :uid A unique identifier for the user profile. (*Required*) + # @option arguments [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option arguments [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option arguments [String] :refresh If 'true', Elasticsearch refreshes the affected shards to make this operation + # visible to search. + # If 'wait_for', it waits for a refresh to make this operation visible to search. + # If 'false', nothing is done with refreshes. Server default: false. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The application data to update (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-user-profile-data.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-update-user-profile-data # def update_user_profile_data(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.update_user_profile_data' } + + defined_params = [:uid].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'uid' missing" unless arguments[:uid] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _uid = arguments.delete(:uid) method = Elasticsearch::API::HTTP_PUT - path = "_security/profile/#{Utils.__listify(_uid)}/_data" + path = "_security/profile/#{Utils.listify(_uid)}/_data" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/delete_node.rb b/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/delete_node.rb deleted file mode 100644 index dcb95bab40..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/delete_node.rb +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Shutdown - module Actions - # Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - # - # @option arguments [String] :node_id The node id of node to be removed from the shutdown state - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current - # - def delete_node(arguments = {}) - raise ArgumentError, "Required argument 'node_id' missing" unless arguments[:node_id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _node_id = arguments.delete(:node_id) - - method = Elasticsearch::API::HTTP_DELETE - path = "_nodes/#{Utils.__listify(_node_id)}/shutdown" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/get_node.rb b/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/get_node.rb deleted file mode 100644 index 2ccfb56563..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/get_node.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Shutdown - module Actions - # Retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - # - # @option arguments [String] :node_id Which node for which to retrieve the shutdown status - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current - # - def get_node(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _node_id = arguments.delete(:node_id) - - method = Elasticsearch::API::HTTP_GET - path = if _node_id - "_nodes/#{Utils.__listify(_node_id)}/shutdown" - else - "_nodes/shutdown" - end - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/put_node.rb b/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/put_node.rb deleted file mode 100644 index 768b5cc0c9..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/shutdown/put_node.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Shutdown - module Actions - # Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - # - # @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*) - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current - # - def put_node(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'node_id' missing" unless arguments[:node_id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _node_id = arguments.delete(:node_id) - - method = Elasticsearch::API::HTTP_PUT - path = "_nodes/#{Utils.__listify(_node_id)}/shutdown" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/simulate/ingest.rb b/elasticsearch-api/lib/elasticsearch/api/actions/simulate/ingest.rb new file mode 100644 index 0000000000..f90d9eea27 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/simulate/ingest.rb @@ -0,0 +1,85 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Simulate + module Actions + # Simulate data ingestion. + # Run ingest pipelines against a set of provided documents, optionally with substitute pipeline definitions, to simulate ingesting data into an index. + # This API is meant to be used for troubleshooting or pipeline development, as it does not actually index any data into Elasticsearch. + # The API runs the default and final pipeline for that index against a set of documents provided in the body of the request. + # If a pipeline contains a reroute processor, it follows that reroute processor to the new index, running that index's pipelines as well the same way that a non-simulated ingest would. + # No data is indexed into Elasticsearch. + # Instead, the transformed document is returned, along with the list of pipelines that have been run and the name of the index where the document would have been indexed if this were not a simulation. + # The transformed document is validated against the mappings that would apply to this index, and any validation error is reported in the result. + # This API differs from the simulate pipeline API in that you specify a single pipeline for that API, and it runs only that one pipeline. + # The simulate pipeline API is more useful for developing a single pipeline, while the simulate ingest API is more useful for troubleshooting the interaction of the various pipelines that get applied when ingesting into an index. + # By default, the pipeline definitions that are currently in the system are used. + # However, you can supply substitute pipeline definitions in the body of the request. + # These will be used in place of the pipeline definitions that are already in the system. This can be used to replace existing pipeline definitions or to create new ones. The pipeline substitutions are used only within this request. + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic 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 The index to simulate ingesting into. + # This value can be overridden by specifying an index on each document. + # If you specify this parameter in the request path, it is used for any documents that do not explicitly specify an index argument. + # @option arguments [String] :pipeline The pipeline to use as the default pipeline. + # This value can be used to override the default pipeline of the index. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-simulate-ingest + # + def ingest(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'simulate.ingest' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _index = arguments.delete(:index) + + method = Elasticsearch::API::HTTP_POST + path = if _index + "_ingest/#{Utils.listify(_index)}/_simulate" + else + '_ingest/_simulate' + end + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb index 43f94739af..d1dcfb8519 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb @@ -15,23 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Removes stale data from repository. + # Clean up the snapshot repository. + # Trigger the review of the contents of a snapshot repository and delete any stale data not referenced by existing snapshots. # - # @option arguments [String] :repository A repository name - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [String] :repository The name of the snapshot repository to clean up. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+ Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. + # If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clean-up-snapshot-repo-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-cleanup-repository # def cleanup_repository(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.cleanup_repository' } + + defined_params = [:repository].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] arguments = arguments.clone @@ -42,11 +54,11 @@ def cleanup_repository(arguments = {}) _repository = arguments.delete(:repository) method = Elasticsearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/_cleanup" + path = "_snapshot/#{Utils.listify(_repository)}/_cleanup" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/clone.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/clone.rb index a4804c4d3c..6774ae513f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/clone.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/clone.rb @@ -15,25 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Clones indices from one snapshot into another snapshot in the same repository. + # Clone a snapshot. + # Clone part of all of a 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 Explicit operation timeout for connection to master node + # @option arguments [String] :repository The name of the snapshot repository that both source and target snapshot belong to. (*Required*) + # @option arguments [String] :snapshot The source snapshot name. (*Required*) + # @option arguments [String] :target_snapshot The target snapshot name. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The snapshot clone definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-clone # def clone(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.clone' } + + defined_params = [:repository, :snapshot, :target_snapshot].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + 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] @@ -51,11 +61,11 @@ def clone(arguments = {}) _target_snapshot = arguments.delete(:target_snapshot) method = Elasticsearch::API::HTTP_PUT - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}/_clone/#{Utils.__listify(_target_snapshot)}" + path = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}/_clone/#{Utils.listify(_target_snapshot)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/create.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/create.rb index 1adf0321e7..2a33ff7284 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/create.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/create.rb @@ -15,25 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Creates a snapshot in a repository. + # Create a snapshot. + # Take a snapshot of a cluster or of data streams and indices. # - # @option arguments [String] :repository A repository name - # @option arguments [String] :snapshot A snapshot name - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning + # @option arguments [String] :repository The name of the repository for the snapshot. (*Required*) + # @option arguments [String] :snapshot The name of the snapshot. + # It supportes date math. + # It must be unique in the repository. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [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 arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The snapshot definition + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-create # def create(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.create' } + + defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] @@ -47,11 +59,11 @@ def create(arguments = {}) _snapshot = arguments.delete(:snapshot) method = Elasticsearch::API::HTTP_PUT - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}" + path = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/create_repository.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/create_repository.rb index 239b0e656f..fa31b46cc2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/create_repository.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/create_repository.rb @@ -15,25 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Creates a repository. + # Create or update a snapshot repository. + # IMPORTANT: If you are migrating searchable snapshots, the repository name must be identical in the source and destination clusters. + # To register a snapshot repository, the cluster's global metadata must be writeable. + # Ensure there are no cluster blocks (for example, +cluster.blocks.read_only+ and +clsuter.blocks.read_only_allow_delete+ settings) that prevent write access. + # Several options for this API can be specified using a query parameter or a request body parameter. + # If both parameters are specified, only the query parameter is used. # - # @option arguments [String] :repository A repository name - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout - # @option arguments [Boolean] :verify Whether to verify the repository after creation + # @option arguments [String] :repository The name of the snapshot repository to register or update. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. + # If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Boolean] :verify If +true+, the request verifies the repository is functional on all master and data nodes in the cluster. + # If +false+, this verification is skipped. + # You can also perform this verification with the verify snapshot repository API. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The repository definition (*Required*) + # @option arguments [Hash] :body repository # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-create-repository # def create_repository(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.create_repository' } + + defined_params = [:repository].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] @@ -45,11 +63,11 @@ def create_repository(arguments = {}) _repository = arguments.delete(:repository) method = Elasticsearch::API::HTTP_PUT - path = "_snapshot/#{Utils.__listify(_repository)}" + path = "_snapshot/#{Utils.listify(_repository)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/delete.rb index ee154a709b..1f47f0c2ae 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/delete.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/delete.rb @@ -15,23 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Deletes one or more snapshots. + # Delete snapshots. # - # @option arguments [String] :repository A repository name - # @option arguments [List] :snapshot A comma-separated list of snapshot names - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node + # @option arguments [String] :repository The name of the repository to delete a snapshot from. (*Required*) + # @option arguments [String] :snapshot A comma-separated list of snapshot names to delete. + # It also accepts wildcards (+*+). (*Required*) + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-delete # def delete(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.delete' } + + defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] @@ -45,18 +55,18 @@ def delete(arguments = {}) _snapshot = arguments.delete(:snapshot) method = Elasticsearch::API::HTTP_DELETE - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}" + path = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/delete_repository.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/delete_repository.rb index 7570265903..86859d8018 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/delete_repository.rb @@ -15,23 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Deletes a repository. + # Delete snapshot repositories. + # When a repository is unregistered, Elasticsearch removes only the reference to the location where the repository is storing the snapshots. + # The snapshots themselves are left untouched and in place. # - # @option arguments [List] :repository Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [String, Array] :repository The ame of the snapshot repositories to unregister. + # Wildcard (+*+) patterns are supported. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. + # If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-delete-repository # def delete_repository(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.delete_repository' } + + defined_params = [:repository].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] arguments = arguments.clone @@ -42,18 +56,18 @@ def delete_repository(arguments = {}) _repository = arguments.delete(:repository) method = Elasticsearch::API::HTTP_DELETE - path = "_snapshot/#{Utils.__listify(_repository)}" + path = "_snapshot/#{Utils.listify(_repository)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get.rb index 4d42438caf..2764523ef5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get.rb @@ -15,35 +15,60 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Returns information about a snapshot. + # Get snapshot information. + # NOTE: The +after+ parameter and +next+ field enable you to iterate through snapshots with some consistency guarantees regarding concurrent creation or deletion of snapshots. + # It is guaranteed that any snapshot that exists at the beginning of the iteration and is not concurrently deleted will be seen during the iteration. + # Snapshots concurrently created may be seen during an iteration. # - # @option arguments [String] :repository A repository name - # @option arguments [List] :snapshot A comma-separated list of snapshot names - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - # @option arguments [Boolean] :index_names Whether to include the name of each index in the snapshot. Defaults to true. - # @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 [String] :sort Allows setting a sort order for the result. Defaults to start_time (options: start_time, duration, name, repository, index_count, shard_count, failed_shard_count) - # @option arguments [Integer] :size Maximum number of snapshots to return. Defaults to 0 which means return all that match without limit. - # @option arguments [String] :order Sort order (options: asc, desc) - # @option arguments [String] :from_sort_value Value of the current sort column at which to start retrieval. - # @option arguments [String] :after Offset identifier to start pagination from as returned by the 'next' field in the response body. - # @option arguments [Integer] :offset Numeric offset to start pagination based on the snapshots matching the request. Defaults to 0 - # @option arguments [String] :slm_policy_filter Filter snapshots by a comma-separated list of SLM policy names that snapshots belong to. Accepts wildcards. Use the special pattern '_none' to match snapshots without an SLM policy - # @option arguments [Boolean] :verbose Whether to show verbose snapshot info or only show the basic info found in the repository index blob + # @option arguments [String] :repository A comma-separated list of snapshot repository names used to limit the request. + # Wildcard (+*+) expressions are supported. (*Required*) + # @option arguments [String, Array] :snapshot A comma-separated list of snapshot names to retrieve + # Wildcards (+*+) are supported. + # - 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+. (*Required*) + # @option arguments [String] :after An offset identifier to start pagination from as returned by the next field in the response body. + # @option arguments [String] :from_sort_value The value of the current sort column at which to start retrieval. + # It can be a string +snapshot-+ or a repository name when sorting by snapshot or repository name. + # It can be a millisecond time value or a number when sorting by +index-+ or shard count. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error for any snapshots that are unavailable. + # @option arguments [Boolean] :index_details If +true+, the response includes additional information about each index in the snapshot comprising the number of shards in the index, the total size of the index in bytes, and the maximum number of segments per shard in the index. + # The default is +false+, meaning that this information is omitted. + # @option arguments [Boolean] :index_names If +true+, the response includes the name of each index in each snapshot. Server default: true. + # @option arguments [Boolean] :include_repository If +true+, the response includes the repository name in each snapshot. Server default: true. + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [String] :order The sort order. + # Valid values are +asc+ for ascending and +desc+ for descending order. + # The default behavior is ascending order. Server default: asc. + # @option arguments [Integer] :offset Numeric offset to start pagination from based on the snapshots matching this request. Using a non-zero value for this parameter is mutually exclusive with using the after parameter. Defaults to 0. Server default: 0. + # @option arguments [Integer] :size The maximum number of snapshots to return. + # The default is 0, which means to return all that match the request without limit. Server default: 0. + # @option arguments [String] :slm_policy_filter Filter snapshots by a comma-separated list of snapshot lifecycle management (SLM) policy names that snapshots belong to.You can use wildcards (+*+) and combinations of wildcards followed by exclude patterns starting with +-+. + # For example, the pattern +*,-policy-a-\*+ will return all snapshots except for those that were created by an SLM policy with a name starting with +policy-a-+. + # Note that the wildcard pattern +*+ matches all snapshots created by an SLM policy but not those snapshots that were not created by an SLM policy. + # To include snapshots that were not created by an SLM policy, you can use the special pattern +_none+ that will match all snapshots without an SLM policy. + # @option arguments [String] :sort The sort order for the result. + # The default behavior is sorting by snapshot start time stamp. Server default: start_time. + # @option arguments [Boolean] :verbose If +true+, returns additional information about each snapshot such as the version of Elasticsearch which took the snapshot, the start and end times of the snapshot, and the number of shards snapshotted.NOTE: The parameters +size+, +order+, +after+, +from_sort_value+, +offset+, +slm_policy_filter+, and +sort+ are not supported when you set +verbose=false+ and the sort order for requests with +verbose=false+ is undefined. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-get # def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.get' } + + defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] @@ -57,18 +82,18 @@ def get(arguments = {}) _snapshot = arguments.delete(:snapshot) method = Elasticsearch::API::HTTP_GET - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}" + path = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get_repository.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get_repository.rb index a15f903d52..cd28d14211 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get_repository.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/get_repository.rb @@ -15,23 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Returns information about a repository. + # Get snapshot repository information. # - # @option arguments [List] :repository A comma-separated list of repository names - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) + # @option arguments [String, Array] :repository A comma-separated list of snapshot repository names used to limit the request. + # Wildcard (+*+) expressions are supported including combining wildcards with exclude patterns starting with +-+.To get information about all snapshot repositories registered in the cluster, omit this parameter or use +*+ or +_all+. + # @option arguments [Boolean] :local If +true+, the request gets information from the local node only. + # If +false+, the request gets information from the master node. + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: to 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-get-repository # def get_repository(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.get_repository' } + + defined_params = [:repository].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,21 +52,21 @@ def get_repository(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _repository - "_snapshot/#{Utils.__listify(_repository)}" + "_snapshot/#{Utils.listify(_repository)}" else - "_snapshot" + '_snapshot' end params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/repository_analyze.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/repository_analyze.rb index cee6820ec2..2f2a4e15a5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/repository_analyze.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/repository_analyze.rb @@ -15,32 +15,120 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Analyzes a repository for correctness and performance + # Analyze a snapshot repository. + # Analyze the performance characteristics and any incorrect behaviour found in a repository. + # The response exposes implementation details of the analysis which may change from version to version. + # The response body format is therefore not considered stable and may be different in newer versions. + # There are a large number of third-party storage systems available, not all of which are suitable for use as a snapshot repository by Elasticsearch. + # Some storage systems behave incorrectly, or perform poorly, especially when accessed concurrently by multiple clients as the nodes of an Elasticsearch cluster do. This API performs a collection of read and write operations on your repository which are designed to detect incorrect behaviour and to measure the performance characteristics of your storage system. + # The default values for the parameters are deliberately low to reduce the impact of running an analysis inadvertently and to provide a sensible starting point for your investigations. + # Run your first analysis with the default parameter values to check for simple problems. + # If successful, run a sequence of increasingly large analyses until you encounter a failure or you reach a +blob_count+ of at least +2000+, a +max_blob_size+ of at least +2gb+, a +max_total_data_size+ of at least +1tb+, and a +register_operation_count+ of at least +100+. + # Always specify a generous timeout, possibly +1h+ or longer, to allow time for each analysis to run to completion. + # Perform the analyses using a multi-node cluster of a similar size to your production cluster so that it can detect any problems that only arise when the repository is accessed by many nodes at once. + # If the analysis fails, Elasticsearch detected that your repository behaved unexpectedly. + # This usually means you are using a third-party storage system with an incorrect or incompatible implementation of the API it claims to support. + # If so, this storage system is not suitable for use as a snapshot repository. + # You will need to work with the supplier of your storage system to address the incompatibilities that Elasticsearch detects. + # If the analysis is successful, the API returns details of the testing process, optionally including how long each operation took. + # You can use this information to determine the performance of your storage system. + # If any operation fails or returns an incorrect result, the API returns an error. + # If the API returns an error, it may not have removed all the data it wrote to the repository. + # The error will indicate the location of any leftover data and this path is also recorded in the Elasticsearch logs. + # You should verify that this location has been cleaned up correctly. + # If there is still leftover data at the specified location, you should manually remove it. + # If the connection from your client to Elasticsearch is closed while the client is waiting for the result of the analysis, the test is cancelled. + # Some clients are configured to close their connection if no response is received within a certain timeout. + # An analysis takes a long time to complete so you might need to relax any such client-side timeouts. + # On cancellation the analysis attempts to clean up the data it was writing, but it may not be able to remove it all. + # The path to the leftover data is recorded in the Elasticsearch logs. + # You should verify that this location has been cleaned up correctly. + # If there is still leftover data at the specified location, you should manually remove it. + # If the analysis is successful then it detected no incorrect behaviour, but this does not mean that correct behaviour is guaranteed. + # The analysis attempts to detect common bugs but it does not offer 100% coverage. + # Additionally, it does not test the following: + # * Your repository must perform durable writes. Once a blob has been written it must remain in place until it is deleted, even after a power loss or similar disaster. + # * Your repository must not suffer from silent data corruption. Once a blob has been written, its contents must remain unchanged until it is deliberately modified or deleted. + # * Your repository must behave correctly even if connectivity from the cluster is disrupted. Reads and writes may fail in this case, but they must not return incorrect results. + # IMPORTANT: An analysis writes a substantial amount of data to your repository and then reads it back again. + # This consumes bandwidth on the network between the cluster and the repository, and storage space and I/O bandwidth on the repository itself. + # You must ensure this load does not affect other users of these systems. + # Analyses respect the repository settings +max_snapshot_bytes_per_sec+ and +max_restore_bytes_per_sec+ if available and the cluster setting +indices.recovery.max_bytes_per_sec+ which you can use to limit the bandwidth they consume. + # NOTE: This API is intended for exploratory use by humans. You should expect the request parameters and the response format to vary in future versions. + # NOTE: Different versions of Elasticsearch may perform different checks for repository compatibility, with newer versions typically being stricter than older ones. + # A storage system that passes repository analysis with one version of Elasticsearch may fail with a different version. + # This indicates it behaves incorrectly in ways that the former version did not detect. + # You must work with the supplier of your storage system to address the incompatibilities detected by the repository analysis API in any version of Elasticsearch. + # NOTE: This API may not work correctly in a mixed-version cluster. + # *Implementation details* + # NOTE: This section of documentation describes how the repository analysis API works in this version of Elasticsearch, but you should expect the implementation to vary between versions. The request parameters and response format depend on details of the implementation so may also be different in newer versions. + # The analysis comprises a number of blob-level tasks, as set by the +blob_count+ parameter and a number of compare-and-exchange operations on linearizable registers, as set by the +register_operation_count+ parameter. + # These tasks are distributed over the data and master-eligible nodes in the cluster for execution. + # For most blob-level tasks, the executing node first writes a blob to the repository and then instructs some of the other nodes in the cluster to attempt to read the data it just wrote. + # The size of the blob is chosen randomly, according to the +max_blob_size+ and +max_total_data_size+ parameters. + # If any of these reads fails then the repository does not implement the necessary read-after-write semantics that Elasticsearch requires. + # For some blob-level tasks, the executing node will instruct some of its peers to attempt to read the data before the writing process completes. + # These reads are permitted to fail, but must not return partial data. + # If any read returns partial data then the repository does not implement the necessary atomicity semantics that Elasticsearch requires. + # For some blob-level tasks, the executing node will overwrite the blob while its peers are reading it. + # In this case the data read may come from either the original or the overwritten blob, but the read operation must not return partial data or a mix of data from the two blobs. + # If any of these reads returns partial data or a mix of the two blobs then the repository does not implement the necessary atomicity semantics that Elasticsearch requires for overwrites. + # The executing node will use a variety of different methods to write the blob. + # For instance, where applicable, it will use both single-part and multi-part uploads. + # Similarly, the reading nodes will use a variety of different methods to read the data back again. + # For instance they may read the entire blob from start to end or may read only a subset of the data. + # For some blob-level tasks, the executing node will cancel the write before it is complete. + # In this case, it still instructs some of the other nodes in the cluster to attempt to read the blob but all of these reads must fail to find the blob. + # Linearizable registers are special blobs that Elasticsearch manipulates using an atomic compare-and-exchange operation. + # This operation ensures correct and strongly-consistent behavior even when the blob is accessed by multiple nodes at the same time. + # The detailed implementation of the compare-and-exchange operation on linearizable registers varies by repository type. + # Repository analysis verifies that that uncontended compare-and-exchange operations on a linearizable register blob always succeed. + # Repository analysis also verifies that contended operations either succeed or report the contention but do not return incorrect results. + # If an operation fails due to contention, Elasticsearch retries the operation until it succeeds. + # Most of the compare-and-exchange operations performed by repository analysis atomically increment a counter which is represented as an 8-byte blob. + # Some operations also verify the behavior on small blobs with sizes other than 8 bytes. # - # @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 [String] :repository The name of the repository. (*Required*) + # @option arguments [Integer] :blob_count The total number of blobs to write to the repository during the test. + # For realistic experiments, you should set it to at least +2000+. Server default: 100. + # @option arguments [Integer] :concurrency The number of operations to run concurrently during the test. Server default: 10. + # @option arguments [Boolean] :detailed Indicates whether to return detailed results, including timing information for every operation performed during the analysis. + # If false, it returns only a summary of the analysis. + # @option arguments [Integer] :early_read_node_count The number of nodes on which to perform an early read operation while writing each blob. + # Early read operations are only rarely performed. Server default: 2. + # @option arguments [Integer, String] :max_blob_size The maximum size of a blob to be written during the test. + # For realistic experiments, you should set it to at least +2gb+. Server default: 10mb. + # @option arguments [Integer, String] :max_total_data_size An upper limit on the total size of all the blobs written during the test. + # For realistic experiments, you should set it to at least +1tb+. Server default: 1gb. + # @option arguments [Float] :rare_action_probability The probability of performing a rare action such as an early read, an overwrite, or an aborted write on each blob. Server default: 0.02. + # @option arguments [Boolean] :rarely_abort_writes Indicates whether to rarely cancel writes before they complete. Server default: true. + # @option arguments [Integer] :read_node_count The number of nodes on which to read a blob after writing. Server default: 10. + # @option arguments [Integer] :register_operation_count The minimum number of linearizable register operations to perform in total. + # For realistic experiments, you should set it to at least +100+. Server default: 10. + # @option arguments [Integer] :seed The seed for the pseudo-random number generator used to generate the list of operations performed during the test. + # To repeat the same set of operations in multiple experiments, use the same seed in each experiment. + # Note that the operations are performed concurrently so might not always happen in the same order on each run. + # @option arguments [Time] :timeout The period of time to wait for the test to complete. + # If no response is received before the timeout expires, the test is cancelled and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-repository-analyze # def repository_analyze(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.repository_analyze' } + + defined_params = [:repository].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] arguments = arguments.clone @@ -51,11 +139,11 @@ def repository_analyze(arguments = {}) _repository = arguments.delete(:repository) method = Elasticsearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/_analyze" + path = "_snapshot/#{Utils.listify(_repository)}/_analyze" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/restore.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/restore.rb index b304cb43c7..f081373e41 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/restore.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/restore.rb @@ -15,25 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Restores a snapshot. + # Restore a snapshot. + # Restore a snapshot of a cluster or data streams and indices. + # You can restore a snapshot only to a running cluster with an elected master node. + # The snapshot repository must be registered and available to the cluster. + # The snapshot and cluster versions must be compatible. + # To restore a snapshot, the cluster's global metadata must be writable. Ensure there are't any cluster blocks that prevent writes. The restore operation ignores index blocks. + # Before you restore a data stream, ensure the cluster contains a matching index template with data streams enabled. To check, use the index management feature in Kibana or the get index template API: + # + + # GET _index_template/*?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream + # + + # If no such template exists, you can create one or restore a cluster state that contains one. Without a matching index template, a data stream can't roll over or create backing indices. + # If your snapshot contains data from App Search or Workplace Search, you must restore the Enterprise Search encryption key before you restore the snapshot. # - # @option arguments [String] :repository A repository name - # @option arguments [String] :snapshot A snapshot name - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning + # @option arguments [String] :repository The name of the repository to restore a snapshot from. (*Required*) + # @option arguments [String] :snapshot The name of the snapshot to restore. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Boolean] :wait_for_completion If +true+, the request returns a response when the restore operation completes. + # The operation is complete when it finishes all attempts to recover primary shards for restored indices. + # This applies even if one or more of the recovery attempts fail.If +false+, the request returns a response when the restore operation initializes. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Details of what to restore + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-restore # def restore(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.restore' } + + defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot] @@ -47,11 +69,11 @@ def restore(arguments = {}) _snapshot = arguments.delete(:snapshot) method = Elasticsearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}/_restore" + path = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}/_restore" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb index c2a024cd9d..d270d55221 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb @@ -15,24 +15,48 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Returns information about the status of a snapshot. + # Get the snapshot status. + # Get a detailed description of the current state for each shard participating in the snapshot. + # Note that this API should be used only to obtain detailed shard-level information for ongoing snapshots. + # If this detail is not needed or you want to obtain information about one or more existing snapshots, use the get snapshot API. + # If you omit the ++ request path parameter, the request retrieves information only for currently running snapshots. + # This usage is preferred. + # If needed, you can specify ++ and ++ to retrieve information for specific snapshots, even if they're not currently running. + # WARNING: Using the API to return the status of any snapshots other than currently running snapshots can be expensive. + # The API requires a read from the repository for each shard in each snapshot. + # For example, if you have 100 snapshots with 1,000 shards each, an API request that includes all snapshots will require 100,000 reads (100 snapshots x 1,000 shards). + # Depending on the latency of your storage, such requests can take an extremely long time to return results. + # These requests can also tax machine resources and, when using cloud storage, incur high processing costs. # - # @option arguments [String] :repository A repository name - # @option arguments [List] :snapshot A comma-separated list of snapshot names - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + # @option arguments [String] :repository The snapshot repository name used to limit the request. + # It supports wildcards (+*+) if ++ isn't specified. + # @option arguments [String, Array] :snapshot A comma-separated list of snapshots to retrieve status for. + # The default is currently running snapshots. + # Wildcards (+*+) are not supported. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error for any snapshots that are unavailable. + # If +true+, the request ignores snapshots that are unavailable, such as those that are corrupted or temporarily cannot be returned. + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-status # def status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.status' } + + defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -44,23 +68,23 @@ def status(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _repository && _snapshot - "_snapshot/#{Utils.__listify(_repository)}/#{Utils.__listify(_snapshot)}/_status" + "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}/_status" elsif _repository - "_snapshot/#{Utils.__listify(_repository)}/_status" + "_snapshot/#{Utils.listify(_repository)}/_status" else - "_snapshot/_status" + '_snapshot/_status' end params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/verify_repository.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/verify_repository.rb index 35c02f62e1..aea20ebcec 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/verify_repository.rb @@ -15,23 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Snapshot module Actions - # Verifies a repository. + # Verify a snapshot repository. + # Check for common misconfigurations in a snapshot repository. # - # @option arguments [String] :repository A repository name - # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node - # @option arguments [Time] :timeout Explicit operation timeout + # @option arguments [String] :repository The name of the snapshot repository to verify. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. + # If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-snapshot-verify-repository # def verify_repository(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'snapshot.verify_repository' } + + defined_params = [:repository].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] arguments = arguments.clone @@ -42,11 +54,11 @@ def verify_repository(arguments = {}) _repository = arguments.delete(:repository) method = Elasticsearch::API::HTTP_POST - path = "_snapshot/#{Utils.__listify(_repository)}/_verify" + path = "_snapshot/#{Utils.listify(_repository)}/_verify" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/delete_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/delete_lifecycle.rb index 0781577c3b..9bd26c2282 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/delete_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/delete_lifecycle.rb @@ -15,21 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Deletes an existing snapshot lifecycle policy. + # Delete a policy. + # Delete a snapshot lifecycle policy definition. + # This operation prevents any future snapshots from being taken but does not cancel in-progress snapshots or remove previously-taken snapshots. # - # @option arguments [String] :policy_id The id of the snapshot lifecycle policy to remove + # @option arguments [String] :policy_id The id of the snapshot lifecycle policy to remove (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-delete-lifecycle # def delete_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.delete_lifecycle' } + + defined_params = [:policy_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'policy_id' missing" unless arguments[:policy_id] arguments = arguments.clone @@ -40,11 +53,11 @@ def delete_lifecycle(arguments = {}) _policy_id = arguments.delete(:policy_id) method = Elasticsearch::API::HTTP_DELETE - path = "_slm/policy/#{Utils.__listify(_policy_id)}" - params = {} + path = "_slm/policy/#{Utils.listify(_policy_id)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/execute_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/execute_lifecycle.rb index a4e11a1c67..ebd69275a2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/execute_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/execute_lifecycle.rb @@ -15,21 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Immediately creates a snapshot according to the lifecycle policy, without waiting for the scheduled time. + # Run a policy. + # Immediately create a snapshot according to the snapshot lifecycle policy without waiting for the scheduled time. + # The snapshot policy is normally applied according to its schedule, but you might want to manually run a policy before performing an upgrade or other maintenance. # - # @option arguments [String] :policy_id The id of the snapshot lifecycle policy to be executed + # @option arguments [String] :policy_id The id of the snapshot lifecycle policy to be executed (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-lifecycle.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-execute-lifecycle # def execute_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.execute_lifecycle' } + + defined_params = [:policy_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'policy_id' missing" unless arguments[:policy_id] arguments = arguments.clone @@ -40,11 +53,11 @@ def execute_lifecycle(arguments = {}) _policy_id = arguments.delete(:policy_id) method = Elasticsearch::API::HTTP_PUT - path = "_slm/policy/#{Utils.__listify(_policy_id)}/_execute" - params = {} + path = "_slm/policy/#{Utils.listify(_policy_id)}/_execute" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/execute_retention.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/execute_retention.rb index 6f49f1bb91..b5d1252d5e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/execute_retention.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/execute_retention.rb @@ -15,31 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Deletes any snapshots that are expired according to the policy's retention rules. + # Run a retention policy. + # Manually apply the retention policy to force immediate removal of snapshots that are expired according to the snapshot lifecycle policy retention rules. + # The retention policy is normally applied according to its schedule. # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-execute-retention # def execute_retention(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.execute_retention' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_slm/_execute_retention" - params = {} + path = '_slm/_execute_retention' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_lifecycle.rb index cbd8f3e3a7..4b8ef8b6e5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_lifecycle.rb @@ -15,21 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Retrieves one or more snapshot lifecycle policy definitions and information about the latest snapshot attempts. + # Get policy information. + # Get snapshot lifecycle policy definitions and information about the latest snapshot attempts. # - # @option arguments [List] :policy_id Comma-separated list of snapshot lifecycle policies to retrieve + # @option arguments [String, Array] :policy_id Comma-separated list of snapshot lifecycle policies to retrieve + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-get-lifecycle # def get_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.get_lifecycle' } + + defined_params = [:policy_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -39,14 +51,14 @@ def get_lifecycle(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _policy_id - "_slm/policy/#{Utils.__listify(_policy_id)}" + "_slm/policy/#{Utils.listify(_policy_id)}" else - "_slm/policy" + '_slm/policy' end - params = {} + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_stats.rb index 3463f48a12..d4e865ffff 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_stats.rb @@ -15,31 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Returns global and policy-level statistics about actions taken by snapshot lifecycle management. + # Get snapshot lifecycle management statistics. + # Get global and policy-level statistics about actions taken by snapshot lifecycle management. # + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-get-stats # def get_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.get_stats' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_slm/stats" - params = {} + path = '_slm/stats' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_status.rb index 1801e72b97..335cf26ccf 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/get_status.rb @@ -15,31 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Retrieves the status of snapshot lifecycle management (SLM). + # Get the snapshot lifecycle management status. # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-status.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-get-status # def get_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.get_status' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_slm/status" - params = {} + path = '_slm/status' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/put_lifecycle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/put_lifecycle.rb index 86106c0d82..e0158652bb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/put_lifecycle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/put_lifecycle.rb @@ -15,22 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Creates or updates a snapshot lifecycle policy. + # Create or update a policy. + # Create or update a snapshot lifecycle policy. + # If the policy already exists, this request increments the policy version. + # Only the latest version of a policy is stored. # - # @option arguments [String] :policy_id The id of the snapshot lifecycle policy + # @option arguments [String] :policy_id The identifier for the snapshot lifecycle policy you want to create or update. (*Required*) + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The snapshot lifecycle policy definition to register + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-put-lifecycle # def put_lifecycle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.put_lifecycle' } + + defined_params = [:policy_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'policy_id' missing" unless arguments[:policy_id] arguments = arguments.clone @@ -41,11 +57,11 @@ def put_lifecycle(arguments = {}) _policy_id = arguments.delete(:policy_id) method = Elasticsearch::API::HTTP_PUT - path = "_slm/policy/#{Utils.__listify(_policy_id)}" - params = {} + path = "_slm/policy/#{Utils.listify(_policy_id)}" + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/start.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/start.rb index 92b091f26e..6eacac6a51 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/start.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/start.rb @@ -15,31 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Turns on snapshot lifecycle management (SLM). + # Start snapshot lifecycle management. + # Snapshot lifecycle management (SLM) starts automatically when a cluster is formed. + # Manually starting SLM is necessary only if it has been stopped using the stop SLM API. # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-start # def start(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.start' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_slm/start" - params = {} + path = '_slm/start' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/stop.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/stop.rb index 0fe259257e..ada3fd17e9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/stop.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot_lifecycle_management/stop.rb @@ -15,31 +15,45 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SnapshotLifecycleManagement module Actions - # Turns off snapshot lifecycle management (SLM). + # Stop snapshot lifecycle management. + # Stop all snapshot lifecycle management (SLM) operations and the SLM plugin. + # This API is useful when you are performing maintenance on a cluster and need to prevent SLM from performing any actions on your data streams or indices. + # Stopping SLM does not stop any snapshots that are in progress. + # You can manually trigger snapshots with the run snapshot lifecycle policy API even if SLM is stopped. + # The API returns a response as soon as the request is acknowledged, but the plugin might continue to run until in-progress operations complete and it can be safely stopped. + # Use the get snapshot lifecycle management status API to see if SLM is running. # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-slm-stop # def stop(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'slm.stop' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_slm/stop" - params = {} + path = '_slm/stop' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/sql/clear_cursor.rb b/elasticsearch-api/lib/elasticsearch/api/actions/sql/clear_cursor.rb index aa97e9efca..70cf7c3956 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/sql/clear_cursor.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/sql/clear_cursor.rb @@ -15,34 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SQL module Actions - # Clears the SQL cursor + # Clear an SQL search cursor. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Specify the cursor value in the `cursor` element to clean the cursor. (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-sql-cursor-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-clear-cursor # def clear_cursor(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'sql.clear_cursor' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_sql/close" + path = '_sql/close' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/sql/delete_async.rb b/elasticsearch-api/lib/elasticsearch/api/actions/sql/delete_async.rb index 5801dcc08d..d55dedd5a8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/sql/delete_async.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/sql/delete_async.rb @@ -15,21 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SQL module Actions - # Deletes an async SQL search or a stored synchronous SQL search. If the search is still running, the API cancels it. + # Delete an async SQL search. + # Delete an async SQL search or a stored synchronous SQL search. + # If the search is still running, the API cancels it. + # If the Elasticsearch security features are enabled, only the following users can use this API to delete a search: + # * Users with the +cancel_task+ cluster privilege. + # * The user who first submitted the search. # - # @option arguments [String] :id The async search ID + # @option arguments [String] :id The identifier for the search. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-async-sql-search-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-delete-async # def delete_async(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'sql.delete_async' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +52,11 @@ def delete_async(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE - path = "_sql/async/delete/#{Utils.__listify(_id)}" + path = "_sql/async/delete/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/sql/get_async.rb b/elasticsearch-api/lib/elasticsearch/api/actions/sql/get_async.rb index a2347e9717..be93a52c91 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/sql/get_async.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/sql/get_async.rb @@ -15,25 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SQL module Actions - # Returns the current status and available results for an async SQL search or stored synchronous SQL search + # Get async SQL search results. + # Get the current status and available results for an async SQL search or stored synchronous SQL search. + # If the Elasticsearch security features are enabled, only the user who first submitted the SQL search can retrieve the search using this API. # - # @option arguments [String] :id The async search ID - # @option arguments [String] :delimiter Separator for CSV results - # @option arguments [String] :format Short version of the Accept header, e.g. json, yaml - # @option arguments [Time] :keep_alive Retention period for the search and its results - # @option arguments [Time] :wait_for_completion_timeout Duration to wait for complete results + # @option arguments [String] :id The identifier for the search. (*Required*) + # @option arguments [String] :delimiter The separator for CSV results. + # The API supports this parameter only for CSV responses. Server default: ,. + # @option arguments [String] :format The format for the response. + # You must specify a format using this parameter or the +Accept+ HTTP header. + # If you specify both, the API uses this parameter. + # @option arguments [Time] :keep_alive The retention period for the search and its results. + # It defaults to the +keep_alive+ period for the original SQL search. + # @option arguments [Time] :wait_for_completion_timeout The period to wait for complete results. + # It defaults to no timeout, meaning the request waits for complete search results. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-async-sql-search-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-get-async # def get_async(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'sql.get_async' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -44,11 +58,11 @@ def get_async(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET - path = "_sql/async/#{Utils.__listify(_id)}" + path = "_sql/async/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/sql/get_async_status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/sql/get_async_status.rb index bc7a91522f..15baca1c96 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/sql/get_async_status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/sql/get_async_status.rb @@ -15,21 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SQL module Actions - # Returns the current status of an async SQL search or a stored synchronous SQL search + # Get the async SQL search status. + # Get the current status of an async SQL search or a stored synchronous SQL search. # - # @option arguments [String] :id The async search ID + # @option arguments [String] :id The identifier for the search. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-async-sql-search-status-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-get-async-status # def get_async_status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'sql.get_async_status' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +48,11 @@ def get_async_status(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET - path = "_sql/async/status/#{Utils.__listify(_id)}" + path = "_sql/async/status/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/sql/query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/sql/query.rb index 90f4875669..a7c0c200e5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/sql/query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/sql/query.rb @@ -15,35 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SQL module Actions - # Executes a SQL request + # Get SQL search results. + # Run an SQL request. # - # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml + # @option arguments [String] :format The format for the response. + # You can also specify a format using the +Accept+ HTTP header. + # If you specify both this parameter and the +Accept+ HTTP header, this parameter takes precedence. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Use the `query` element to start a query. Use the `cursor` element to continue a query. (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-search-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-query # def query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'sql.query' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_sql" + path = '_sql' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/sql/translate.rb b/elasticsearch-api/lib/elasticsearch/api/actions/sql/translate.rb index 3f9764e75f..14e8e89f4c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/sql/translate.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/sql/translate.rb @@ -15,34 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SQL module Actions - # Translates SQL into Elasticsearch queries + # Translate SQL into Elasticsearch queries. + # Translate an SQL search into a search API request containing Query DSL. + # It accepts the same request body parameters as the SQL search API, excluding +cursor+. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Specify the query in the `query` element. (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-sql-translate # def translate(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'sql.translate' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_sql/translate" + path = '_sql/translate' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/ssl/certificates.rb b/elasticsearch-api/lib/elasticsearch/api/actions/ssl/certificates.rb index 549c149c9a..5d6f2882a2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/ssl/certificates.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/ssl/certificates.rb @@ -15,31 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module SSL module Actions - # Retrieves information about the X.509 certificates used to encrypt communications in the cluster. + # Get SSL certificates. + # Get information about the X.509 certificates that are used to encrypt communications in the cluster. + # The API returns a list that includes certificates from all TLS contexts including: + # - Settings for transport and HTTP interfaces + # - TLS settings that are used within authentication realms + # - TLS settings for remote monitoring exporters + # The list includes certificates that are used for configuring trust, such as those configured in the +xpack.security.transport.ssl.truststore+ and +xpack.security.transport.ssl.certificate_authorities+ settings. + # It also includes certificates that are used for configuring server identity, such as +xpack.security.http.ssl.keystore+ and +xpack.security.http.ssl.certificate settings+. + # The list does not include certificates that are sourced from the default SSL context of the Java Runtime Environment (JRE), even if those certificates are in use within Elasticsearch. + # NOTE: When a PKCS#11 token is configured as the truststore of the JRE, the API returns all the certificates that are included in the PKCS#11 token irrespective of whether these are used in the Elasticsearch TLS configuration. + # If Elasticsearch is configured to use a keystore or truststore, the API output includes all certificates in that store, even though some of the certificates might not be in active use within the cluster. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ssl-certificates # def certificates(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'ssl.certificates' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_ssl/certificates" + path = '_ssl/certificates' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/delete.rb deleted file mode 100644 index 3a36171521..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/delete.rb +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module SynonymRule - module Actions - # Deletes a synonym rule in a synonym set - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :synonyms_set The id of the synonym set to be updated - # @option arguments [String] :synonym_rule The id of the synonym rule to be deleted - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-synonym-rule.html - # - def delete(arguments = {}) - raise ArgumentError, "Required argument 'synonyms_set' missing" unless arguments[:synonyms_set] - raise ArgumentError, "Required argument 'synonym_rule' missing" unless arguments[:synonym_rule] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _synonyms_set = arguments.delete(:synonyms_set) - - _synonym_rule = arguments.delete(:synonym_rule) - - method = Elasticsearch::API::HTTP_DELETE - path = "_synonyms/#{Utils.__listify(_synonyms_set)}/#{Utils.__listify(_synonym_rule)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/get.rb deleted file mode 100644 index 3b09962ca1..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/get.rb +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module SynonymRule - module Actions - # Retrieves a synonym rule from a synonym set - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :synonyms_set The id of the synonym set to retrieve the synonym rule from - # @option arguments [String] :synonym_rule The id of the synonym rule to retrieve - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-synonym-rule.html - # - def get(arguments = {}) - raise ArgumentError, "Required argument 'synonyms_set' missing" unless arguments[:synonyms_set] - raise ArgumentError, "Required argument 'synonym_rule' missing" unless arguments[:synonym_rule] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _synonyms_set = arguments.delete(:synonyms_set) - - _synonym_rule = arguments.delete(:synonym_rule) - - method = Elasticsearch::API::HTTP_GET - path = "_synonyms/#{Utils.__listify(_synonyms_set)}/#{Utils.__listify(_synonym_rule)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/put.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/put.rb deleted file mode 100644 index 15063d7f63..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/synonym_rule/put.rb +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module SynonymRule - module Actions - # Creates or updates a synonym rule in a synonym set - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :synonyms_set The id of the synonym set to be updated with the synonym rule - # @option arguments [String] :synonym_rule The id of the synonym rule to be updated or created - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Synonym rule (*Required*) - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-synonym-rule.html - # - def put(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'synonyms_set' missing" unless arguments[:synonyms_set] - raise ArgumentError, "Required argument 'synonym_rule' missing" unless arguments[:synonym_rule] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _synonyms_set = arguments.delete(:synonyms_set) - - _synonym_rule = arguments.delete(:synonym_rule) - - method = Elasticsearch::API::HTTP_PUT - path = "_synonyms/#{Utils.__listify(_synonyms_set)}/#{Utils.__listify(_synonym_rule)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete.rb deleted file mode 100644 index c7d64979c3..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete.rb +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Synonyms - module Actions - # Deletes a synonym set - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :synonyms_set The name of the synonyms set to be deleted - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-synonyms.html - # - def delete(arguments = {}) - raise ArgumentError, "Required argument 'synonyms_set' missing" unless arguments[:synonyms_set] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _synonyms_set = arguments.delete(:synonyms_set) - - method = Elasticsearch::API::HTTP_DELETE - path = "_synonyms/#{Utils.__listify(_synonyms_set)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete_synonym.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete_synonym.rb new file mode 100644 index 0000000000..131c8abbe4 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete_synonym.rb @@ -0,0 +1,72 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Synonyms + module Actions + # Delete a synonym set. + # You can only delete a synonyms set that is not in use by any index analyzer. + # Synonyms sets can be used in synonym graph token filters and synonym token filters. + # These synonym filters can be used as part of search analyzers. + # Analyzers need to be loaded when an index is restored (such as when a node starts, or the index becomes open). + # Even if the analyzer is not used on any field mapping, it still needs to be loaded on the index recovery phase. + # If any analyzers cannot be loaded, the index becomes unavailable and the cluster status becomes red or yellow as index shards are not available. + # To prevent that, synonyms sets that are used in analyzers can't be deleted. + # A delete request in this case will return a 400 response code. + # To remove a synonyms set, you must first remove all indices that contain analyzers using it. + # You can migrate an index by creating a new index that does not contain the token filter with the synonyms set, and use the reindex API in order to copy over the index data. + # Once finished, you can delete the index. + # When the synonyms set is not used in analyzers, you will be able to delete it. + # + # @option arguments [String] :id The synonyms set identifier to delete. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-delete-synonym + # + def delete_synonym(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'synonyms.delete_synonym' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_synonyms/#{Utils.listify(_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete_synonym_rule.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete_synonym_rule.rb new file mode 100644 index 0000000000..fa433aa937 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/delete_synonym_rule.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Synonyms + module Actions + # Delete a synonym rule. + # Delete a synonym rule from a synonym set. + # + # @option arguments [String] :set_id The ID of the synonym set to update. (*Required*) + # @option arguments [String] :rule_id The ID of the synonym rule to delete. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-delete-synonym-rule + # + def delete_synonym_rule(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'synonyms.delete_synonym_rule' } + + defined_params = [:set_id, :rule_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'set_id' missing" unless arguments[:set_id] + raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _set_id = arguments.delete(:set_id) + + _rule_id = arguments.delete(:rule_id) + + method = Elasticsearch::API::HTTP_DELETE + path = "_synonyms/#{Utils.listify(_set_id)}/#{Utils.listify(_rule_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get.rb deleted file mode 100644 index f20ae634da..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get.rb +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Synonyms - module Actions - # Retrieves a synonym set - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :synonyms_set The name of the synonyms set to be retrieved - # @option arguments [Integer] :from Starting offset - # @option arguments [Integer] :size specifies a max number of results to get - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-synonyms.html - # - def get(arguments = {}) - raise ArgumentError, "Required argument 'synonyms_set' missing" unless arguments[:synonyms_set] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - _synonyms_set = arguments.delete(:synonyms_set) - - method = Elasticsearch::API::HTTP_GET - path = "_synonyms/#{Utils.__listify(_synonyms_set)}" - params = Utils.process_params(arguments) - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonym.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonym.rb new file mode 100644 index 0000000000..aebd55d8ac --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonym.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Synonyms + module Actions + # Get a synonym set. + # + # @option arguments [String] :id The synonyms set identifier to retrieve. (*Required*) + # @option arguments [Integer] :from The starting offset for query rules to retrieve. Server default: 0. + # @option arguments [Integer] :size The max number of query rules to retrieve. Server default: 10. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-get-synonym + # + def get_synonym(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'synonyms.get_synonym' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_GET + path = "_synonyms/#{Utils.listify(_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonym_rule.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonym_rule.rb new file mode 100644 index 0000000000..fed3016155 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonym_rule.rb @@ -0,0 +1,65 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Synonyms + module Actions + # Get a synonym rule. + # Get a synonym rule from a synonym set. + # + # @option arguments [String] :set_id The ID of the synonym set to retrieve the synonym rule from. (*Required*) + # @option arguments [String] :rule_id The ID of the synonym rule to retrieve. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-get-synonym-rule + # + def get_synonym_rule(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'synonyms.get_synonym_rule' } + + defined_params = [:set_id, :rule_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'set_id' missing" unless arguments[:set_id] + raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _set_id = arguments.delete(:set_id) + + _rule_id = arguments.delete(:rule_id) + + method = Elasticsearch::API::HTTP_GET + path = "_synonyms/#{Utils.listify(_set_id)}/#{Utils.listify(_rule_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonyms_sets.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonyms_sets.rb new file mode 100644 index 0000000000..f3b1297bc0 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/get_synonyms_sets.rb @@ -0,0 +1,53 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Synonyms + module Actions + # Get all synonym sets. + # Get a summary of all defined synonym sets. + # + # @option arguments [Integer] :from The starting offset for synonyms sets to retrieve. Server default: 0. + # @option arguments [Integer] :size The maximum number of synonyms sets to retrieve. Server default: 10. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-get-synonym + # + def get_synonyms_sets(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'synonyms.get_synonyms_sets' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_synonyms' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put.rb deleted file mode 100644 index 4b0cd02143..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put.rb +++ /dev/null @@ -1,59 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module Synonyms - module Actions - # Creates or updates a synonyms set - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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] :synonyms_set The name of the synonyms set to be created or updated - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Synonyms set rules (*Required*) - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-synonyms.html - # - def put(arguments = {}) - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'synonyms_set' missing" unless arguments[:synonyms_set] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _synonyms_set = arguments.delete(:synonyms_set) - - method = Elasticsearch::API::HTTP_PUT - path = "_synonyms/#{Utils.__listify(_synonyms_set)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put_synonym.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put_synonym.rb new file mode 100644 index 0000000000..138bb900c6 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put_synonym.rb @@ -0,0 +1,66 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Synonyms + module Actions + # Create or update a synonym set. + # Synonyms sets are limited to a maximum of 10,000 synonym rules per set. + # If you need to manage more synonym rules, you can create multiple synonym sets. + # When an existing synonyms set is updated, the search analyzers that use the synonyms set are reloaded automatically for all indices. + # This is equivalent to invoking the reload search analyzers API for all indices that use the synonyms set. + # + # @option arguments [String] :id The ID of the synonyms set to be created or updated. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-put-synonym + # + def put_synonym(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'synonyms.put_synonym' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_PUT + path = "_synonyms/#{Utils.listify(_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put_synonym_rule.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put_synonym_rule.rb new file mode 100644 index 0000000000..64243d40f0 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms/put_synonym_rule.rb @@ -0,0 +1,69 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Synonyms + module Actions + # Create or update a synonym rule. + # Create or update a synonym rule in a synonym set. + # If any of the synonym rules included is invalid, the API returns an error. + # When you update a synonym rule, all analyzers using the synonyms set will be reloaded automatically to reflect the new rule. + # + # @option arguments [String] :set_id The ID of the synonym set. (*Required*) + # @option arguments [String] :rule_id The ID of the synonym rule to be updated or created. (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-synonyms-put-synonym-rule + # + def put_synonym_rule(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'synonyms.put_synonym_rule' } + + defined_params = [:set_id, :rule_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'set_id' missing" unless arguments[:set_id] + raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _set_id = arguments.delete(:set_id) + + _rule_id = arguments.delete(:rule_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_synonyms/#{Utils.listify(_set_id)}/#{Utils.listify(_rule_id)}" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms_sets/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/synonyms_sets/get.rb deleted file mode 100644 index 8a20c6b9da..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/synonyms_sets/get.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# -module Elasticsearch - module API - module SynonymsSets - module Actions - # Retrieves a summary of all defined synonym sets - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic 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 [Integer] :from Starting offset - # @option arguments [Integer] :size specifies a max number of results to get - # @option arguments [Hash] :headers Custom HTTP headers - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/list-synonyms.html - # - def get(arguments = {}) - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = nil - - method = Elasticsearch::API::HTTP_GET - path = "_synonyms" - params = Utils.process_params(arguments) - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/tasks/cancel.rb b/elasticsearch-api/lib/elasticsearch/api/actions/tasks/cancel.rb index 076fb91d80..3f6f0ccf2d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/tasks/cancel.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/tasks/cancel.rb @@ -15,29 +15,44 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Tasks module Actions - # Cancels a task, if it can be cancelled through an API. + # Cancel a task. + # WARNING: The task management API is new and should still be considered a beta feature. + # The API may change in ways that are not backwards compatible. + # A task may continue to run for some time after it has been cancelled because it may not be able to safely stop its current activity straight away. + # It is also possible that Elasticsearch must complete its work on other tasks before it can process the cancellation. + # The get task information API will continue to list these cancelled tasks until they complete. + # The cancelled flag in the response indicates that the cancellation command has been processed and the task will stop as soon as possible. + # To troubleshoot why a cancelled task does not complete promptly, use the get task information API with the +?detailed+ parameter to identify the other tasks the system is running. + # You can also use the node hot threads API to obtain detailed information about the work the system is doing instead of completing the cancelled task. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 [String, Integer] :task_id The task identifier. + # @option arguments [String] :actions A comma-separated list or wildcard expression of actions that is used to limit the request. + # @option arguments [Array] :nodes A comma-separated list of node IDs or names that is used to limit the request. + # @option arguments [String] :parent_task_id A parent task ID that is used to limit the tasks. + # @option arguments [Boolean] :wait_for_completion If true, the request blocks until all found tasks are complete. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-tasks # def cancel(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'tasks.cancel' } + + defined_params = [:task_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -47,14 +62,14 @@ def cancel(arguments = {}) method = Elasticsearch::API::HTTP_POST path = if _task_id - "_tasks/#{Utils.__listify(_task_id)}/_cancel" + "_tasks/#{Utils.listify(_task_id)}/_cancel" else - "_tasks/_cancel" + '_tasks/_cancel' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/tasks/get.rb b/elasticsearch-api/lib/elasticsearch/api/actions/tasks/get.rb index b94d91bc6b..3ca9ae65d5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/tasks/get.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/tasks/get.rb @@ -15,27 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Tasks module Actions - # Returns information about a task. + # Get task information. + # Get information about a task currently running in the cluster. + # WARNING: The task management API is new and should still be considered a beta feature. + # The API may change in ways that are not backwards compatible. + # If the task identifier is not found, a 404 response code indicates that there are no resources that match the request. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 [String] :task_id The task identifier. (*Required*) + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [Boolean] :wait_for_completion If +true+, the request blocks until the task has completed. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-tasks # def get(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'tasks.get' } + + defined_params = [:task_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -44,11 +58,11 @@ def get(arguments = {}) _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_GET - path = "_tasks/#{Utils.__listify(_task_id)}" + path = "_tasks/#{Utils.listify(_task_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/tasks/list.rb b/elasticsearch-api/lib/elasticsearch/api/actions/tasks/list.rb index a16ef69c36..317642ee95 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/tasks/list.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/tasks/list.rb @@ -15,42 +15,102 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Tasks module Actions - # Returns a list of tasks. + # Get all tasks. + # Get information about the tasks currently running on one or more nodes in the cluster. + # WARNING: The task management API is new and should still be considered a beta feature. + # The API may change in ways that are not backwards compatible. + # **Identifying running tasks** + # The +X-Opaque-Id header+, when provided on the HTTP request header, is going to be returned as a header in the response as well as in the headers field for in the task information. + # This enables you to track certain calls or associate certain tasks with the client that started them. + # For example: + # + + # curl -i -H "X-Opaque-Id: 123456" "http://localhost:9200/_tasks?group_by=parents" + # + + # The API returns the following result: + # + + # HTTP/1.1 200 OK + # X-Opaque-Id: 123456 + # content-type: application/json; charset=UTF-8 + # content-length: 831 + # { + # "tasks" : { + # "u5lcZHqcQhu-rUoFaqDphA:45" : { + # "node" : "u5lcZHqcQhu-rUoFaqDphA", + # "id" : 45, + # "type" : "transport", + # "action" : "cluster:monitor/tasks/lists", + # "start_time_in_millis" : 1513823752749, + # "running_time_in_nanos" : 293139, + # "cancellable" : false, + # "headers" : { + # "X-Opaque-Id" : "123456" + # }, + # "children" : [ + # { + # "node" : "u5lcZHqcQhu-rUoFaqDphA", + # "id" : 46, + # "type" : "direct", + # "action" : "cluster:monitor/tasks/lists[n]", + # "start_time_in_millis" : 1513823752750, + # "running_time_in_nanos" : 92133, + # "cancellable" : false, + # "parent_task_id" : "u5lcZHqcQhu-rUoFaqDphA:45", + # "headers" : { + # "X-Opaque-Id" : "123456" + # } + # } + # ] + # } + # } + # } + # + + # In this example, +X-Opaque-Id: 123456+ is the ID as a part of the response header. + # The +X-Opaque-Id+ in the task +headers+ is the ID for the task that was initiated by the REST request. + # The +X-Opaque-Id+ in the children +headers+ is the child task of the task that was initiated by the REST request. # This functionality is Experimental and may be changed or removed # completely in a future release. Elastic 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 [String] :actions A comma-separated list or wildcard expression of actions used to limit the request. + # For example, you can use +cluser:*+ to retrieve all cluster-related tasks. + # @option arguments [Boolean] :detailed If +true+, the response includes detailed information about the running tasks. + # This information is useful to distinguish tasks from each other but is more costly to run. + # @option arguments [String] :group_by A key that is used to group tasks in the response. + # The task lists can be grouped either by nodes or by parent tasks. + # @option arguments [String, Array] :nodes A comma-separated list of node IDs or names that is used to limit the returned information. + # @option arguments [String] :parent_task_id A parent task identifier that is used to limit returned information. + # To return all tasks, omit this parameter or use a value of +-1+. + # If the parent task is not found, the API does not return a 404 response code. + # @option arguments [Time] :timeout The period to wait for each node to respond. + # If a node does not respond before its timeout expires, the response does not include its information. + # However, timed out nodes are included in the +node_failures+ property. Server default: 30s. + # @option arguments [Boolean] :wait_for_completion If +true+, the request blocks until the operation is complete. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-tasks # def list(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'tasks.list' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_tasks" + path = '_tasks' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/terms_enum.rb b/elasticsearch-api/lib/elasticsearch/api/actions/terms_enum.rb index 9dbfd23551..ce09a037b1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/terms_enum.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/terms_enum.rb @@ -15,27 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios. + # Get terms in an index. + # Discover terms that match a partial string in an index. + # This API is designed for low-latency look-ups used in auto-complete scenarios. # - # @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] :index A comma-separated list of data streams, indices, and index aliases to search. + # Wildcard (+*+) expressions are supported. + # To search all data streams or indices, omit this parameter or use +*+ or +_all+. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body field name, string which is the prefix expected in matching terms, timeout and size for max number of results + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-terms-enum # def terms_enum(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'terms_enum' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -45,11 +56,11 @@ def terms_enum(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "#{Utils.__listify(_index)}/_terms_enum" + path = "#{Utils.listify(_index)}/_terms_enum" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/termvectors.rb b/elasticsearch-api/lib/elasticsearch/api/actions/termvectors.rb index 1e6f2eea98..eacb145c24 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/termvectors.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/termvectors.rb @@ -15,39 +15,73 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Returns information and statistics about terms in the fields of a particular document. + # Get term vector information. + # Get information and statistics about terms in the fields of a particular document. + # You can retrieve term vectors for documents stored in the index or for artificial documents passed in the body of the request. + # You can specify the fields you are interested in through the +fields+ parameter or by adding the fields to the request body. + # For example: + # + + # GET /my-index-000001/_termvectors/1?fields=message + # + + # Fields can be specified using wildcards, similar to the multi match query. + # Term vectors are real-time by default, not near real-time. + # This can be changed by setting +realtime+ parameter to +false+. + # You can request three types of values: _term information_, _term statistics_, and _field statistics_. + # By default, all term information and field statistics are returned for all fields but term statistics are excluded. + # **Term information** + # * term frequency in the field (always returned) + # * term positions (+positions: true+) + # * start and end offsets (+offsets: true+) + # * term payloads (+payloads: true+), as base64 encoded bytes + # If the requested information wasn't stored in the index, it will be computed on the fly if possible. + # Additionally, term vectors could be computed for documents not even existing in the index, but instead provided by the user. # - # @option arguments [String] :index The index in which the document resides. - # @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) + # @option arguments [String] :index The name of the index that contains the document. (*Required*) + # @option arguments [String] :id A unique identifier for the document. + # @option arguments [String, Array] :fields A comma-separated list or wildcard expressions of fields to include in the statistics. + # It is used as the default list unless a specific field list is provided in the +completion_fields+ or +fielddata_fields+ parameters. + # @option arguments [Boolean] :field_statistics If +true+, the response includes: + # - The document count (how many documents contain this field). + # - The sum of document frequencies (the sum of document frequencies for all terms in this field). + # - The sum of total term frequencies (the sum of total term frequencies of each term in this field). Server default: true. + # @option arguments [Boolean] :offsets If +true+, the response includes term offsets. Server default: true. + # @option arguments [Boolean] :payloads If +true+, the response includes term payloads. Server default: true. + # @option arguments [Boolean] :positions If +true+, the response includes term positions. Server default: true. + # @option arguments [String] :preference The node or shard the operation should be performed on. + # It is random by default. + # @option arguments [Boolean] :realtime If true, the request is real-time as opposed to near-real-time. Server default: true. + # @option arguments [String] :routing A custom value that is used to route operations to a specific shard. + # @option arguments [Boolean] :term_statistics If +true+, the response includes: + # - The total term frequency (how often a term occurs in all documents). + # - The document frequency (the number of documents containing the current term). + # By default these values are not returned since term statistics can have a serious performance impact. + # @option arguments [Integer] :version If +true+, returns the document version as part of a hit. + # @option arguments [String] :version_type The version type. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Define parameters and or supply a document to get termvectors for. See documentation. + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-termvectors # def termvectors(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'termvectors' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) @@ -59,23 +93,24 @@ def termvectors(arguments = {}) Elasticsearch::API::HTTP_GET end - endpoint = arguments.delete(:endpoint) || '_termvectors' - path = if _index && _id - "#{Utils.__listify(_index)}/_termvectors/#{Utils.__listify(_id)}" - else - "#{Utils.__listify(_index)}/_termvectors" - end + arguments.delete(:endpoint) + path = if _index && _id + "#{Utils.listify(_index)}/_termvectors/#{Utils.listify(_id)}" + else + "#{Utils.listify(_index)}/_termvectors" + end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end # Deprecated: Use the plural version, {#termvectors} # def termvector(arguments = {}) - termvectors(arguments.merge endpoint: '_termvector') + warn '[DEPRECATION] `termvector` is deprecated. Please use the plural version, `termvectors` instead.' + termvectors(arguments.merge(endpoint: '_termvector')) end end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_field_structure.rb b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_field_structure.rb new file mode 100644 index 0000000000..2cef2c2986 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_field_structure.rb @@ -0,0 +1,127 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module TextStructure + module Actions + # Find the structure of a text field. + # Find the structure of a text field in an Elasticsearch index. + # This API provides a starting point for extracting further information from log messages already ingested into Elasticsearch. + # For example, if you have ingested data into a very simple index that has just +@timestamp+ and message fields, you can use this API to see what common structure exists in the message field. + # The response from the API contains: + # * Sample messages. + # * Statistics that reveal the most common values for all fields detected within the text and basic numeric statistics for numeric fields. + # * Information about the structure of the text, which is useful when you write ingest configurations to index it or similarly formatted text. + # * Appropriate mappings for an Elasticsearch index, which you could use to ingest the text. + # All this information can be calculated by the structure finder with no guidance. + # However, you can optionally override some of the decisions about the text structure by specifying one or more query parameters. + # If the structure finder produces unexpected results, specify the +explain+ query parameter and an explanation will appear in the response. + # It helps determine why the returned structure was chosen. + # + # @option arguments [String] :column_names If +format+ is set to +delimited+, you can specify the column names in a comma-separated list. + # If this parameter is not specified, the structure finder uses the column names from the header row of the text. + # If the text does not have a header row, columns are named "column1", "column2", "column3", for example. + # @option arguments [String] :delimiter If you have set +format+ to +delimited+, you can specify the character used to delimit the values in each row. + # Only a single character is supported; the delimiter cannot have multiple characters. + # By default, the API considers the following possibilities: comma, tab, semi-colon, and pipe (+|+). + # In this default scenario, all rows must have the same number of fields for the delimited format to be detected. + # If you specify a delimiter, up to 10% of the rows can have a different number of columns than the first row. + # @option arguments [Integer] :documents_to_sample The number of documents to include in the structural analysis. + # The minimum value is 2. Server default: 1000. + # @option arguments [String] :ecs_compatibility The mode of compatibility with ECS compliant Grok patterns. + # Use this parameter to specify whether to use ECS Grok patterns instead of legacy ones when the structure finder creates a Grok pattern. + # This setting primarily has an impact when a whole message Grok pattern such as +%{CATALINALOG}+ matches the input. + # If the structure finder identifies a common structure but has no idea of the meaning then generic field names such as +path+, +ipaddress+, +field1+, and +field2+ are used in the +grok_pattern+ output. + # The intention in that situation is that a user who knows the meanings will rename the fields before using them. Server default: disabled. + # @option arguments [Boolean] :explain If +true+, the response includes a field named +explanation+, which is an array of strings that indicate how the structure finder produced its result. + # @option arguments [String] :field The field that should be analyzed. (*Required*) + # @option arguments [String] :format The high level structure of the text. + # By default, the API chooses the format. + # In this default scenario, all rows must have the same number of fields for a delimited format to be detected. + # If the format is set to delimited and the delimiter is not set, however, the API tolerates up to 5% of rows that have a different number of columns than the first row. + # @option arguments [String] :grok_pattern If the format is +semi_structured_text+, you can specify a Grok pattern that is used to extract fields from every message in the text. + # The name of the timestamp field in the Grok pattern must match what is specified in the +timestamp_field+ parameter. + # If that parameter is not specified, the name of the timestamp field in the Grok pattern must match "timestamp". + # If +grok_pattern+ is not specified, the structure finder creates a Grok pattern. + # @option arguments [String] :index The name of the index that contains the analyzed field. (*Required*) + # @option arguments [String] :quote If the format is +delimited+, you can specify the character used to quote the values in each row if they contain newlines or the delimiter character. + # Only a single character is supported. + # If this parameter is not specified, the default value is a double quote (+"+). + # If your delimited text format does not use quoting, a workaround is to set this argument to a character that does not appear anywhere in the sample. + # @option arguments [Boolean] :should_trim_fields If the format is +delimited+, you can specify whether values between delimiters should have whitespace trimmed from them. + # If this parameter is not specified and the delimiter is pipe (+|+), the default value is true. + # Otherwise, the default value is +false+. + # @option arguments [Time] :timeout The maximum amount of time that the structure analysis can take. + # If the analysis is still running when the timeout expires, it will be stopped. Server default: 25s. + # @option arguments [String] :timestamp_field The name of the field that contains the primary timestamp of each record in the text. + # In particular, if the text was ingested into an index, this is the field that would be used to populate the +@timestamp+ field.If the format is +semi_structured_text+, this field must match the name of the appropriate extraction in the +grok_pattern+. + # Therefore, for semi-structured text, it is best not to specify this parameter unless +grok_pattern+ is also specified.For structured text, if you specify this parameter, the field must exist within the text.If this parameter is not specified, the structure finder makes a decision about which field (if any) is the primary timestamp field. + # For structured text, it is not compulsory to have a timestamp in the text. + # @option arguments [String] :timestamp_format The Java time format of the timestamp field in the text. + # Only a subset of Java time format letter groups are supported: + # - +a+ + # - +d+ + # - +dd+ + # - +EEE+ + # - +EEEE+ + # - +H+ + # - +HH+ + # - +h+ + # - +M+ + # - +MM+ + # - +MMM+ + # - +MMMM+ + # - +mm+ + # - +ss+ + # - +XX+ + # - +XXX+ + # - +yy+ + # - +yyyy+ + # - +zzz+ + # Additionally +S+ letter groups (fractional seconds) of length one to nine are supported providing they occur after +ss+ and are separated from the +ss+ by a period (+.+), comma (+,+), or colon (+:+). + # Spacing and punctuation is also permitted with the exception a question mark (+?+), newline, and carriage return, together with literal text enclosed in single quotes. + # For example, +MM/dd HH.mm.ss,SSSSSS 'in' yyyy+ is a valid override format.One valuable use case for this parameter is when the format is semi-structured text, there are multiple timestamp formats in the text, and you know which format corresponds to the primary timestamp, but you do not want to specify the full +grok_pattern+. + # Another is when the timestamp format is one that the structure finder does not consider by default.If this parameter is not specified, the structure finder chooses the best format from a built-in set.If the special value +null+ is specified, the structure finder will not look for a primary timestamp in the text. + # When the format is semi-structured text, this will result in the structure finder treating the text as single-line messages. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-text_structure + # + def find_field_structure(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'text_structure.find_field_structure' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_text_structure/find_field_structure' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_message_structure.rb b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_message_structure.rb new file mode 100644 index 0000000000..6fc99b4d65 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_message_structure.rb @@ -0,0 +1,126 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module TextStructure + module Actions + # Find the structure of text messages. + # Find the structure of a list of text messages. + # The messages must contain data that is suitable to be ingested into Elasticsearch. + # This API provides a starting point for ingesting data into Elasticsearch in a format that is suitable for subsequent use with other Elastic Stack functionality. + # Use this API rather than the find text structure API if your input text has already been split up into separate messages by some other process. + # The response from the API contains: + # * Sample messages. + # * Statistics that reveal the most common values for all fields detected within the text and basic numeric statistics for numeric fields. + # * Information about the structure of the text, which is useful when you write ingest configurations to index it or similarly formatted text. + # Appropriate mappings for an Elasticsearch index, which you could use to ingest the text. + # All this information can be calculated by the structure finder with no guidance. + # However, you can optionally override some of the decisions about the text structure by specifying one or more query parameters. + # If the structure finder produces unexpected results, specify the +explain+ query parameter and an explanation will appear in the response. + # It helps determine why the returned structure was chosen. + # + # @option arguments [String] :column_names If the format is +delimited+, you can specify the column names in a comma-separated list. + # If this parameter is not specified, the structure finder uses the column names from the header row of the text. + # If the text does not have a header role, columns are named "column1", "column2", "column3", for example. + # @option arguments [String] :delimiter If you the format is +delimited+, you can specify the character used to delimit the values in each row. + # Only a single character is supported; the delimiter cannot have multiple characters. + # By default, the API considers the following possibilities: comma, tab, semi-colon, and pipe (+|+). + # In this default scenario, all rows must have the same number of fields for the delimited format to be detected. + # If you specify a delimiter, up to 10% of the rows can have a different number of columns than the first row. + # @option arguments [String] :ecs_compatibility The mode of compatibility with ECS compliant Grok patterns. + # Use this parameter to specify whether to use ECS Grok patterns instead of legacy ones when the structure finder creates a Grok pattern. + # This setting primarily has an impact when a whole message Grok pattern such as +%{CATALINALOG}+ matches the input. + # If the structure finder identifies a common structure but has no idea of meaning then generic field names such as +path+, +ipaddress+, +field1+, and +field2+ are used in the +grok_pattern+ output, with the intention that a user who knows the meanings rename these fields before using it. Server default: disabled. + # @option arguments [Boolean] :explain If this parameter is set to true, the response includes a field named +explanation+, which is an array of strings that indicate how the structure finder produced its result. + # @option arguments [String] :format The high level structure of the text. + # By default, the API chooses the format. + # In this default scenario, all rows must have the same number of fields for a delimited format to be detected. + # If the format is +delimited+ and the delimiter is not set, however, the API tolerates up to 5% of rows that have a different number of columns than the first row. + # @option arguments [String] :grok_pattern If the format is +semi_structured_text+, you can specify a Grok pattern that is used to extract fields from every message in the text. + # The name of the timestamp field in the Grok pattern must match what is specified in the +timestamp_field+ parameter. + # If that parameter is not specified, the name of the timestamp field in the Grok pattern must match "timestamp". + # If +grok_pattern+ is not specified, the structure finder creates a Grok pattern. + # @option arguments [String] :quote If the format is +delimited+, you can specify the character used to quote the values in each row if they contain newlines or the delimiter character. + # Only a single character is supported. + # If this parameter is not specified, the default value is a double quote (+"+). + # If your delimited text format does not use quoting, a workaround is to set this argument to a character that does not appear anywhere in the sample. + # @option arguments [Boolean] :should_trim_fields If the format is +delimited+, you can specify whether values between delimiters should have whitespace trimmed from them. + # If this parameter is not specified and the delimiter is pipe (+|+), the default value is true. + # Otherwise, the default value is +false+. + # @option arguments [Time] :timeout The maximum amount of time that the structure analysis can take. + # If the analysis is still running when the timeout expires, it will be stopped. Server default: 25s. + # @option arguments [String] :timestamp_field The name of the field that contains the primary timestamp of each record in the text. + # In particular, if the text was ingested into an index, this is the field that would be used to populate the +@timestamp+ field.If the format is +semi_structured_text+, this field must match the name of the appropriate extraction in the +grok_pattern+. + # Therefore, for semi-structured text, it is best not to specify this parameter unless +grok_pattern+ is also specified.For structured text, if you specify this parameter, the field must exist within the text.If this parameter is not specified, the structure finder makes a decision about which field (if any) is the primary timestamp field. + # For structured text, it is not compulsory to have a timestamp in the text. + # @option arguments [String] :timestamp_format The Java time format of the timestamp field in the text. + # Only a subset of Java time format letter groups are supported: + # - +a+ + # - +d+ + # - +dd+ + # - +EEE+ + # - +EEEE+ + # - +H+ + # - +HH+ + # - +h+ + # - +M+ + # - +MM+ + # - +MMM+ + # - +MMMM+ + # - +mm+ + # - +ss+ + # - +XX+ + # - +XXX+ + # - +yy+ + # - +yyyy+ + # - +zzz+ + # Additionally +S+ letter groups (fractional seconds) of length one to nine are supported providing they occur after +ss+ and are separated from the +ss+ by a period (+.+), comma (+,+), or colon (+:+). + # Spacing and punctuation is also permitted with the exception a question mark (+?+), newline, and carriage return, together with literal text enclosed in single quotes. + # For example, +MM/dd HH.mm.ss,SSSSSS 'in' yyyy+ is a valid override format.One valuable use case for this parameter is when the format is semi-structured text, there are multiple timestamp formats in the text, and you know which format corresponds to the primary timestamp, but you do not want to specify the full +grok_pattern+. + # Another is when the timestamp format is one that the structure finder does not consider by default.If this parameter is not specified, the structure finder chooses the best format from a built-in set.If the special value +null+ is specified, the structure finder will not look for a primary timestamp in the text. + # When the format is semi-structured text, this will result in the structure finder treating the text as single-line messages. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-text-structure-find-message-structure + # + def find_message_structure(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'text_structure.find_message_structure' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_text_structure/find_message_structure' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_structure.rb b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_structure.rb index 56ea7efbfa..b5fa98ab50 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_structure.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_structure.rb @@ -15,56 +15,132 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module TextStructure module Actions - # Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch. + # Find the structure of a text file. + # The text file must contain data that is suitable to be ingested into Elasticsearch. + # This API provides a starting point for ingesting data into Elasticsearch in a format that is suitable for subsequent use with other Elastic Stack functionality. + # Unlike other Elasticsearch endpoints, the data that is posted to this endpoint does not need to be UTF-8 encoded and in JSON format. + # It must, however, be text; binary text formats are not currently supported. + # The size is limited to the Elasticsearch HTTP receive buffer size, which defaults to 100 Mb. + # The response from the API contains: + # * A couple of messages from the beginning of the text. + # * Statistics that reveal the most common values for all fields detected within the text and basic numeric statistics for numeric fields. + # * Information about the structure of the text, which is useful when you write ingest configurations to index it or similarly formatted text. + # * Appropriate mappings for an Elasticsearch index, which you could use to ingest the text. + # All this information can be calculated by the structure finder with no guidance. + # However, you can optionally override some of the decisions about the text structure by specifying one or more query parameters. # - # @option arguments [Integer] :lines_to_sample How many lines of the file should be included in the analysis - # @option arguments [Integer] :line_merge_size_limit Maximum number of characters permitted in a single message when lines are merged to create messages. - # @option arguments [Time] :timeout Timeout after which the analysis will be aborted - # @option arguments [String] :charset Optional parameter to specify the character set of the file - # @option arguments [String] :format Optional parameter to specify the high level file format (options: ndjson, xml, delimited, semi_structured_text) - # @option arguments [Boolean] :has_header_row Optional parameter to specify whether a delimited file includes the column names in its first row - # @option arguments [List] :column_names Optional parameter containing a comma separated list of the column names for a delimited file - # @option arguments [String] :delimiter Optional parameter to specify the delimiter character for a delimited file - must be a single character - # @option arguments [String] :quote Optional parameter to specify the quote character for a delimited file - must be a single character - # @option arguments [Boolean] :should_trim_fields Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them - # @option arguments [String] :grok_pattern Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file - # @option arguments [String] :ecs_compatibility Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' - # @option arguments [String] :timestamp_field Optional parameter to specify the timestamp field in the file - # @option arguments [String] :timestamp_format Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format - # @option arguments [Boolean] :explain Whether to include a commentary on how the structure was derived + # @option arguments [String] :charset The text's character set. + # It must be a character set that is supported by the JVM that Elasticsearch uses. + # For example, +UTF-8+, +UTF-16LE+, +windows-1252+, or +EUC-JP+. + # If this parameter is not specified, the structure finder chooses an appropriate character set. + # @option arguments [String] :column_names If you have set format to +delimited+, you can specify the column names in a comma-separated list. + # If this parameter is not specified, the structure finder uses the column names from the header row of the text. + # If the text does not have a header role, columns are named "column1", "column2", "column3", for example. + # @option arguments [String] :delimiter If you have set +format+ to +delimited+, you can specify the character used to delimit the values in each row. + # Only a single character is supported; the delimiter cannot have multiple characters. + # By default, the API considers the following possibilities: comma, tab, semi-colon, and pipe (+|+). + # In this default scenario, all rows must have the same number of fields for the delimited format to be detected. + # If you specify a delimiter, up to 10% of the rows can have a different number of columns than the first row. + # @option arguments [String] :ecs_compatibility The mode of compatibility with ECS compliant Grok patterns. + # Use this parameter to specify whether to use ECS Grok patterns instead of legacy ones when the structure finder creates a Grok pattern. + # Valid values are +disabled+ and +v1+. + # This setting primarily has an impact when a whole message Grok pattern such as +%{CATALINALOG}+ matches the input. + # If the structure finder identifies a common structure but has no idea of meaning then generic field names such as +path+, +ipaddress+, +field1+, and +field2+ are used in the +grok_pattern+ output, with the intention that a user who knows the meanings rename these fields before using it. Server default: disabled. + # @option arguments [Boolean] :explain If this parameter is set to +true+, the response includes a field named explanation, which is an array of strings that indicate how the structure finder produced its result. + # If the structure finder produces unexpected results for some text, use this query parameter to help you determine why the returned structure was chosen. + # @option arguments [String] :format The high level structure of the text. + # Valid values are +ndjson+, +xml+, +delimited+, and +semi_structured_text+. + # By default, the API chooses the format. + # In this default scenario, all rows must have the same number of fields for a delimited format to be detected. + # If the format is set to +delimited+ and the delimiter is not set, however, the API tolerates up to 5% of rows that have a different number of columns than the first row. + # @option arguments [String] :grok_pattern If you have set +format+ to +semi_structured_text+, you can specify a Grok pattern that is used to extract fields from every message in the text. + # The name of the timestamp field in the Grok pattern must match what is specified in the +timestamp_field+ parameter. + # If that parameter is not specified, the name of the timestamp field in the Grok pattern must match "timestamp". + # If +grok_pattern+ is not specified, the structure finder creates a Grok pattern. + # @option arguments [Boolean] :has_header_row If you have set +format+ to +delimited+, you can use this parameter to indicate whether the column names are in the first row of the text. + # If this parameter is not specified, the structure finder guesses based on the similarity of the first row of the text to other rows. + # @option arguments [Integer] :line_merge_size_limit The maximum number of characters in a message when lines are merged to form messages while analyzing semi-structured text. + # If you have extremely long messages you may need to increase this, but be aware that this may lead to very long processing times if the way to group lines into messages is misdetected. Server default: 10000. + # @option arguments [Integer] :lines_to_sample The number of lines to include in the structural analysis, starting from the beginning of the text. + # The minimum is 2. + # If the value of this parameter is greater than the number of lines in the text, the analysis proceeds (as long as there are at least two lines in the text) for all of the lines.NOTE: The number of lines and the variation of the lines affects the speed of the analysis. + # For example, if you upload text where the first 1000 lines are all variations on the same message, the analysis will find more commonality than would be seen with a bigger sample. + # If possible, however, it is more efficient to upload sample text with more variety in the first 1000 lines than to request analysis of 100000 lines to achieve some variety. Server default: 1000. + # @option arguments [String] :quote If you have set +format+ to +delimited+, you can specify the character used to quote the values in each row if they contain newlines or the delimiter character. + # Only a single character is supported. + # If this parameter is not specified, the default value is a double quote (+"+). + # If your delimited text format does not use quoting, a workaround is to set this argument to a character that does not appear anywhere in the sample. + # @option arguments [Boolean] :should_trim_fields If you have set +format+ to +delimited+, you can specify whether values between delimiters should have whitespace trimmed from them. + # If this parameter is not specified and the delimiter is pipe (+|+), the default value is +true+. + # Otherwise, the default value is +false+. + # @option arguments [Time] :timeout The maximum amount of time that the structure analysis can take. + # If the analysis is still running when the timeout expires then it will be stopped. Server default: 25s. + # @option arguments [String] :timestamp_field The name of the field that contains the primary timestamp of each record in the text. + # In particular, if the text were ingested into an index, this is the field that would be used to populate the +@timestamp+ field.If the +format+ is +semi_structured_text+, this field must match the name of the appropriate extraction in the +grok_pattern+. + # Therefore, for semi-structured text, it is best not to specify this parameter unless +grok_pattern+ is also specified.For structured text, if you specify this parameter, the field must exist within the text.If this parameter is not specified, the structure finder makes a decision about which field (if any) is the primary timestamp field. + # For structured text, it is not compulsory to have a timestamp in the text. + # @option arguments [String] :timestamp_format The Java time format of the timestamp field in the text.Only a subset of Java time format letter groups are supported: + # - +a+ + # - +d+ + # - +dd+ + # - +EEE+ + # - +EEEE+ + # - +H+ + # - +HH+ + # - +h+ + # - +M+ + # - +MM+ + # - +MMM+ + # - +MMMM+ + # - +mm+ + # - +ss+ + # - +XX+ + # - +XXX+ + # - +yy+ + # - +yyyy+ + # - +zzz+ + # Additionally +S+ letter groups (fractional seconds) of length one to nine are supported providing they occur after +ss+ and separated from the +ss+ by a +.+, +,+ or +:+. + # Spacing and punctuation is also permitted with the exception of +?+, newline and carriage return, together with literal text enclosed in single quotes. + # For example, +MM/dd HH.mm.ss,SSSSSS 'in' yyyy+ is a valid override format.One valuable use case for this parameter is when the format is semi-structured text, there are multiple timestamp formats in the text, and you know which format corresponds to the primary timestamp, but you do not want to specify the full +grok_pattern+. + # Another is when the timestamp format is one that the structure finder does not consider by default.If this parameter is not specified, the structure finder chooses the best format from a built-in set.If the special value +null+ is specified the structure finder will not look for a primary timestamp in the text. + # When the format is semi-structured text this will result in the structure finder treating the text as single-line messages. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The contents of the file to be analyzed (*Required*) + # @option arguments [Hash] :body text_files # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/find-structure.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-text-structure-find-structure # def find_structure(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'text_structure.find_structure' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_POST - path = "_text_structure/find_structure" + path = '_text_structure/find_structure' params = Utils.process_params(arguments) - if body.is_a? Array - payload = Elasticsearch::API::Utils.__bulkify(body) - else - payload = body - end + payload = if body.is_a? Array + Elasticsearch::API::Utils.bulkify(body) + else + body + end - headers.merge!("Content-Type" => "application/x-ndjson") + headers.merge!({ + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + }) Elasticsearch::API::Response.new( - perform_request(method, path, params, payload, headers) + perform_request(method, path, params, payload, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/test_grok_pattern.rb b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/test_grok_pattern.rb new file mode 100644 index 0000000000..df8bdbde39 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/test_grok_pattern.rb @@ -0,0 +1,58 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module TextStructure + module Actions + # Test a Grok pattern. + # Test a Grok pattern on one or more lines of text. + # The API indicates whether the lines match the pattern together with the offsets and lengths of the matched substrings. + # + # @option arguments [String] :ecs_compatibility The mode of compatibility with ECS compliant Grok patterns. + # Use this parameter to specify whether to use ECS Grok patterns instead of legacy ones when the structure finder creates a Grok pattern. + # Valid values are +disabled+ and +v1+. Server default: disabled. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-text-structure-test-grok-pattern + # + def test_grok_pattern(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'text_structure.test_grok_pattern' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = '_text_structure/test_grok_pattern' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/delete_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/delete_transform.rb index 0be922e61b..89373e3acf 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/delete_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/delete_transform.rb @@ -15,24 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Deletes an existing transform. + # Delete a transform. # - # @option arguments [String] :transform_id The id of the transform to delete - # @option arguments [Boolean] :force When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted. - # @option arguments [Boolean] :delete_dest_index When `true`, the destination index is deleted together with the transform. The default value is `false`, meaning that the destination index will not be deleted. - # @option arguments [Time] :timeout Controls the time to wait for the transform deletion + # @option arguments [String] :transform_id Identifier for the transform. (*Required*) + # @option arguments [Boolean] :force If this value is false, the transform must be stopped before it can be deleted. If true, the transform is + # deleted regardless of its current state. + # @option arguments [Boolean] :delete_dest_index If this value is true, the destination index is deleted together with the transform. If false, the destination + # index will not be deleted + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-delete-transform # def delete_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.delete_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id] arguments = arguments.clone @@ -43,11 +52,11 @@ def delete_transform(arguments = {}) _transform_id = arguments.delete(:transform_id) method = Elasticsearch::API::HTTP_DELETE - path = "_transform/#{Utils.__listify(_transform_id)}" + path = "_transform/#{Utils.listify(_transform_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_node_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_node_stats.rb new file mode 100644 index 0000000000..1f480a8eab --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_node_stats.rb @@ -0,0 +1,55 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Transform + module Actions + # Retrieves transform usage information for transform nodes. + # + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-node-stats.html + # + def get_node_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.get_node_stats' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = if body + Elasticsearch::API::HTTP_POST + else + Elasticsearch::API::HTTP_GET + end + + path = '_transform/_node_stats' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_transform.rb index 957645fca5..91dcc59eb9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_transform.rb @@ -15,25 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Retrieves configuration information for transforms. + # Get transforms. + # Get configuration information for transforms. # - # @option arguments [String] :transform_id The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms - # @option arguments [Integer] :from skips a number of transform configs, defaults to 0 - # @option arguments [Integer] :size specifies a max number of transforms to get, defaults to 100 - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - # @option arguments [Boolean] :exclude_generated Omits fields that are illegal to set on transform PUT + # @option arguments [String, Array] :transform_id Identifier for the transform. It can be a transform identifier or a + # wildcard expression. You can get information for all transforms by using + # +_all+, by specifying +*+ as the ++, or by omitting the + # ++. + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no transforms that match. + # - Contains the _all string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If this parameter is false, the request returns a 404 status code when + # there are no matches or only partial matches. Server default: true. + # @option arguments [Integer] :from Skips the specified number of transforms. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of transforms to obtain. Server default: 100. + # @option arguments [Boolean] :exclude_generated Excludes fields that were automatically added when creating the + # transform. This allows the configuration to be in an acceptable format to + # be retrieved and then added to another cluster. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-get-transform # def get_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.get_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -43,14 +61,14 @@ def get_transform(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _transform_id - "_transform/#{Utils.__listify(_transform_id)}" + "_transform/#{Utils.listify(_transform_id)}" else - "_transform" + '_transform' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_transform_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_transform_stats.rb index 72c8b5f0d3..3b95969bc6 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_transform_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/get_transform_stats.rb @@ -15,25 +15,41 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Retrieves usage information for transforms. + # Get transform stats. + # Get usage information for transforms. # - # @option arguments [String] :transform_id The id of the transform for which to get stats. '_all' or '*' implies all transforms - # @option arguments [Number] :from skips a number of transform stats, defaults to 0 - # @option arguments [Number] :size specifies a max number of transform stats to get, defaults to 100 + # @option arguments [String, Array] :transform_id Identifier for the transform. It can be a transform identifier or a + # wildcard expression. You can get information for all transforms by using + # +_all+, by specifying +*+ as the ++, or by omitting the + # ++. (*Required*) + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: + # - Contains wildcard expressions and there are no transforms that match. + # - Contains the _all string or no identifiers and there are no matches. + # - Contains wildcard expressions and there are only partial matches. + # If this parameter is false, the request returns a 404 status code when + # there are no matches or only partial matches. Server default: true. + # @option arguments [Integer] :from Skips the specified number of transforms. Server default: 0. + # @option arguments [Integer] :size Specifies the maximum number of transforms to obtain. Server default: 100. # @option arguments [Time] :timeout Controls the time to wait for the stats - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-get-transform-stats # def get_transform_stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.get_transform_stats' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id] arguments = arguments.clone @@ -44,11 +60,11 @@ def get_transform_stats(arguments = {}) _transform_id = arguments.delete(:transform_id) method = Elasticsearch::API::HTTP_GET - path = "_transform/#{Utils.__listify(_transform_id)}/_stats" + path = "_transform/#{Utils.listify(_transform_id)}/_stats" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/preview_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/preview_transform.rb index ec438cd5d6..27a9978262 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/preview_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/preview_transform.rb @@ -15,23 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Previews a transform. + # Preview a transform. + # Generates a preview of the results that you will get when you create a transform with the same configuration. + # It returns a maximum of 100 results. The calculations are based on all the current data in the source index. It also + # generates a list of mappings and settings for the destination index. These values are determined based on the field + # types of the source index and the transform aggregations. # - # @option arguments [String] :transform_id The id of the transform to preview. - # @option arguments [Time] :timeout Controls the time to wait for the preview + # @option arguments [String] :transform_id Identifier for the transform to preview. If you specify this path parameter, you cannot provide transform + # configuration details in the request body. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the + # timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The definition for the transform to preview + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-preview-transform # def preview_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.preview_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -46,14 +59,14 @@ def preview_transform(arguments = {}) end path = if _transform_id - "_transform/#{Utils.__listify(_transform_id)}/_preview" + "_transform/#{Utils.listify(_transform_id)}/_preview" else - "_transform/_preview" + '_transform/_preview' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/put_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/put_transform.rb index ceab00abbc..c8c4f3e32c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/put_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/put_transform.rb @@ -15,24 +15,53 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Instantiates a transform. + # Create a transform. + # Creates a transform. + # A transform copies data from source indices, transforms it, and persists it into an entity-centric destination index. You can also think of the destination index as a two-dimensional tabular data structure (known as + # a data frame). The ID for each document in the data frame is generated from a hash of the entity, so there is a + # unique row per entity. + # You must choose either the latest or pivot method for your transform; you cannot use both in a single transform. If + # you choose to use the pivot method for your transform, the entities are defined by the set of +group_by+ fields in + # the pivot object. If you choose to use the latest method, the entities are defined by the +unique_key+ field values + # in the latest object. + # You must have +create_index+, +index+, and +read+ privileges on the destination index and +read+ and + # +view_index_metadata+ privileges on the source indices. When Elasticsearch security features are enabled, the + # transform remembers which roles the user that created it had at the time of creation and uses those same roles. If + # those roles do not have the required privileges on the source and destination indices, the transform fails when it + # attempts unauthorized operations. + # NOTE: You must use Kibana or this API to create a transform. Do not add a transform directly into any + # +.transform-internal*+ indices using the Elasticsearch index API. If Elasticsearch security features are enabled, do + # not give users any privileges on +.transform-internal*+ indices. If you used transforms prior to 7.5, also do not + # give users any privileges on +.data-frame-internal*+ indices. # - # @option arguments [String] :transform_id The id of the new transform. - # @option arguments [Boolean] :defer_validation If validations should be deferred until transform starts, defaults to false. - # @option arguments [Time] :timeout Controls the time to wait for the transform to start + # @option arguments [String] :transform_id Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), + # hyphens, and underscores. It has a 64 character limit and must start and end with alphanumeric characters. (*Required*) + # @option arguments [Boolean] :defer_validation When the transform is created, a series of validations occur to ensure its success. For example, there is a + # check for the existence of the source indices and a check that the destination index is not part of the source + # index pattern. You can use this parameter to skip the checks, for example when the source index does not exist + # until after the transform is created. The validations are always run when you start the transform, however, with + # the exception of privilege checks. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The transform definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-put-transform # def put_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.put_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id] @@ -44,11 +73,11 @@ def put_transform(arguments = {}) _transform_id = arguments.delete(:transform_id) method = Elasticsearch::API::HTTP_PUT - path = "_transform/#{Utils.__listify(_transform_id)}" + path = "_transform/#{Utils.listify(_transform_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/reset_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/reset_transform.rb index b05517f375..5bb1dc9e28 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/reset_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/reset_transform.rb @@ -15,23 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Resets an existing transform. + # Reset a transform. + # Before you can reset it, you must stop it; alternatively, use the +force+ query parameter. + # If the destination index was created by the transform, it is deleted. # - # @option arguments [String] :transform_id The id of the transform to reset - # @option arguments [Boolean] :force When `true`, the transform is reset regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be reset. - # @option arguments [Time] :timeout Controls the time to wait for the transform to reset + # @option arguments [String] :transform_id Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), + # hyphens, and underscores. It has a 64 character limit and must start and end with alphanumeric characters. (*Required*) + # @option arguments [Boolean] :force If this value is +true+, the transform is reset regardless of its current state. If it's +false+, the transform + # must be stopped before it can be reset. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/reset-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-reset-transform # def reset_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.reset_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id] arguments = arguments.clone @@ -42,11 +53,11 @@ def reset_transform(arguments = {}) _transform_id = arguments.delete(:transform_id) method = Elasticsearch::API::HTTP_POST - path = "_transform/#{Utils.__listify(_transform_id)}/_reset" + path = "_transform/#{Utils.listify(_transform_id)}/_reset" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/schedule_now_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/schedule_now_transform.rb index c609724e69..60e9630bf9 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/schedule_now_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/schedule_now_transform.rb @@ -15,22 +15,34 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Schedules now a transform. + # Schedule a transform to start now. + # Instantly run a transform to process data. + # If you run this API, the transform will process the new data instantly, + # without waiting for the configured frequency interval. After the API is called, + # the transform will be processed again at +now + frequency+ unless the API + # is called again in the meantime. # - # @option arguments [String] :transform_id The id of the transform. (*Required*) - # @option arguments [Time] :timeout Controls the time to wait for the scheduling to take place + # @option arguments [String] :transform_id Identifier for the transform. (*Required*) + # @option arguments [Time] :timeout Controls the time to wait for the scheduling to take place Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/schedule-now-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-schedule-now-transform # def schedule_now_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.schedule_now_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id] arguments = arguments.clone @@ -41,11 +53,11 @@ def schedule_now_transform(arguments = {}) _transform_id = arguments.delete(:transform_id) method = Elasticsearch::API::HTTP_POST - path = "_transform/#{Utils.__listify(_transform_id)}/_schedule_now" + path = "_transform/#{Utils.listify(_transform_id)}/_schedule_now" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/start_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/start_transform.rb index d41773766d..48fea92273 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/start_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/start_transform.rb @@ -15,23 +15,43 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Starts one or more transforms. + # Start a transform. + # When you start a transform, it creates the destination index if it does not already exist. The +number_of_shards+ is + # set to +1+ and the +auto_expand_replicas+ is set to +0-1+. If it is a pivot transform, it deduces the mapping + # definitions for the destination index from the source indices and the transform aggregations. If fields in the + # destination index are derived from scripts (as in the case of +scripted_metric+ or +bucket_script+ aggregations), + # the transform uses dynamic mappings unless an index template exists. If it is a latest transform, it does not deduce + # mapping definitions; it uses dynamic mappings. To use explicit mappings, create the destination index before you + # start the transform. Alternatively, you can create an index template, though it does not affect the deduced mappings + # in a pivot transform. + # When the transform starts, a series of validations occur to ensure its success. If you deferred validation when you + # created the transform, they occur when you start the transform—​with the exception of privilege checks. When + # Elasticsearch security features are enabled, the transform remembers which roles the user that created it had at the + # time of creation and uses those same roles. If those roles do not have the required privileges on the source and + # destination indices, the transform fails when it attempts unauthorized operations. # - # @option arguments [String] :transform_id The id of the transform to start - # @option arguments [String] :from Restricts the set of transformed entities to those changed after this time - # @option arguments [Time] :timeout Controls the time to wait for the transform to start + # @option arguments [String] :transform_id Identifier for the transform. (*Required*) + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. + # @option arguments [String] :from Restricts the set of transformed entities to those changed after this time. Relative times like now-30d are supported. Only applicable for continuous transforms. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-start-transform # def start_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.start_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id] arguments = arguments.clone @@ -42,11 +62,11 @@ def start_transform(arguments = {}) _transform_id = arguments.delete(:transform_id) method = Elasticsearch::API::HTTP_POST - path = "_transform/#{Utils.__listify(_transform_id)}/_start" + path = "_transform/#{Utils.listify(_transform_id)}/_start" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/stop_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/stop_transform.rb index 42743b657c..474a880bc5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/stop_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/stop_transform.rb @@ -15,26 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions + # Stop transforms. # Stops one or more transforms. # - # @option arguments [String] :transform_id The id of the transform to stop - # @option arguments [Boolean] :force Whether to force stop a failed transform or not. Default to false - # @option arguments [Boolean] :wait_for_completion Whether to wait for the transform to fully stop before returning or not. Default to false - # @option arguments [Time] :timeout Controls the time to wait until the transform has stopped. Default to 30 seconds - # @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - # @option arguments [Boolean] :wait_for_checkpoint Whether to wait for the transform to reach a checkpoint before stopping. Default to false + # @option arguments [String] :transform_id Identifier for the transform. To stop multiple transforms, use a comma-separated list or a wildcard expression. + # To stop all transforms, use +_all+ or +*+ as the identifier. (*Required*) + # @option arguments [Boolean] :allow_no_match Specifies what to do when the request: contains wildcard expressions and there are no transforms that match; + # contains the +_all+ string or no identifiers and there are no matches; contains wildcard expressions and there + # are only partial matches.If it is true, the API returns a successful acknowledgement message when there are no matches. When there are + # only partial matches, the API stops the appropriate transforms.If it is false, the request returns a 404 status code when there are no matches or only partial matches. Server default: true. + # @option arguments [Boolean] :force If it is true, the API forcefully stops the transforms. + # @option arguments [Time] :timeout Period to wait for a response when +wait_for_completion+ is +true+. If no response is received before the + # timeout expires, the request returns a timeout exception. However, the request continues processing and + # eventually moves the transform to a STOPPED state. Server default: 30s. + # @option arguments [Boolean] :wait_for_checkpoint If it is true, the transform does not completely stop until the current checkpoint is completed. If it is false, + # the transform stops as soon as possible. + # @option arguments [Boolean] :wait_for_completion If it is true, the API blocks until the indexer state completely stops. If it is false, the API returns + # immediately and the indexer is stopped asynchronously in the background. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-stop-transform # def stop_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.stop_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id] arguments = arguments.clone @@ -45,11 +61,11 @@ def stop_transform(arguments = {}) _transform_id = arguments.delete(:transform_id) method = Elasticsearch::API::HTTP_POST - path = "_transform/#{Utils.__listify(_transform_id)}/_stop" + path = "_transform/#{Utils.listify(_transform_id)}/_stop" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/update_transform.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/update_transform.rb index f5b8e245c7..014ecda2aa 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/update_transform.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/update_transform.rb @@ -15,24 +15,40 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions + # Update a transform. # Updates certain properties of a transform. + # All updated properties except +description+ do not take effect until after the transform starts the next checkpoint, + # thus there is data consistency in each checkpoint. To use this API, you must have +read+ and +view_index_metadata+ + # privileges for the source indices. You must also have +index+ and +read+ privileges for the destination index. When + # Elasticsearch security features are enabled, the transform remembers which roles the user who updated it had at the + # time of update and runs with those privileges. # - # @option arguments [String] :transform_id The id of the transform. (*Required*) - # @option arguments [Boolean] :defer_validation If validations should be deferred until transform starts, defaults to false. - # @option arguments [Time] :timeout Controls the time to wait for the update + # @option arguments [String] :transform_id Identifier for the transform. (*Required*) + # @option arguments [Boolean] :defer_validation When true, deferrable validations are not run. This behavior may be + # desired if the source index does not exist until after the transform is + # created. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the + # timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The update transform definition (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-update-transform # def update_transform(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.update_transform' } + + defined_params = [:transform_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id] @@ -44,11 +60,11 @@ def update_transform(arguments = {}) _transform_id = arguments.delete(:transform_id) method = Elasticsearch::API::HTTP_POST - path = "_transform/#{Utils.__listify(_transform_id)}/_update" + path = "_transform/#{Utils.listify(_transform_id)}/_update" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/transform/upgrade_transforms.rb b/elasticsearch-api/lib/elasticsearch/api/actions/transform/upgrade_transforms.rb index 22bf4c0353..0a3717e86b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/transform/upgrade_transforms.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/transform/upgrade_transforms.rb @@ -15,33 +15,47 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Transform module Actions - # Upgrades all transforms. + # Upgrade all transforms. + # Transforms are compatible across minor versions and between supported major versions. + # However, over time, the format of transform configuration information may change. + # This API identifies transforms that have a legacy configuration format and upgrades them to the latest version. + # It also cleans up the internal data structures that store the transform state and checkpoints. + # The upgrade does not affect the source and destination indices. + # The upgrade also does not affect the roles that transforms use when Elasticsearch security features are enabled; the role used to read source data and write to the destination index remains unchanged. + # If a transform upgrade step fails, the upgrade stops and an error is returned about the underlying issue. + # Resolve the issue then re-run the process again. + # A summary is returned when the upgrade is finished. + # To ensure continuous transforms remain running during a major version upgrade of the cluster – for example, from 7.16 to 8.0 – it is recommended to upgrade transforms before upgrading the cluster. + # You may want to perform a recent cluster backup prior to the upgrade. # - # @option arguments [Boolean] :dry_run Whether to only check for updates but don't execute - # @option arguments [Time] :timeout Controls the time to wait for the upgrade + # @option arguments [Boolean] :dry_run When true, the request checks for updates but does not run them. + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and + # returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/upgrade-transforms.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-upgrade-transforms # def upgrade_transforms(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'transform.upgrade_transforms' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_transform/_upgrade" + path = '_transform/_upgrade' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/update.rb b/elasticsearch-api/lib/elasticsearch/api/actions/update.rb index 93cdb4b992..cd71f18ea4 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/update.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/update.rb @@ -15,34 +15,62 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Updates a document with a script or partial document. + # Update a document. + # Update a document by running a script or passing a partial document. + # If the Elasticsearch security features are enabled, you must have the +index+ or +write+ index privilege for the target index or index alias. + # The script can update, delete, or skip modifying the document. + # The API also supports passing a partial document, which is merged into the existing document. + # To fully replace an existing document, use the index API. + # This operation: + # * Gets the document (collocated with the shard) from the index. + # * Runs the specified script. + # * Indexes the result. + # The document must still be reindexed, but using this API removes some network roundtrips and reduces chances of version conflicts between the GET and the index operation. + # The +_source+ field must be enabled to use this API. + # In addition to +_source+, you can access the following variables through the +ctx+ map: +_index+, +_type+, +_id+, +_version+, +_routing+, and +_now+ (the current timestamp). # - # @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 [String] :id A unique identifier for the document to be updated. (*Required*) + # @option arguments [String] :index The name of the target index. + # By default, the index is created automatically if it doesn't exist. (*Required*) + # @option arguments [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option arguments [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option arguments [Boolean] :include_source_on_error True or false if to include the document source in the error message in case of parsing errors. Server default: true. + # @option arguments [String] :lang The script language. Server default: painless. + # @option arguments [String] :refresh If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search. + # If 'wait_for', it waits for a refresh to make this operation visible to search. + # If 'false', it does nothing with refreshes. Server default: false. + # @option arguments [Boolean] :require_alias If +true+, the destination must be an index alias. + # @option arguments [Integer] :retry_on_conflict The number of times the operation should be retried when a conflict occurs. Server default: 0. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Time] :timeout The period to wait for the following operations: dynamic mapping updates and waiting for active shards. + # Elasticsearch waits for at least the timeout period before failing. + # The actual wait time could be longer, particularly when multiple waits occur. Server default: 1m. + # @option arguments [Integer, String] :wait_for_active_shards The number of copies of each shard 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). + # The default value of +1+ means it waits for each primary shard to be active. Server default: 1. + # @option arguments [Boolean, String, Array] :_source If +false+, source retrieval is turned off. + # You can also specify a comma-separated list of the fields you want to retrieve. Server default: true. + # @option arguments [String, Array] :_source_excludes The source fields you want to exclude. + # @option arguments [String, Array] :_source_includes The source fields you want to retrieve. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The request definition requires either `script` or partial `doc` (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-update # def update(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'update' } + + defined_params = [:index, :id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + 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] @@ -57,18 +85,18 @@ def update(arguments = {}) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}" + path = "#{Utils.listify(_index)}/_update/#{Utils.listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb index 54d1d63102..0abbf268ca 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb @@ -15,68 +15,166 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch 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. + # Update documents. + # Updates documents that match the specified query. + # If no query is specified, performs an update on every document in the data stream or index without modifying the source, which is useful for picking up mapping changes. + # If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias: + # * +read+ + # * +index+ or +write+ + # You can specify the query criteria in the request URI or the request body using the same syntax as the search API. + # When you submit an update by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and updates matching documents using internal versioning. + # When the versions match, the document is updated and the version number is incremented. + # If a document changes between the time that the snapshot is taken and the update operation is processed, it results in a version conflict and the operation fails. + # You can opt to count version conflicts instead of halting and returning by setting +conflicts+ to +proceed+. + # Note that if you opt to count version conflicts, the operation could attempt to update more documents from the source than +max_docs+ until it has successfully updated +max_docs+ documents or it has gone through every document in the source query. + # NOTE: Documents with a version equal to 0 cannot be updated using update by query because internal versioning does not support 0 as a valid version number. + # While processing an update by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents. + # A bulk update request is performed for each batch of matching documents. + # Any query or update failures cause the update by query request to fail and the failures are shown in the response. + # Any update requests that completed successfully still stick, they are not rolled back. + # **Throttling update requests** + # To control the rate at which update by query issues batches of update operations, you can set +requests_per_second+ to any positive decimal number. + # This pads each batch with a wait time to throttle the rate. + # Set +requests_per_second+ to +-1+ to turn off throttling. + # Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account. + # The padding time is the difference between the batch size divided by the +requests_per_second+ and the time spent writing. + # By default the batch size is 1000, so if +requests_per_second+ is set to +500+: + # + + # target_time = 1000 / 500 per second = 2 seconds + # wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds + # + + # Since the batch is issued as a single _bulk request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set. + # This is "bursty" instead of "smooth". + # **Slicing** + # Update by query supports sliced scroll to parallelize the update process. + # This can improve efficiency and provide a convenient way to break the request down into smaller parts. + # Setting +slices+ to +auto+ chooses a reasonable number for most data streams and indices. + # This setting will use one slice per shard, up to a certain limit. + # If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards. + # Adding +slices+ to +_update_by_query+ just automates the manual process of creating sub-requests, which means it has some quirks: + # * You can see these requests in the tasks APIs. These sub-requests are "child" tasks of the task for the request with slices. + # * Fetching the status of the task for the request with +slices+ only contains the status of completed slices. + # * These sub-requests are individually addressable for things like cancellation and rethrottling. + # * Rethrottling the request with +slices+ will rethrottle the unfinished sub-request proportionally. + # * Canceling the request with slices will cancel each sub-request. + # * Due to the nature of slices each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution. + # * Parameters like +requests_per_second+ and +max_docs+ on a request with slices are distributed proportionally to each sub-request. Combine that with the point above about distribution being uneven and you should conclude that using +max_docs+ with +slices+ might not result in exactly +max_docs+ documents being updated. + # * Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time. + # If you're slicing manually or otherwise tuning automatic slicing, keep in mind that: + # * Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many slices hurts performance. Setting slices higher than the number of shards generally does not improve efficiency and adds overhead. + # * Update performance scales linearly across available resources with the number of slices. + # Whether query or update performance dominates the runtime depends on the documents being reindexed and cluster resources. + # **Update the document source** + # Update by query supports scripts to update the document source. + # As with the update API, you can set +ctx.op+ to change the operation that is performed. + # Set +ctx.op = "noop"+ if your script decides that it doesn't have to make any changes. + # The update by query operation skips updating the document and increments the +noop+ counter. + # Set +ctx.op = "delete"+ if your script decides that the document should be deleted. + # The update by query operation deletes the document and increments the +deleted+ counter. + # Update by query supports only +index+, +noop+, and +delete+. + # Setting +ctx.op+ to anything else is an error. + # Setting any other field in +ctx+ is an error. + # This API enables you to only modify the source of matching documents; you cannot move them. # - # @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 [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] :max_docs Maximum number of documents to process (default: all documents) - # @option arguments [List] :sort A comma-separated list of : pairs - # @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 [String, Array] :index A comma-separated list of data streams, indices, and aliases to search. + # It supports wildcards (+*+). + # To search all data streams or indices, omit this parameter or use +*+ or +_all+. (*Required*) + # @option arguments [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 indices. + # This behavior applies even if the request targets other open indices. + # For example, a request targeting +foo*,bar*+ returns an error if an index starts with +foo+ but no index starts with +bar+. Server default: true. + # @option arguments [String] :analyzer The analyzer to use for the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [Boolean] :analyze_wildcard If +true+, wildcard and prefix queries are analyzed. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [String] :conflicts The preferred behavior when update by query hits version conflicts: +abort+ or +proceed+. Server default: abort. + # @option arguments [String] :default_operator The default operator for query string query: +AND+ or +OR+. + # This parameter can be used only when the +q+ query string parameter is specified. Server default: OR. + # @option arguments [String] :df The field to use as default where no field prefix is given in the query string. + # This parameter can be used only when the +q+ query string parameter is specified. + # @option arguments [String, Array] :expand_wildcards The 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. + # It supports comma-separated values, such as +open,hidden+. + # Valid values are: +all+, +open+, +closed+, +hidden+, +none+. + # @option arguments [Integer] :from Skips the specified number of documents. Server default: 0. + # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. + # @option arguments [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 be used only when the +q+ query string parameter is specified. + # @option arguments [Integer] :max_docs The maximum number of documents to process. + # It defaults to all documents. + # When set to a value less then or equal to +scroll_size+ then a scroll will not be used to retrieve the results for the operation. + # @option arguments [String] :pipeline The 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 arguments [String] :preference The node or shard the operation should be performed on. + # It is random by default. + # @option arguments [String] :q A query in the Lucene query string syntax. + # @option arguments [Boolean] :refresh If +true+, Elasticsearch refreshes affected shards to make the operation visible to search after the request completes. + # This is different than the update API's +refresh+ parameter, which causes just the shard that received the request to be refreshed. + # @option arguments [Boolean] :request_cache If +true+, the request cache is used for this request. + # It defaults to the index-level setting. + # @option arguments [Float] :requests_per_second The throttle for this request in sub-requests per second. Server default: -1. + # @option arguments [String] :routing A custom value used to route operations to a specific shard. + # @option arguments [Time] :scroll The period to retain the search context for scrolling. Server default: 5m. + # @option arguments [Integer] :scroll_size The size of the scroll request that powers the operation. Server default: 1000. + # @option arguments [Time] :search_timeout An explicit timeout for each search request. + # By default, there is no timeout. + # @option arguments [String] :search_type The type of the search operation. Available options include +query_then_fetch+ and +dfs_query_then_fetch+. + # @option arguments [Integer, String] :slices The number of slices this task should be divided into. Server default: 1. + # @option arguments [Array] :sort A comma-separated list of : pairs. + # @option arguments [Array] :stats The specific +tag+ of the request for logging and statistical purposes. + # @option arguments [Integer] :terminate_after The maximum number of documents to collect for each shard. + # If a query reaches this limit, Elasticsearch terminates the query early. + # Elasticsearch collects documents before sorting.IMPORTANT: Use with caution. + # Elasticsearch applies this parameter to each shard handling the request. + # When possible, let Elasticsearch perform early termination automatically. + # Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + # @option arguments [Time] :timeout The period each update request waits for the following operations: dynamic mapping updates, waiting for active shards. + # By default, it is one minute. + # This guarantees Elasticsearch waits for at least the timeout before failing. + # The actual wait time could be longer, particularly when multiple waits occur. Server default: 1m. + # @option arguments [Boolean] :version If +true+, returns the 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 [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+). + # The +timeout+ parameter controls how long each write request waits for unavailable shards to become available. + # Both work exactly the way they work in the bulk API. Server default: 1. + # @option arguments [Boolean] :wait_for_completion If +true+, the request blocks until the operation is complete. + # If +false+, Elasticsearch performs some preflight checks, launches the request, and returns a task ID that you can use to cancel or get the status of the task. + # Elasticsearch creates a record of this task as a document at +.tasks/task/${taskId}+. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The search definition using the Query DSL + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-update-by-query # def update_by_query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'update_by_query' } + + defined_params = [:index].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) _index = arguments.delete(:index) method = Elasticsearch::API::HTTP_POST - path = "#{Utils.__listify(_index)}/_update_by_query" + path = "#{Utils.listify(_index)}/_update_by_query" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb index b34ecd28b4..d01810fb44 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb @@ -15,21 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Actions - # Changes the number of requests per second for a particular Update By Query operation. + # Throttle an update by query operation. + # Change the number of requests per second for a particular update by query operation. + # Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts. # - # @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 [String] :task_id The ID for the task. (*Required*) + # @option arguments [Float] :requests_per_second The throttle for this request in sub-requests per second. + # To turn off throttling, set it to +-1+. Server default: -1. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-update-by-query-rethrottle # def update_by_query_rethrottle(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'update_by_query_rethrottle' } + + defined_params = [:task_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone @@ -40,11 +50,11 @@ def update_by_query_rethrottle(arguments = {}) _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST - path = "_update_by_query/#{Utils.__listify(_task_id)}/_rethrottle" + path = "_update_by_query/#{Utils.listify(_task_id)}/_rethrottle" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/ack_watch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/ack_watch.rb index 985ca3db1d..0597aa10d2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/ack_watch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/ack_watch.rb @@ -15,22 +15,36 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Acknowledges a watch, manually throttling the execution of the watch's actions. + # Acknowledge a watch. + # Acknowledging a watch enables you to manually throttle the execution of the watch's actions. + # The acknowledgement state of an action is stored in the +status.actions..ack.state+ structure. + # IMPORTANT: If the specified watch is currently being executed, this API will return an error + # The reason for this behavior is to prevent overwriting the watch status from a watch execution. + # Acknowledging an action throttles further executions of that action until its +ack.state+ is reset to +awaits_successful_execution+. + # This happens when the condition of the watch is not met (the condition evaluates to false). # - # @option arguments [String] :watch_id Watch ID - # @option arguments [List] :action_id A comma-separated list of the action ids to be acked + # @option arguments [String] :watch_id The watch identifier. (*Required*) + # @option arguments [String, Array] :action_id A comma-separated list of the action identifiers to acknowledge. + # If you omit this parameter, all of the actions of the watch are acknowledged. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-ack-watch # def ack_watch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.ack_watch' } + + defined_params = [:watch_id, :action_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id] arguments = arguments.clone @@ -44,14 +58,14 @@ def ack_watch(arguments = {}) method = Elasticsearch::API::HTTP_PUT path = if _watch_id && _action_id - "_watcher/watch/#{Utils.__listify(_watch_id)}/_ack/#{Utils.__listify(_action_id)}" + "_watcher/watch/#{Utils.listify(_watch_id)}/_ack/#{Utils.listify(_action_id)}" else - "_watcher/watch/#{Utils.__listify(_watch_id)}/_ack" + "_watcher/watch/#{Utils.listify(_watch_id)}/_ack" end params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/activate_watch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/activate_watch.rb index c973d60dac..4bd6603310 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/activate_watch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/activate_watch.rb @@ -15,21 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Activates a currently inactive watch. + # Activate a watch. + # A watch can be either active or inactive. # - # @option arguments [String] :watch_id Watch ID + # @option arguments [String] :watch_id The watch identifier. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-activate-watch # def activate_watch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.activate_watch' } + + defined_params = [:watch_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id] arguments = arguments.clone @@ -40,11 +48,11 @@ def activate_watch(arguments = {}) _watch_id = arguments.delete(:watch_id) method = Elasticsearch::API::HTTP_PUT - path = "_watcher/watch/#{Utils.__listify(_watch_id)}/_activate" + path = "_watcher/watch/#{Utils.listify(_watch_id)}/_activate" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/deactivate_watch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/deactivate_watch.rb index 25cbeabd9d..c2c80414fb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/deactivate_watch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/deactivate_watch.rb @@ -15,21 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Deactivates a currently active watch. + # Deactivate a watch. + # A watch can be either active or inactive. # - # @option arguments [String] :watch_id Watch ID + # @option arguments [String] :watch_id The watch identifier. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-deactivate-watch # def deactivate_watch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.deactivate_watch' } + + defined_params = [:watch_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'watch_id' missing" unless arguments[:watch_id] arguments = arguments.clone @@ -40,11 +48,11 @@ def deactivate_watch(arguments = {}) _watch_id = arguments.delete(:watch_id) method = Elasticsearch::API::HTTP_PUT - path = "_watcher/watch/#{Utils.__listify(_watch_id)}/_deactivate" + path = "_watcher/watch/#{Utils.listify(_watch_id)}/_deactivate" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/delete_watch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/delete_watch.rb index 46a19f167b..e30f3324cd 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/delete_watch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/delete_watch.rb @@ -15,21 +15,33 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Removes a watch from Watcher. + # Delete a watch. + # When the watch is removed, the document representing the watch in the +.watches+ index is gone and it will never be run again. + # Deleting a watch does not delete any watch execution records related to this watch from the watch history. + # IMPORTANT: Deleting a watch must be done by using only this API. + # Do not delete the watch directly from the +.watches+ index using the Elasticsearch delete document API + # When Elasticsearch security features are enabled, make sure no write privileges are granted to anyone for the +.watches+ index. # - # @option arguments [String] :id Watch ID + # @option arguments [String] :id The watch identifier. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-delete-watch # def delete_watch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.delete_watch' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,18 +52,18 @@ def delete_watch(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_DELETE - path = "_watcher/watch/#{Utils.__listify(_id)}" + path = "_watcher/watch/#{Utils.listify(_id)}" params = Utils.process_params(arguments) if Array(arguments[:ignore]).include?(404) - Utils.__rescue_from_not_found { + Utils.rescue_from_not_found do Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) - } + end else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/execute_watch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/execute_watch.rb index d0bf8b1c26..d24e74b3a5 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/execute_watch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/execute_watch.rb @@ -15,23 +15,39 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Forces the execution of a stored watch. + # Run a watch. + # This API can be used to force execution of the watch outside of its triggering logic or to simulate the watch execution for debugging purposes. + # For testing and debugging purposes, you also have fine-grained control on how the watch runs. + # You can run the watch without running all of its actions or alternatively by simulating them. + # You can also force execution by ignoring the watch condition and control whether a watch record would be written to the watch history after it runs. + # You can use the run watch API to run watches that are not yet registered by specifying the watch definition inline. + # This serves as great tool for testing and debugging your watches prior to adding them to Watcher. + # When Elasticsearch security features are enabled on your cluster, watches are run with the privileges of the user that stored the watches. + # If your user is allowed to read index +a+, but not index +b+, then the exact same set of rules will apply during execution of a watch. + # When using the run watch API, the authorization data of the user that called the API will be used as a base, instead of the information who stored the watch. # - # @option arguments [String] :id Watch ID - # @option arguments [Boolean] :debug indicates whether the watch should execute in debug mode + # @option arguments [String] :id The watch identifier. + # @option arguments [Boolean] :debug Defines whether the watch runs in debug mode. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body Execution control + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-execute-watch # def execute_watch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.execute_watch' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -41,14 +57,14 @@ def execute_watch(arguments = {}) method = Elasticsearch::API::HTTP_PUT path = if _id - "_watcher/watch/#{Utils.__listify(_id)}/_execute" + "_watcher/watch/#{Utils.listify(_id)}/_execute" else - "_watcher/watch/_execute" + '_watcher/watch/_execute' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/get_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/get_settings.rb index 565a6b8840..4ff78f573a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/get_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/get_settings.rb @@ -15,31 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Retrieve settings for the watcher system index + # Get Watcher index settings. + # Get settings for the Watcher internal index (+.watches+). + # Only a subset of settings are shown, for example +index.auto_expand_replicas+ and +index.number_of_replicas+. # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-settings.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-get-settings # def get_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.get_settings' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_watcher/settings" - params = {} + path = '_watcher/settings' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/get_watch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/get_watch.rb index f6d28bea93..56a5c74dd1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/get_watch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/get_watch.rb @@ -15,21 +15,28 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Retrieves a watch by its ID. + # Get a watch. # - # @option arguments [String] :id Watch ID + # @option arguments [String] :id The watch identifier. (*Required*) # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-get-watch # def get_watch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.get_watch' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -40,11 +47,11 @@ def get_watch(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_GET - path = "_watcher/watch/#{Utils.__listify(_id)}" + path = "_watcher/watch/#{Utils.listify(_id)}" params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/put_watch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/put_watch.rb index a582e0016e..a33053d7d8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/put_watch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/put_watch.rb @@ -15,26 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Creates a new watch, or updates an existing one. + # Create or update a watch. + # When a watch is registered, a new document that represents the watch is added to the +.watches+ index and its trigger is immediately registered with the relevant trigger engine. + # Typically for the +schedule+ trigger, the scheduler is the trigger engine. + # IMPORTANT: You must use Kibana or this API to create a watch. + # Do not add a watch directly to the +.watches+ index by using the Elasticsearch index API. + # If Elasticsearch security features are enabled, do not give users write privileges on the +.watches+ index. + # When you add a watch you can also define its initial active state by setting the *active* parameter. + # When Elasticsearch security features are enabled, your watch can index or search only on indices for which the user that stored the watch has privileges. + # If the user is able to read index +a+, but not index +b+, the same will apply when the watch runs. # - # @option arguments [String] :id Watch ID - # @option arguments [Boolean] :active Specify whether the watch is in/active by default - # @option arguments [Number] :version Explicit version number for concurrency control - # @option arguments [Number] :if_seq_no only update the watch if the last operation that has changed the watch has the specified sequence number - # @option arguments [Number] :if_primary_term only update the watch if the last operation that has changed the watch has the specified primary term + # @option arguments [String] :id The identifier for the watch. (*Required*) + # @option arguments [Boolean] :active The initial state of the watch. + # The default value is +true+, which means the watch is active by default. Server default: true. + # @option arguments [Integer] :if_primary_term only update the watch if the last operation that has changed the watch has the specified primary term + # @option arguments [Integer] :if_seq_no only update the watch if the last operation that has changed the watch has the specified sequence number + # @option arguments [Integer] :version Explicit version number for concurrency control # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body The watch + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-put-watch # def put_watch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.put_watch' } + + defined_params = [:id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] arguments = arguments.clone @@ -45,11 +61,11 @@ def put_watch(arguments = {}) _id = arguments.delete(:id) method = Elasticsearch::API::HTTP_PUT - path = "_watcher/watch/#{Utils.__listify(_id)}" + path = "_watcher/watch/#{Utils.listify(_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/query_watches.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/query_watches.rb index 5a952ca40a..144bbbb326 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/query_watches.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/query_watches.rb @@ -15,25 +15,29 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Retrieves stored watches. + # Query watches. + # Get all registered watches in a paginated manner and optionally filter watches by a query. + # Note that only the +_id+ and +metadata.*+ fields are queryable or sortable. # # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body From, size, query, sort and search_after + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-query-watches.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-query-watches # def query_watches(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.query_watches' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = if body Elasticsearch::API::HTTP_POST @@ -41,11 +45,11 @@ def query_watches(arguments = {}) Elasticsearch::API::HTTP_GET end - path = "_watcher/_query/watches" + path = '_watcher/_query/watches' params = {} Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/start.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/start.rb index fa71261a8a..127a4b17c7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/start.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/start.rb @@ -15,31 +15,35 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Starts Watcher if it is not already running. + # Start the watch service. + # Start the Watcher service if it is not already running. # + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-start # def start(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.start' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_watcher/_start" - params = {} + path = '_watcher/_start' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/stats.rb index cea1d31c91..b9472aa98f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/stats.rb @@ -15,22 +15,31 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Retrieves the current Watcher metrics. + # Get Watcher statistics. + # This API always returns basic metrics. + # You retrieve more metrics by using the metric parameter. # - # @option arguments [List] :metric Controls what additional stat metrics should be include in the response (options: _all, queued_watches, current_watches, pending_watches) - # @option arguments [Boolean] :emit_stacktraces Emits stack traces of currently running watches + # @option arguments [Watchermetric] :metric Defines which additional metrics are included in the response. + # @option arguments [Boolean] :emit_stacktraces Defines whether stack traces are generated for each watch that is running. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-stats # def stats(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.stats' } + + defined_params = [:metric].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -40,14 +49,14 @@ def stats(arguments = {}) method = Elasticsearch::API::HTTP_GET path = if _metric - "_watcher/stats/#{Utils.__listify(_metric)}" + "_watcher/stats/#{Utils.listify(_metric)}" else - "_watcher/stats" + '_watcher/stats' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/stop.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/stop.rb index 5d2394caf4..915ff2b7ac 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/stop.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/stop.rb @@ -15,31 +15,37 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Stops Watcher if it is running. + # Stop the watch service. + # Stop the Watcher service if it is running. # + # @option arguments [Time] :master_timeout The period to wait for the master node. + # If the master node is not available before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-stop # def stop(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.stop' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_POST - path = "_watcher/_stop" - params = {} + path = '_watcher/_stop' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/update_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/update_settings.rb index 6e4c27c223..bd205d873b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/update_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/update_settings.rb @@ -15,34 +15,46 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module Watcher module Actions - # Update settings for the watcher system index + # Update Watcher index settings. + # Update settings for the Watcher internal index (+.watches+). + # Only a subset of settings can be modified. + # This includes +index.auto_expand_replicas+, +index.number_of_replicas+, +index.routing.allocation.exclude.*+, + # +index.routing.allocation.include.*+ and +index.routing.allocation.require.*+. + # Modification of +index.routing.allocation.include._tier_preference+ is an exception and is not allowed as the + # Watcher shards must always be in the +data_content+ tier. # + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # @option arguments [Time] :timeout The period to wait for a response. + # If no response is received before the timeout expires, the request fails and returns an error. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body An object with the new index settings (*Required*) + # @option arguments [Hash] :body request body # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-update-settings.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-watcher-update-settings # def update_settings(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'watcher.update_settings' } + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = arguments.delete(:body) + body = arguments.delete(:body) method = Elasticsearch::API::HTTP_PUT - path = "_watcher/settings" - params = {} + path = '_watcher/settings' + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/xpack/info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/xpack/info.rb index 6dc2b6e496..5cb6731ce8 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/xpack/info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/xpack/info.rb @@ -15,33 +15,42 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module XPack module Actions - # Retrieves information about the installed X-Pack features. + # Get information. + # The information provided by the API includes: + # * Build information including the build number and timestamp. + # * License information about the currently installed license. + # * Feature information for the features that are currently enabled and available under the current license. # - # @option arguments [List] :categories Comma-separated list of info categories. Can be any of: build, license, features - # @option arguments [Boolean] :accept_enterprise If this param is used it must be set to true *Deprecated* + # @option arguments [Array] :categories A comma-separated list of the information categories to include in the response. + # For example, +build,license,features+. + # @option arguments [Boolean] :accept_enterprise If this param is used it must be set to true + # @option arguments [Boolean] :human Defines whether additional human-readable information is included in the response. + # In particular, it adds descriptions and a tag line. Server default: true. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-info # def info(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'xpack.info' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_xpack" + path = '_xpack' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/xpack/usage.rb b/elasticsearch-api/lib/elasticsearch/api/actions/xpack/usage.rb index b15346c02a..d0224f2472 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/xpack/usage.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/xpack/usage.rb @@ -15,32 +15,38 @@ # specific language governing permissions and limitations # under the License. # -# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80 -# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec -# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. module Elasticsearch module API module XPack module Actions - # Retrieves usage information about the installed X-Pack features. + # Get usage information. + # Get information about the features that are currently enabled and available under the current license. + # The API also provides some usage statistics. # - # @option arguments [Time] :master_timeout Specify timeout for watch write operation + # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. + # If no response is received before the timeout expires, the request fails and returns an error. + # To indicate that the request should never timeout, set it to +-1+. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/usage-api.html + # @see https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-xpack # def usage(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'xpack.usage' } + arguments = arguments.clone headers = arguments.delete(:headers) || {} - body = nil + body = nil method = Elasticsearch::API::HTTP_GET - path = "_xpack/usage" + path = '_xpack/usage' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/async_search.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/async_search.rb deleted file mode 100644 index af5f5eafc6..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/async_search.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module AsyncSearch - module Actions; end - - # Client for the "async_search" namespace (includes the {AsyncSearch::Actions} methods) - # - class AsyncSearchClient - include Common::Client, Common::Client::Base, AsyncSearch::Actions - end - - # Proxy method for {AsyncSearchClient}, available in the receiving object - # - def async_search - @async_search ||= AsyncSearchClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/autoscaling.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/autoscaling.rb deleted file mode 100644 index 0ded4d5e42..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/autoscaling.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Autoscaling - module Actions; end - - # Client for the "autoscaling" namespace (includes the {Autoscaling::Actions} methods) - # - class AutoscalingClient - include Common::Client, Common::Client::Base, Autoscaling::Actions - end - - # Proxy method for {AutoscalingClient}, available in the receiving object - # - def autoscaling - @autoscaling ||= AutoscalingClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/cat.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/cat.rb deleted file mode 100644 index ba3952e3bd..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/cat.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Cat - module Actions; end - - # Client for the "cat" namespace (includes the {Cat::Actions} methods) - # - class CatClient - include Common::Client, Common::Client::Base, Cat::Actions - end - - # Proxy method for {CatClient}, available in the receiving object - # - def cat - @cat ||= CatClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/cluster.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/cluster.rb deleted file mode 100644 index e2eb15f707..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/cluster.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Cluster - module Actions; end - - # Client for the "cluster" namespace (includes the {Cluster::Actions} methods) - # - class ClusterClient - include Common::Client, Common::Client::Base, Cluster::Actions - end - - # Proxy method for {ClusterClient}, available in the receiving object - # - def cluster - @cluster ||= ClusterClient.new(self) - end - - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/common.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/common.rb deleted file mode 100644 index 06cac3f73a..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/common.rb +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - 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 - end - - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/cross_cluster_replication.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/cross_cluster_replication.rb deleted file mode 100644 index d9cb230653..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/cross_cluster_replication.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module CrossClusterReplication - module Actions; end - - # Client for the "cross_cluster_replication" namespace (includes the {CrossClusterReplication::Actions} methods) - # - class CrossClusterReplicationClient - include Common::Client, Common::Client::Base, CrossClusterReplication::Actions - end - - # Proxy method for {CrossClusterReplicationClient}, available in the receiving object - # - def cross_cluster_replication - @cross_cluster_replication ||= CrossClusterReplicationClient.new(self) - end - - alias ccr cross_cluster_replication - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/dangling_indices.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/dangling_indices.rb deleted file mode 100644 index 76291aaede..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/dangling_indices.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module DanglingIndices - module Actions; end - # Client for the "dangling_indices" namespace (includes the {DanglingIndices::Actions} methods) - # - class DanglingIndicesClient - include Common::Client, Common::Client::Base, DanglingIndices::Actions - 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/elasticsearch-api/lib/elasticsearch/api/namespace/data_frame_transform_deprecated.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/data_frame_transform_deprecated.rb deleted file mode 100644 index 8487199af4..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/data_frame_transform_deprecated.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module DataFrameTransformDeprecated - module Actions; end - - # Client for the "data_frame_transform_deprecated" namespace (includes the {DataFrameTransformDeprecated::Actions} methods) - # - class DataFrameTransformDeprecatedClient - include Common::Client, Common::Client::Base, DataFrameTransformDeprecated::Actions - end - - # Proxy method for {DataFrameTransformDeprecatedClient}, available in the receiving object - # - def data_frame_transform_deprecated - @data_frame_transform_deprecated ||= DataFrameTransformDeprecatedClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/enrich.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/enrich.rb deleted file mode 100644 index d591cc99ac..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/enrich.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Enrich - module Actions; end - - # Client for the "enrich" namespace (includes the {Enrich::Actions} methods) - # - class EnrichClient - include Common::Client, Common::Client::Base, Enrich::Actions - end - - # Proxy method for {EnrichClient}, available in the receiving object - # - def enrich - @enrich ||= EnrichClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/eql.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/eql.rb deleted file mode 100644 index 38c9f891e2..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/eql.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Eql - module Actions; end - - # Client for the "eql" namespace (includes the {Eql::Actions} methods) - # - class EqlClient - include Common::Client, Common::Client::Base, Eql::Actions - end - - # Proxy method for {EqlClient}, available in the receiving object - # - def eql - @eql ||= EqlClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/features.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/features.rb deleted file mode 100644 index 8b968f167e..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/features.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Features - module Actions; end - - # Client for the "features" namespace (includes the {Features::Actions} methods) - # - class FeaturesClient - include Common::Client, Common::Client::Base, Features::Actions - end - - # Proxy method for {FeaturesClient}, available in the receiving object - # - def features - @features ||= FeaturesClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/fleet.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/fleet.rb deleted file mode 100644 index 81f8cc369e..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/fleet.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Fleet - module Actions; end - - # Client for the "fleet" namespace (includes the {Fleet::Actions} methods) - # - class FleetClient - include Common::Client, Common::Client::Base, Fleet::Actions - end - - # Proxy method for {FleetClient}, available in the receiving object - # - def fleet - @fleet ||= FleetClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/graph.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/graph.rb deleted file mode 100644 index 04fd1d08a5..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/graph.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Graph - module Actions; end - - # Client for the "graph" namespace (includes the {Graph::Actions} methods) - # - class GraphClient - include Common::Client, Common::Client::Base, Graph::Actions - end - - # Proxy method for {GraphClient}, available in the receiving object - # - def graph - @graph ||= GraphClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/index_lifecycle_management.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/index_lifecycle_management.rb deleted file mode 100644 index 23077edeb3..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/index_lifecycle_management.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module IndexLifecycleManagement - module Actions; end - - # Client for the "index_lifecycle_management" namespace (includes the {IndexLifecycleManagement::Actions} methods) - # - class IndexLifecycleManagementClient - include Common::Client, Common::Client::Base, IndexLifecycleManagement::Actions - end - - # Proxy method for {IndexLifecycleManagementClient}, available in the receiving object - # - def ilm - @ilm ||= IndexLifecycleManagementClient.new(self) - end - - alias index_lifecycle_management ilm - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/indices.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/indices.rb deleted file mode 100644 index 75a3c0f290..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/indices.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Indices - module Actions; end - - # Client for the "indices" namespace (includes the {Indices::Actions} methods) - # - class IndicesClient - include Common::Client, Common::Client::Base, Indices::Actions - end - - # Proxy method for {IndicesClient}, available in the receiving object - # - def indices - @indices ||= IndicesClient.new(self) - end - - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/ingest.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/ingest.rb deleted file mode 100644 index 6e5e57af1f..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/ingest.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Ingest - module Actions; end - - # Client for the "ingest" namespace (includes the {Ingest::Actions} methods) - # - class IngestClient - include Common::Client, Common::Client::Base, Ingest::Actions - end - - # Proxy method for {IngestClient}, available in the receiving object - # - def ingest - @ingest ||= IngestClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/license.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/license.rb deleted file mode 100644 index e6fbd83676..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/license.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module License - module Actions; end - - # Client for the "license" namespace (includes the {License::Actions} methods) - # - class LicenseClient - include Common::Client, Common::Client::Base, License::Actions - end - - # Proxy method for {LicenseClient}, available in the receiving object - # - def license - @license ||= LicenseClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/logstash.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/logstash.rb deleted file mode 100644 index 2a0dd34871..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/logstash.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Logstash - module Actions; end - - # Client for the "logstash" namespace (includes the {Logstash::Actions} methods) - # - class LogstashClient - include Common::Client, Common::Client::Base, Logstash::Actions - end - - # Proxy method for {LogstashClient}, available in the receiving object - # - def logstash - @logstash ||= LogstashClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/machine_learning.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/machine_learning.rb deleted file mode 100644 index 63ada11f03..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/machine_learning.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module MachineLearning - module Actions; end - - # Client for the "machine_learning" namespace (includes the {MachineLearning::Actions} methods) - # - class MachineLearningClient - include Common::Client, Common::Client::Base, MachineLearning::Actions - end - - # Proxy method for {MachineLearningClient}, available in the receiving object - # - def machine_learning - @machine_learning ||= MachineLearningClient.new(self) - end - - alias ml machine_learning - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/migration.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/migration.rb deleted file mode 100644 index 05685adf49..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/migration.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Migration - module Actions; end - - # Client for the "migration" namespace (includes the {Migration::Actions} methods) - # - class MigrationClient - include Common::Client, Common::Client::Base, Migration::Actions - end - - # Proxy method for {MigrationClient}, available in the receiving object - # - def migration - @migration ||= MigrationClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/monitoring.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/monitoring.rb deleted file mode 100644 index 4c0f9dc010..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/monitoring.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Monitoring - module Actions; end - - # Client for the "monitoring" namespace (includes the {Monitoring::Actions} methods) - # - class MonitoringClient - include Common::Client, Common::Client::Base, Monitoring::Actions - end - - # Proxy method for {MonitoringClient}, available in the receiving object - # - def monitoring - @monitoring ||= MonitoringClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/nodes.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/nodes.rb deleted file mode 100644 index e717db05b2..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/nodes.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Nodes - module Actions; end - - # Client for the "nodes" namespace (includes the {Nodes::Actions} methods) - # - class NodesClient - include Common::Client, Common::Client::Base, Nodes::Actions - end - - # Proxy method for {NodesClient}, available in the receiving object - # - def nodes - @nodes ||= NodesClient.new(self) - end - - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/query_ruleset.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/query_ruleset.rb deleted file mode 100644 index c77d50dbcc..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/query_ruleset.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module QueryRuleset - module Actions; end - - # Client for the "query_ruleset" namespace (includes the {QueryRuleset::Actions} methods) - # - class QueryRulesetClient - include Common::Client, Common::Client::Base, QueryRuleset::Actions - end - - # Proxy method for {QueryRulesetClient}, available in the receiving object - # - def query_ruleset - @query_ruleset ||= QueryRulesetClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/remote.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/remote.rb deleted file mode 100644 index bcf5e4265f..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/remote.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Remote - module Actions; end - - # Client for the "remote" namespace (includes the {Remote::Actions} methods) - # - class RemoteClient - include Common::Client, Common::Client::Base, Remote::Actions - end - - # Proxy method for {RemoteClient}, available in the receiving object - # - def remote - @remote ||= RemoteClient.new(self) - end - - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/rollup.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/rollup.rb deleted file mode 100644 index 1e0e4b1c8e..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/rollup.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Rollup - module Actions; end - - # Client for the "rollup" namespace (includes the {Rollup::Actions} methods) - # - class RollupClient - include Common::Client, Common::Client::Base, Rollup::Actions - end - - # Proxy method for {RollupClient}, available in the receiving object - # - def rollup - @rollup ||= RollupClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/search_application.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/search_application.rb deleted file mode 100644 index 962bf15b5e..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/search_application.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module SearchApplication - module Actions; end - - # Client for the "searchable_snapshots" namespace (includes the {SearchableSnapshots::Actions} methods) - # - class SearchApplicationClient - include Common::Client, Common::Client::Base, SearchApplication::Actions - end - - # Proxy method for {SearchApplicationClient}, available in the receiving object - # - def search_application - @search_application ||= SearchApplicationClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/searchable_snapshots.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/searchable_snapshots.rb deleted file mode 100644 index 0a2add26b5..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/searchable_snapshots.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module SearchableSnapshots - module Actions; end - - # Client for the "searchable_snapshots" namespace (includes the {SearchableSnapshots::Actions} methods) - # - class SearchableSnapshotsClient - include Common::Client, Common::Client::Base, SearchableSnapshots::Actions - end - - # Proxy method for {SearchableSnapshotsClient}, available in the receiving object - # - def searchable_snapshots - @searchable_snapshots ||= SearchableSnapshotsClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/security.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/security.rb deleted file mode 100644 index 61f9efba1f..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/security.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Security - module Actions; end - - # Client for the "security" namespace (includes the {Security::Actions} methods) - # - class SecurityClient - include Common::Client, Common::Client::Base, Security::Actions - end - - # Proxy method for {SecurityClient}, available in the receiving object - # - def security - @security ||= SecurityClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/shutdown.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/shutdown.rb deleted file mode 100644 index 0c6fbee48a..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/shutdown.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Shutdown - module Actions; end - - # Client for the "shutdown" namespace (includes the {Shutdown::Actions} methods) - # - class ShutdownClient - include Common::Client, Common::Client::Base, Shutdown::Actions - end - - # Proxy method for {ShutdownClient}, available in the receiving object - # - def shutdown - @shutdown ||= ShutdownClient.new(self) - end - - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/snapshot.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/snapshot.rb deleted file mode 100644 index 35853de862..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/snapshot.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Snapshot - module Actions; end - - # Client for the "snapshot" namespace (includes the {Snapshot::Actions} methods) - # - class SnapshotClient - include Common::Client, Common::Client::Base, Snapshot::Actions - end - - # Proxy method for {SnapshotClient}, available in the receiving object - # - def snapshot - @snapshot ||= SnapshotClient.new(self) - end - - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/snapshot_lifecycle_management.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/snapshot_lifecycle_management.rb deleted file mode 100644 index 29b74ac932..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/snapshot_lifecycle_management.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module SnapshotLifecycleManagement - module Actions; end - - # Client for the "snapshot_lifecycle_management" namespace (includes the {SnapshotLifecycleManagement::Actions} methods) - # - class SnapshotLifecycleManagementClient - include Common::Client, Common::Client::Base, SnapshotLifecycleManagement::Actions - end - - # Proxy method for {SnapshotLifecycleManagementClient}, available in the receiving object - # - def snapshot_lifecycle_management - @snapshot_lifecycle_management ||= SnapshotLifecycleManagementClient.new(self) - end - - alias slm snapshot_lifecycle_management - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/sql.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/sql.rb deleted file mode 100644 index f0a5c7939e..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/sql.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module SQL - module Actions; end - - # Client for the "sql" namespace (includes the {SQL::Actions} methods) - # - class SQLClient - include Common::Client, Common::Client::Base, SQL::Actions - end - - # Proxy method for {SQLClient}, available in the receiving object - # - def sql - @sql ||= SQLClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/ssl.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/ssl.rb deleted file mode 100644 index d298fce678..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/ssl.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module SSL - module Actions; end - - # Client for the "ssl" namespace (includes the {SSL::Actions} methods) - # - class SSLClient - include Common::Client, Common::Client::Base, SSL::Actions - end - - # Proxy method for {SSLClient}, available in the receiving object - # - def ssl - @ssl ||= SSLClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/synonym_rule.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/synonym_rule.rb deleted file mode 100644 index 4c672e4ae0..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/synonym_rule.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module SynonymRule - module Actions; end - - # Client for the "synonym_rule" namespace (includes the {SynonymRule::Actions} methods) - # - class SynonymRuleClient - include Common::Client, Common::Client::Base, SynonymRule::Actions - end - - # Proxy method for {SynonymRuleClient}, available in the receiving object - # - def synonym_rule - @synonym_rule ||= SynonymRuleClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/synonyms.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/synonyms.rb deleted file mode 100644 index 083a215203..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/synonyms.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Synonyms - module Actions; end - - # Client for the "synonyms" namespace (includes the {Synonyms::Actions} methods) - # - class SynonymsClient - include Common::Client, Common::Client::Base, Synonyms::Actions - end - - # Proxy method for {SynonymsClient}, available in the receiving object - # - def synonyms - @synonyms ||= SynonymsClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/synonyms_sets.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/synonyms_sets.rb deleted file mode 100644 index 1cecdec750..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/synonyms_sets.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module SynonymsSets - module Actions; end - - # Client for the "synonyms_sets" namespace (includes the {SynonymsSets::Actions} methods) - # - class SynonymsSetsClient - include Common::Client, Common::Client::Base, SynonymsSets::Actions - end - - # Proxy method for {SynonymsSetsClient}, available in the receiving object - # - def synonyms_sets - @synonyms_sets ||= SynonymsSetsClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/tasks.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/tasks.rb deleted file mode 100644 index 9c4809dce2..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/tasks.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Tasks - module Actions; end - - # Client for the "tasks" namespace (includes the {Tasks::Actions} methods) - # - class TasksClient - include Common::Client, Common::Client::Base, Tasks::Actions - end - - # Proxy method for {TasksClient}, available in the receiving object - # - def tasks - @tasks ||= TasksClient.new(self) - end - - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/text_structure.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/text_structure.rb deleted file mode 100644 index 0d1f5b7636..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/text_structure.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module TextStructure - module Actions; end - - # Client for the "text_structure" namespace (includes the {TextStructure::Actions} methods) - # - class TextStructureClient - include Common::Client, Common::Client::Base, TextStructure::Actions - end - - # Proxy method for {TextStructureClient}, available in the receiving object - # - def text_structure - @text_structure ||= TextStructureClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/transform.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/transform.rb deleted file mode 100644 index 0c9040adfb..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/transform.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Transform - module Actions; end - - # Client for the "transform" namespace (includes the {Transform::Actions} methods) - # - class TransformClient - include Common::Client, Common::Client::Base, Transform::Actions - end - - # Proxy method for {TransformClient}, available in the receiving object - # - def transform - @transform ||= TransformClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/watcher.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/watcher.rb deleted file mode 100644 index 554e401361..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/watcher.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module Watcher - module Actions; end - - # Client for the "watcher" namespace (includes the {Watcher::Actions} methods) - # - class WatcherClient - include Common::Client, Common::Client::Base, Watcher::Actions - end - - # Proxy method for {WatcherClient}, available in the receiving object - # - def watcher - @watcher ||= WatcherClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/xpack.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/xpack.rb deleted file mode 100644 index 74d8f9bb13..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/namespace/xpack.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module API - module XPack - module Actions; end - - # Client for the "xpack" namespace (includes the {XPack::Actions} methods) - # - class XPackClient - include Common::Client, Common::Client::Base, XPack::Actions - end - - # Proxy method for {XPackClient}, available in the receiving object - # - def xpack - @xpack ||= XPackClient.new(self) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/utils.rb b/elasticsearch-api/lib/elasticsearch/api/utils.rb index fc53cb1d49..128281a611 100644 --- a/elasticsearch-api/lib/elasticsearch/api/utils.rb +++ b/elasticsearch-api/lib/elasticsearch/api/utils.rb @@ -24,60 +24,62 @@ module Utils # URL-escape a string # # @example - # __escape('foo/bar') # => 'foo%2Fbar' - # __escape('bar^bam') # => 'bar%5Ebam' + # escape('foo/bar') # => 'foo%2Fbar' + # escape('bar^bam') # => 'bar%5Ebam' # # @api private - def __escape(string) + def escape(string) return string if string == '*' + ERB::Util.url_encode(string.to_s) 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' + # listify(['A','B']) # => 'A,B' # # @example Create a list from arguments - # __listify('A','B') # => 'A,B' + # listify('A','B') # => 'A,B' # # @example Escape values - # __listify('foo','bar^bam') # => 'foo,bar%5Ebam' + # listify('foo','bar^bam') # => 'foo,bar%5Ebam' # # @example Do not escape the values - # __listify('foo','bar^bam', escape: false) # => 'foo,bar^bam' + # listify('foo','bar^bam', escape: false) # => 'foo,bar^bam' # # @api private - def __listify(*list) + 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(',') + Array(list) + .flat_map { |e| e.respond_to?(:split) ? e.split(',') : e } + .flatten + .compact + .map { |e| escape == false ? e : escape(e) } + .join(',') 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' + # pathify(['foo', '', nil, 'bar']) # => 'foo/bar' # # @example Create a path from arguments - # __pathify('foo', '', nil, 'bar') # => 'foo/bar' + # pathify('foo', '', nil, 'bar') # => 'foo/bar' # # # @example Encode special characters - # __pathify(['foo', 'bar^bam']) # => 'foo/bar%5Ebam' + # 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('/') + def pathify(*segments) + Array(segments) + .flatten + .compact + .reject { |s| s.to_s.strip.empty? } + .join('/') + .squeeze('/') end # Convert an array of payloads into Elasticsearch `header\ndata` format @@ -86,7 +88,7 @@ def __pathify(*segments) # or the conveniency "combined" format where data is passed along with the header # in a single item. # - # Elasticsearch::API::Utils.__bulkify [ + # Elasticsearch::API::Utils.bulkify [ # { :index => { :_index => 'myindexA', :_type => 'mytype', :_id => '1', :data => { :title => 'Test' } } }, # { :update => { :_index => 'myindexB', :_type => 'mytype', :_id => '2', :data => { :doc => { :title => 'Update' } } } } # ] @@ -96,7 +98,7 @@ def __pathify(*segments) # # => {"update":{"_index":"myindexB","_type":"mytype","_id":"2"}} # # => {"doc":{"title":"Update"}} # - def __bulkify(payload) + def bulkify(payload) operations = %w[index create delete update] case @@ -131,7 +133,7 @@ def __bulkify(payload) def process_params(arguments) arguments = Hash[arguments] unless arguments.is_a?(Hash) - Hash[arguments.map { |k, v| v.is_a?(Array) ? [k, __listify(v, { escape: false })] : [k, v] }] # Listify Arrays + Hash[arguments.map { |k, v| v.is_a?(Array) ? [k, listify(v, { escape: false })] : [k, v] }] # Listify Arrays end # Extracts the valid parts of the URL from the arguments @@ -144,14 +146,14 @@ def process_params(arguments) # @return [Array] Valid parts of the URL as an array of strings # # @example Extract parts - # __extract_parts { :foo => true }, [:foo, :bar] + # extract_parts { :foo => true }, [:foo, :bar] # # => [:foo] # # # @api private # - def __extract_parts(arguments, valid_parts=[]) - Hash[arguments].reduce([]) { |sum, item| k, v = item; v.is_a?(TrueClass) ? sum << k.to_s : sum << v } + def extract_parts(arguments, _valid_parts = []) + Hash[arguments].reduce([]) { |sum, item| k, v = item; v.is_a?(TrueClass) ? sum << k.to_s : sum << v } end # Calls the given block, rescuing from `StandardError`. @@ -165,7 +167,7 @@ def __extract_parts(arguments, valid_parts=[]) # # @api private # - def __rescue_from_not_found(&block) + def rescue_from_not_found(&block) yield rescue StandardError => e if e.class.to_s =~ /NotFound/ || e.message =~ /Not\s*Found/i @@ -175,63 +177,6 @@ def __rescue_from_not_found(&block) end end - def __report_unsupported_parameters(arguments, params=[]) - messages = [] - unsupported_params = params.select {|d| d.is_a?(Hash) ? arguments.include?(d.keys.first) : arguments.include?(d) } - - 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: #{Elasticsearch::API::VERSION}, and will be removed in the next release." - end - - message = "[!] You are using unsupported parameter [:#{name}]" - - if source = caller && caller.last - message += " in `#{source}`" - end - - message += explanation - - messages << message - end - - unless 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 - end - - def __report_unsupported_method(name) - message = "[!] You are using unsupported method [#{name}]" - if source = caller && caller.last - message += " in `#{source}`" - end - - message += ". This method is not supported in the version you're using: #{Elasticsearch::API::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 diff --git a/elasticsearch-api/lib/elasticsearch/api/version.rb b/elasticsearch-api/lib/elasticsearch/api/version.rb index e26bcc3db3..e7be8dfb1a 100644 --- a/elasticsearch-api/lib/elasticsearch/api/version.rb +++ b/elasticsearch-api/lib/elasticsearch/api/version.rb @@ -17,6 +17,7 @@ module Elasticsearch module API - VERSION = '8.10.0'.freeze + VERSION = '9.0.0'.freeze + ES_SPECIFICATION_COMMIT = 'cd9c33775947086a99e6cf299b87733ba0111c28'.freeze end end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/count_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cat/count_spec.rb deleted file mode 100644 index e1c335032a..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/count_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/health_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cat/health_spec.rb deleted file mode 100644 index 32afd710f2..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/health_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/pending_tasks_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cat/pending_tasks_spec.rb deleted file mode 100644 index f61e07ba34..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/pending_tasks_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/recovery_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cat/recovery_spec.rb deleted file mode 100644 index c2b08ba799..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/recovery_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/segments_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cat/segments_spec.rb deleted file mode 100644 index f85fd7e623..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/segments_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/clear_scroll_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/clear_scroll_spec.rb deleted file mode 100644 index 9c4fb4c77a..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/clear_scroll_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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: ['abc123', 'def456'])).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/get_settings_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cluster/get_settings_spec.rb deleted file mode 100644 index 9bf2aca291..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/get_settings_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/health_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cluster/health_spec.rb deleted file mode 100644 index 3ce3b6160b..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/health_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/info_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cluster/info_spec.rb deleted file mode 100644 index 13d0124eb6..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/info_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.cluster#info' do - - let(:expected_args) do - [ - 'GET', - '_info/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.cluster.info(target: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/pending_tasks_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cluster/pending_tasks_spec.rb deleted file mode 100644 index c4e6017633..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/pending_tasks_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb deleted file mode 100644 index e4671204c3..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/stats_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/cluster/stats_spec.rb deleted file mode 100644 index b695f849eb..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/stats_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/count_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/count_spec.rb deleted file mode 100644 index 06508838f1..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/count_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#count' do - let(:expected_args) do - [ - 'GET', - '_count', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.count).to be_a Elasticsearch::API::Response - end - - context 'when an index and type are specified' do - let(:expected_args) do - [ - 'GET', - 'foo,bar/_count', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.count(index: ['foo','bar'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/create_document_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/create_document_spec.rb deleted file mode 100644 index 51a305e6fb..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/create_document_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end - - context 'when the request needs to be URL-escaped' do - - let(:expected_args) do - [ - 'PUT', - 'foo/_doc/123', - { op_type: 'create' }, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.create(index: 'foo', id: '123', body: {})).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/fleet/msearch_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/fleet/msearch_spec.rb deleted file mode 100644 index 2ac7177a9b..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/fleet/msearch_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#fleet.msearch' do - let(:expected_args) do - [ - 'POST', - '_fleet/_fleet_msearch', - {}, - {}, - { 'Content-Type' => 'application/x-ndjson' } - ] - end - - it 'performs the request' do - expect(client_double.fleet.msearch(body: {})).to be_a Elasticsearch::API::Response - end - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'requires the :body argument' do - expect { - client.fleet.msearch - }.to raise_exception(ArgumentError) - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/fleet/search_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/fleet/search_spec.rb deleted file mode 100644 index 45e0b8b4a3..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/fleet/search_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#fleet.search' do - let(:expected_args) do - [ - 'GET', - 'foo/_fleet/_fleet_search', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.fleet.search(index: 'foo')).to be_a Elasticsearch::API::Response - end - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'requires the :index argument' do - expect { - client.fleet.search - }.to raise_exception(ArgumentError) - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb deleted file mode 100644 index 580f7f6996..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +++ /dev/null @@ -1,80 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/clone_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/clone_spec.rb deleted file mode 100644 index 853f0810e2..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/clone_spec.rb +++ /dev/null @@ -1,122 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 Elasticsearch::API }.new - end - - it 'raises an exception' do - expect { - client.indices.clone(target: 'my_target_index') - }.to raise_exception(ArgumentError) - end - end - - context 'when there is no index specified' do - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'raises an exception' do - expect { - client.indices.clone(index: 'my_source_index') - }.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 be_a Elasticsearch::API::Response - end - end - - context 'when params are provided' do - - let(:params) do - { - timeout: '1s', - master_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', - master_timeout: '10s', - wait_for_active_shards: 1)).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/create_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/create_spec.rb deleted file mode 100644 index ea11591bc5..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/create_spec.rb +++ /dev/null @@ -1,85 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 Elasticsearch::API }.new - end - - it 'raises an exception' do - expect { - client.indices.create - }.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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_spec.rb deleted file mode 100644 index 9025baba79..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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: ['foo', 'bar'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end - - context 'when a NotFound exception is raised by the request' do - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - before do - expect(client).to receive(:perform_request).and_raise(NotFound) - end - - it 'raises the exception' do - expect { - client.indices.delete(index: 'foo') - }.to raise_exception(NotFound) - end - end - - context 'when the ignore parameter is specified' do - - let(:client) do - Class.new { include Elasticsearch::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 eq(false) - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/flush_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/flush_spec.rb deleted file mode 100644 index ce21e4b98a..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/flush_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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: ['foo','bar'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_field_mapping_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_field_mapping_spec.rb deleted file mode 100644 index 7687fb8319..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_field_mapping_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_mapping_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_mapping_spec.rb deleted file mode 100644 index 20f95460ef..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_mapping_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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: ['foo', 'bar'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_settings_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_settings_spec.rb deleted file mode 100644 index c603a589c0..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_settings_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_spec.rb deleted file mode 100644 index f22b538982..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_settings_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_settings_spec.rb deleted file mode 100644 index 27c43cd690..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_settings_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end - - context 'when there is no body specified' do - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'raises an exception' do - expect { - client.indices.put_settings - }.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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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: ['foo','bar'], body: {})).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/recovery_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/recovery_spec.rb deleted file mode 100644 index 365b11d716..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/recovery_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/refresh_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/refresh_spec.rb deleted file mode 100644 index 678accbacc..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/refresh_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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: ['foo', 'bar'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/segments_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/segments_spec.rb deleted file mode 100644 index 49293e444c..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/segments_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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: ['foo', 'bar'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/stats_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/stats_spec.rb deleted file mode 100644 index 934faba7e2..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/stats_spec.rb +++ /dev/null @@ -1,119 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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: ['foo', 'bar'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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', metric: 'fielddata', fields: ['foo', 'bar'])).to be_a Elasticsearch::API::Response - 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(groups: [ 'groupA', 'groupB'], metric: 'search')).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb deleted file mode 100644 index 1a735daec5..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb +++ /dev/null @@ -1,85 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.indices#unfreeze' 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 Elasticsearch::API }.new - end - - it 'raises an exception' do - expect { - client.indices.unfreeze - }.to raise_exception(ArgumentError) - end - end - - context 'when an index is specified' do - - let(:url) do - 'foo/_unfreeze' - end - - it 'performs the request' do - expect(client_double.indices.unfreeze(index: 'foo')).to be_a Elasticsearch::API::Response - end - end - - context 'when params are specified' do - - let(:params) do - { timeout: '1s' } - end - - let(:url) do - 'foo/_unfreeze' - end - - it 'performs the request' do - expect(client_double.indices.unfreeze(index: 'foo', timeout: '1s')).to be_a Elasticsearch::API::Response - end - end - - context 'when the path must be URL-escaped' do - - let(:url) do - 'foo%5Ebar/_unfreeze' - end - - it 'performs the request' do - expect(client_double.indices.unfreeze(index: 'foo^bar')).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/validate_query_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/indices/validate_query_spec.rb deleted file mode 100644 index c8489ffa59..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/validate_query_spec.rb +++ /dev/null @@ -1,112 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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: ['foo', 'bar'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/info_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/info_spec.rb deleted file mode 100644 index a54f5bd3b0..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/info_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#info' do - - let(:expected_args) do - [ - 'GET', - '', - { }, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.info).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/delete_pipeline_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/ingest/delete_pipeline_spec.rb deleted file mode 100644 index 4bb90b522f..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/delete_pipeline_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 Elasticsearch::API }.new - end - - it 'requires the :id argument' do - expect { - client.ingest.delete_pipeline - }.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.ingest.delete_pipeline(id: 'foo')).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/get_pipeline_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/ingest/get_pipeline_spec.rb deleted file mode 100644 index 9ebfe3f976..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/get_pipeline_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb deleted file mode 100644 index baedaa06fc..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/put_pipeline_spec.rb +++ /dev/null @@ -1,60 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 Elasticsearch::API }.new - end - - it 'requires the :id argument' do - expect { - client.ingest.put_pipeline - }.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.ingest.put_pipeline(id: 'foo', body: {})).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/get_memory_stats_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/get_memory_stats_spec.rb deleted file mode 100644 index 26dd5260d5..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/get_memory_stats_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#ml.get_memory_stats' do - - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - - context 'without a node id' do - let(:url) { '_ml/memory/_stats' } - - it 'performs the request' do - expect(client_double.ml.get_memory_stats).to be_a Elasticsearch::API::Response - end - end - - context 'with a node id' do - let(:url) { '_ml/memory/foo/_stats' } - - it 'performs the request' do - expect(client_double.ml.get_memory_stats(node_id: 'foo')).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/msearch_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/msearch_spec.rb deleted file mode 100644 index 203766940a..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/msearch_spec.rb +++ /dev/null @@ -1,153 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 Elasticsearch::API }.new - end - - it 'requires the :body argument' do - expect { - client.msearch - }.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 - %Q|{"foo":"bar"}\n{"moo":"lam"}| - end - - it 'performs the request' do - expect(client_double.msearch(body: %Q|{"foo":"bar"}\n{"moo":"lam"}|)).to be_a Elasticsearch::API::Response - 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: ['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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/mtermvectors_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/mtermvectors_spec.rb deleted file mode 100644 index 8a56b3265d..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/mtermvectors_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#mtermvectors' do - let(:expected_args) do - [ - 'POST', - 'my-index/_mtermvectors', - {}, - body, - {} - ] - end - - 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 be_a Elasticsearch::API::Response - end - - context 'when a list of ids is passed instead of a body' do - it 'performs the request' do - expect(client_double.mtermvectors(index: 'my-index', ids: [1, 2, 3])).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/info_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/nodes/info_spec.rb deleted file mode 100644 index 7ee8925fa6..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/info_spec.rb +++ /dev/null @@ -1,102 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.nodes#info' do - - let(:expected_args) do - [ - 'GET', - url, - params, - nil, - {} - ] - end - - let(:url) do - '_nodes' - end - - it 'performs the request' do - expect(client_double.nodes.info).to be_a Elasticsearch::API::Response - end - - let(:params) do - {} - 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 be_a Elasticsearch::API::Response - 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: ['A', 'B', 'C'])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - 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: ['http', 'network'])).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/stats_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/nodes/stats_spec.rb deleted file mode 100644 index 11106c968e..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/stats_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.nodes#stats' do - - let(:expected_args) do - [ - 'GET', - url, - params, - nil, - {} - ] - end - - let(:url) do - '_nodes/stats' - end - - it 'performs the request' do - expect(client_double.nodes.stats).to be_a Elasticsearch::API::Response - end - - let(:params) do - {} - 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 be_a Elasticsearch::API::Response - 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: [:http, :fs])).to be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/delete_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/delete_spec.rb deleted file mode 100644 index 6b4ac1c15d..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/delete_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.query_ruleset#delete' do - - let(:expected_args) do - [ - 'DELETE', - '_query_rules/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.query_ruleset.delete(ruleset_id: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/get_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/get_spec.rb deleted file mode 100644 index 33bac01549..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/get_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.query_ruleset#get' do - let(:expected_args) do - [ - 'GET', - '_query_rules/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.query_ruleset.get(ruleset_id: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/list_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/list_spec.rb deleted file mode 100644 index ee3c544ee2..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/list_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.query_ruleset#list' do - let(:expected_args) do - [ - 'GET', - '_query_rules', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.query_ruleset.list).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/put_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/put_spec.rb deleted file mode 100644 index 99372f8fb7..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/query_ruleset/put_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.query_ruleset#put' do - - let(:expected_args) do - [ - 'PUT', - '_query_rules/foo', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.query_ruleset.put(body: {}, ruleset_id: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/delete_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/search_application/delete_spec.rb deleted file mode 100644 index dbdb16f547..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/delete_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.search_application#delete' do - let(:expected_args) do - [ - 'DELETE', - '_application/search_application/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.search_application.delete(name: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/get_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/search_application/get_spec.rb deleted file mode 100644 index bb4e23cbe8..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/get_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.search_application#get' do - let(:expected_args) do - [ - 'GET', - '_application/search_application/foo', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.search_application.get(name: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/list_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/search_application/list_spec.rb deleted file mode 100644 index 6de6d0653c..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/list_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.search_application#list' do - let(:expected_args) do - [ - 'GET', - '_application/search_application', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.search_application.list).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/put_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/search_application/put_spec.rb deleted file mode 100644 index 42f5a8a925..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/put_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.search_application#put' do - let(:expected_args) do - [ - 'PUT', - '_application/search_application/foo', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.search_application.put(name: 'foo', body: {})).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/search_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/search_application/search_spec.rb deleted file mode 100644 index a124b81fb1..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/search_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.search_application#delete_behavioral_analytics' do - let(:expected_args) do - [ - 'GET', - '_application/search_application/foo/_search', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.search_application.search(name: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/search_spec.rb deleted file mode 100644 index 7d55c7abf6..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_spec.rb +++ /dev/null @@ -1,96 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 multiple indices are specified' do - let(:url) do - 'foo,bar/_search' - end - - it 'performs the request' do - expect(client_double.search(index: ['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 -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/clear_cache_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/clear_cache_spec.rb deleted file mode 100644 index be377a5cbf..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/clear_cache_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#searchable_snapshots.clear_cache' do - let(:expected_args) do - [ - 'POST', - url, - {}, - nil, - {} - ] - end - - let(:url){ '_searchable_snapshots/cache/clear' } - - it 'performs the request' do - expect(client_double.searchable_snapshots.clear_cache).to be_a Elasticsearch::API::Response - end - - context 'when using index' do - let(:url){ 'foo/_searchable_snapshots/cache/clear' } - - it 'performs the request' do - expect(client_double.searchable_snapshots.clear_cache(index: 'foo')).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/stats_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/stats_spec.rb deleted file mode 100644 index 2c36013f91..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/stats_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#searchable_snapshots.stats' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - let(:url) { '_searchable_snapshots/stats' } - - it 'performs the request' do - expect(client_double.searchable_snapshots.stats).to be_a Elasticsearch::API::Response - end - - context 'using index' do - let(:url) { 'foo/_searchable_snapshots/stats' } - - it 'performs the request' do - expect(client_double.searchable_snapshots.stats(index: 'foo')).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/has_privileges_user_profile_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/security/has_privileges_user_profile_spec.rb deleted file mode 100644 index bccd3624fa..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/has_privileges_user_profile_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#security#has_privileges_user_profile' do - let(:expected_args) do - [ - 'POST', - '_security/profile/_has_privileges', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.security.has_privileges_user_profile(body: {})).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/suggest_user_profiles_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/security/suggest_user_profiles_spec.rb deleted file mode 100644 index ec31fde218..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/suggest_user_profiles_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#security#search_user_profiles' do - let(:expected_args) do - [ - method, - '_security/profile/_suggest', - {}, - body, - {} - ] - end - let(:method) { 'GET' } - let(:body) { nil } - - it 'performs the request' do - expect(client_double.security.suggest_user_profiles).to be_a Elasticsearch::API::Response - end - - context 'when there is a body parameter' do - let(:method) { 'POST' } - let(:body) { {} } - - it 'performs the request' do - expect(client_double.security.suggest_user_profiles(body: {})).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/delete_node_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/delete_node_spec.rb deleted file mode 100644 index 214d6ab4e0..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/delete_node_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.shutdown#delete_node' do - let(:expected_args) do - [ - 'DELETE', - '_nodes/id/shutdown', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.shutdown.delete_node(node_id: 'id')).to be_a Elasticsearch::API::Response - end - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'raises an error if no node_id is provided' do - expect { - client.shutdown.delete_node - }.to raise_exception(ArgumentError) - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/get_node_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/get_node_spec.rb deleted file mode 100644 index aa12297a4c..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/get_node_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/put_node_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/put_node_spec.rb deleted file mode 100644 index 411a90e562..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/shutdown/put_node_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.shutdown#put_node' do - let(:expected_args) do - [ - 'PUT', - '_nodes/id/shutdown', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.shutdown.put_node(body: {}, node_id: 'id')).to be_a Elasticsearch::API::Response - end - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'raises an error if no node_id is provided' do - expect { - client.shutdown.put_node(body: {}) - }.to raise_exception(ArgumentError) - end - - it 'raises an error if no body is provided' do - expect { - client.shutdown.put_node(node_id: 'id') - }.to raise_exception(ArgumentError) - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/clone_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/clone_spec.rb deleted file mode 100644 index b99623382b..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/clone_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.snapshot#clone' do - let(:expected_args) do - [ - 'PUT', - '_snapshot/foo/bar/_clone/snapshot', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'requires the :body argument' do - expect { - client.snapshot.clone(snapshot: 'bar') - }.to raise_exception(ArgumentError) - end - - it 'requires the :repository argument' do - expect { - client.snapshot.clone(snapshot: 'foo', body: {}) - }.to raise_exception(ArgumentError) - end - - it 'requires the :snapshot argument' do - expect { - client.snapshot.clone(repository: 'foo', body: {}) - }.to raise_exception(ArgumentError) - end - - it 'requires the :target_snapshot argument' do - expect { - client.snapshot.clone(repository: 'foo', body: {}, snapshot: 'bar') - }.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.clone( - repository: 'foo', - snapshot: 'bar', - body: {}, - target_snapshot: 'snapshot' - )).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/create_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/create_spec.rb deleted file mode 100644 index c9f9fcc6c9..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/create_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.snapshot#create' do - - let(:expected_args) do - [ - 'PUT', - '_snapshot/foo/bar', - {}, - {}, - {} - ] - end - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'requires the :repository argument' do - expect { - client.snapshot.create(snapshot: 'bar', body: {}) - }.to raise_exception(ArgumentError) - end - - it 'requires the :snapshot argument' do - expect { - client.snapshot.create(repository: 'foo', body: {}) - }.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.create(repository: 'foo', snapshot: 'bar', body: {})).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/delete_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/delete_spec.rb deleted file mode 100644 index ce3a2b5cee..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/delete_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.snapshot#delete' do - - let(:expected_args) do - [ - 'DELETE', - '_snapshot/foo/bar', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'requires the :snapshot argument' do - expect { - client.snapshot.delete(repository: 'foo') - }.to raise_exception(ArgumentError) - end - - it 'requires the :repository argument' do - expect { - client.snapshot.delete(snapshot: 'bar') - }.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.delete(repository: 'foo', snapshot: 'bar')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/get_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/get_spec.rb deleted file mode 100644 index 3bed381e03..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/get_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.snapshot#get' do - - let(:expected_args) do - [ - 'GET', - '_snapshot/foo/bar', - {}, - nil, - {} - ] - end - - let(:client) do - Class.new { include Elasticsearch::API }.new - end - - it 'requires the :snapshot argument' do - expect { - client.snapshot.get(repository: 'foo') - }.to raise_exception(ArgumentError) - end - - it 'requires the :repository argument' do - expect { - client.snapshot.get(snapshot: 'bar') - }.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.snapshot.get(repository: 'foo', snapshot: 'bar')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/status_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/status_spec.rb deleted file mode 100644 index d007a5792c..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/status_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/delete_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/delete_spec.rb deleted file mode 100644 index f31a224e51..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/delete_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.synonym_rule#put' do - let(:expected_args) do - [ - 'DELETE', - '_synonyms/set/rule', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.synonym_rule.delete(synonyms_set: 'set', synonym_rule: 'rule')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/get_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/get_spec.rb deleted file mode 100644 index 95bdf7c04f..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/get_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.synonym_rule#put' do - let(:expected_args) do - [ - 'GET', - '_synonyms/set/rule', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.synonym_rule.get(synonyms_set: 'set', synonym_rule: 'rule')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/put_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/put_spec.rb deleted file mode 100644 index 3790ee35a4..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/synonym_rule/put_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.synonym_rule#put' do - let(:expected_args) do - [ - 'PUT', - '_synonyms/set/rule', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.synonym_rule.put(body: {}, synonyms_set: 'set', synonym_rule: 'rule')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/synonyms/update_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/synonyms/update_spec.rb deleted file mode 100644 index a9a7f8e8a0..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/synonyms/update_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.synonyms#put' do - let(:expected_args) do - [ - 'PUT', - '_synonyms/foo', - {}, - {}, - {} - ] - end - - it 'performs the request' do - expect(client_double.synonyms.put(body: {}, synonyms_set: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/synonyms_sets/get_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/synonyms_sets/get_spec.rb deleted file mode 100644 index 52d20c37be..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/synonyms_sets/get_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client.synonyms_sets#get' do - let(:expected_args) do - [ - 'GET', - '_synonyms', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.synonyms_sets.get).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/tasks/cancel_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/tasks/cancel_spec.rb deleted file mode 100644 index 14c2b2eec0..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/tasks/cancel_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - 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 be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/tasks/get_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/tasks/get_spec.rb deleted file mode 100644 index 44c316d31c..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/tasks/get_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/tasks/list_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/tasks/list_spec.rb deleted file mode 100644 index 73ec37ee8e..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/tasks/list_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/termvectors_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/termvectors_spec.rb deleted file mode 100644 index 2b07e1d749..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/termvectors_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '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 Elasticsearch::API }.new - end - - it 'requires the :index argument' do - expect { - client.termvectors(id: '1') - }.to raise_exception(ArgumentError) - end - - it 'performs the request' do - expect(client_double.termvectors(index: 'foo', id: '123', body: {})).to be_a Elasticsearch::API::Response - end - - context 'when the older api name \'termvector\' is used' do - let(:url) do - 'foo/_termvectors/123' - end - - it 'performs the request' do - expect(client_double.termvector(index: 'foo', id: '123', body: {})).to be_a Elasticsearch::API::Response - end - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/watcher/get_settings_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/watcher/get_settings_spec.rb deleted file mode 100644 index 0cf419b222..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/actions/watcher/get_settings_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe 'client#watcher.get_settings' do - let(:expected_args) do - [ - 'GET', - '_watcher/settings', - {}, - nil, - {} - ] - end - - it 'performs the request' do - expect(client_double.watcher.get_settings).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/elasticsearch/api/utils_spec.rb b/elasticsearch-api/spec/elasticsearch/api/utils_spec.rb deleted file mode 100644 index 63eba22f13..0000000000 --- a/elasticsearch-api/spec/elasticsearch/api/utils_spec.rb +++ /dev/null @@ -1,355 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'spec_helper' - -describe Elasticsearch::API::Utils do - let(:utils) do - Class.new { include Elasticsearch::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%20bar') - 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 - 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(['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 - - it 'ignores special characters' do - expect(utils.__listify(['foo', 'bar^bam'])).to eq('foo,bar%5Ebam') - end - - 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') - 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(['foo', 'bar'])).to eq('foo/bar') - end - - it 'ignores nil values' do - expect(utils.__pathify(['foo', nil, 'bar'])).to eq('foo/bar') - end - - it 'ignores empty string values' do - expect(utils.__pathify(['foo', '', 'bar'])).to eq('foo/bar') - end - end - - describe '#__bulkify' do - context 'when the input is an array of hashes' do - let(:result) do - utils.__bulkify [ - { index: { _index: 'myindexA', _id: '1', data: { title: 'Test' } } }, - { update: { _index: 'myindexB', _id: '2', data: { doc: { title: 'Update' } } } }, - { delete: { _index: 'myindexC', _id: '3' } } - ] - end - - let(:expected_string) do - <<-PAYLOAD.gsub(/^\s+/, '') - {"index":{"_index":"myindexA","_id":"1"}} - {"title":"Test"} - {"update":{"_index":"myindexB","_id":"2"}} - {"doc":{"title":"Update"}} - {"delete":{"_index":"myindexC","_id":"3"}} - PAYLOAD - end - - it 'serializes the hashes' do - expect(result).to eq(expected_string) - end - end - - context 'when the input is an array of strings' do - - let(:result) do - utils.__bulkify(['{"foo":"bar"}','{"moo":"bam"}']) - end - - let(:expected_string) do - <<-PAYLOAD.gsub(/^\s+/, '') - {"foo":"bar"} - {"moo":"bam"} - PAYLOAD - end - - it 'serializes the array of strings' do - expect(result).to eq(expected_string) - end - end - - context 'when the input is an array of header/data pairs' do - - let(:result) do - utils.__bulkify([{ foo: 'bar' }, { moo: 'bam' },{ foo: 'baz' }]) - end - - let(:expected_string) do - <<-PAYLOAD.gsub(/^\s+/, '') - {"foo":"bar"} - {"moo":"bam"} - {"foo":"baz"} - PAYLOAD - end - - it 'serializes the array of strings' do - expect(result).to eq(expected_string) - end - end - - context 'when the payload has the :data option' do - - let(:input) do - { index: { foo: 'bar', data: { moo: 'bam' } } } - end - - let(:result) do - utils.__bulkify([input]) - end - - let(:expected_string) do - <<-PAYLOAD.gsub(/^\s+/, '') - {"index":{"foo":"bar"}} - {"moo":"bam"} - PAYLOAD - end - - it 'does not mutate the input' do - expect(input[:index][:data]).to eq(moo: 'bam') - end - - it 'serializes the array of strings' do - expect(result).to eq(expected_string) - end - end - - context 'when the payload has nested :data options' do - let(:data) do - { data: { a: 'b', data: { c: 'd' } } } - end - - let(:result) do - utils.__bulkify([{ index: { foo: 'bar'} } , data]) - end - - let(:lines) do - result.split("\n") - end - - let(:header) do - MultiJson.load(lines.first) - end - - let(:data_string) do - MultiJson.load(lines.last) - end - - it 'does not mutate the input' do - expect(data[:data]).to eq(a: 'b', data: { c: 'd' }) - end - - it 'serializes the array of strings' do - expect(header['index']['foo']).to eq('bar') - expect(data_string['data']['a']).to eq('b') - expect(data_string['data']['data']['c']).to eq('d') - end - end - end - - context '#__validate_and_extract_params' do - it 'listify Arrays' do - expect(utils.process_params({ foo: ['a', 'b'] })).to eq(foo: 'a,b') - end - - it 'does not escape the parameters' do - expect(utils.process_params({ foo: ['a.*', 'b.*'] })).to eq(foo: 'a.*,b.*') - end - - context 'when the params are valid' do - it 'extracts the valid params from the hash' do - expect(utils.process_params({ foo: 'qux' })).to eq(foo: 'qux') - 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' })).to eq(['foo', 'blah']) - end - - it 'extracts parts with string value from a Hash' do - expect(utils.__extract_parts({ foo: 'qux', moo: 'blah' })).to eq(['qux', 'blah']) - end - end - - context '#__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.new "Not Found" }).to be(false) - expect(utils.__rescue_from_not_found { raise StandardError.new "NotFound" }).to be(false) - end - - it 'raises the exception if the class name and message do not include \'NotFound\'' do - expect { - utils.__rescue_from_not_found { raise StandardError.new "Any other exception" } - }.to raise_exception(StandardError) - end - end - - context '#__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 - [ :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 - [ :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/elasticsearch-api/spec/integration/api_key_spec.rb b/elasticsearch-api/spec/integration/api_key_spec.rb new file mode 100644 index 0000000000..f2453dc76a --- /dev/null +++ b/elasticsearch-api/spec/integration/api_key_spec.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'base64' +require_relative './integration_helper' + +describe 'API keys' do + before do + CLIENT.security.put_user( + username: client_username, + body: { password: 'test-password', roles: ['superuser'] } + ) + end + + after do + CLIENT.security.delete_user(username: client_username) + end + + let(:client_username) { "query_api_keys_#{Time.new.to_i}" } + let(:credentials) { Base64.strict_encode64("#{client_username}:test-password") } + + let(:client) do + Elasticsearch::Client.new( + host: HOST, + transport_options: TRANSPORT_OPTIONS.merge(headers: { Authorization: "Basic #{credentials}" }) + ) + end + + it 'queries API keys' do + key_name1 = "query-key-1-#{Time.new.to_i}" + response = client.security.create_api_key( + body: { + name: key_name1, + role_descriptors: {}, + expiration: '1d', + metadata: { search: 'this' } + } + ) + expect(response['name']).to eq key_name1 + expect(response['api_key']).not_to be nil + api_key_id1 = response['id'] + + key_name2 = "query-key-2-#{Time.new.to_i}" + response = client.security.create_api_key( + body: { + name: key_name2, + expiration: '2d', + role_descriptors: { 'role-a' => { "cluster": ['monitor'] } }, + metadata: { search: false } + } + ) + expect(response['name']).to eq key_name2 + expect(response['api_key']).not_to be nil + api_key_id2 = response['id'] + + key_name3 = "query-key-3#{Time.new.to_i}" + response = client.security.create_api_key( + body: { + name: key_name3, + expiration: '3d' + } + ) + expect(response['name']).to eq key_name3 + expect(response['api_key']).not_to be nil + api_key_id3 = response['id'] + + response = client.security.authenticate + response['username'] + + response = client.security.query_api_keys( + body: { + query: { wildcard: { name: key_name1 } } + } + ) + expect(response['total']).to eq 1 + expect(response['count']).to eq 1 + expect(response['api_keys'].first['id']).to eq api_key_id1 + + response = client.security.query_api_keys( + body: { + query: { wildcard: { name: key_name2 } } + } + ) + expect(response['total']).to eq 1 + expect(response['count']).to eq 1 + expect(response['api_keys'].first['id']).to eq api_key_id2 + + response = client.security.query_api_keys( + body: { + query: { wildcard: { name: key_name3 } } + } + ) + expect(response['total']).to eq 1 + expect(response['count']).to eq 1 + expect(response['api_keys'].first['id']).to eq api_key_id3 + end +end diff --git a/elasticsearch-api/spec/integration/health_spec.rb b/elasticsearch-api/spec/integration/health_spec.rb new file mode 100644 index 0000000000..3f7207094d --- /dev/null +++ b/elasticsearch-api/spec/integration/health_spec.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 './integration_helper' + +describe 'Health basic test' do + it 'performs the request' do + response = CLIENT.health_report + expect(response.status).to eq 200 + expect(response['cluster_name']).not_to be_nil + expect(response.dig('indicators', 'master_is_stable', 'symptom')).to eq 'The cluster has a stable master node' + expect(response.dig('indicators', 'master_is_stable', 'status')).to eq 'green' + end + + context 'Usage stats on the health API' do + before do + CLIENT.indices.create( + index: 'red_index', + body: { + settings: { + number_of_shards: 1, + number_of_replicas: 0, + 'index.routing.allocation.enable' => 'none' + } + } + ) + end + + after do + CLIENT.indices.delete(index: 'red_index') + end + + it 'responds with health report' do + expect(CLIENT.health_report.status).to eq 200 + expect(CLIENT.health_report(feature: 'disk').status).to eq 200 + response = CLIENT.xpack.usage + expect(response['health_api']['available']).to eq true + expect(response['health_api']['enabled']).to eq true + expect(response['health_api']['invocations']['total']).to be >= 2 + expect(response['health_api']['invocations']['verbose_true']).to be >= 2 + end + end +end diff --git a/elasticsearch-api/spec/integration/integration_helper.rb b/elasticsearch-api/spec/integration/integration_helper.rb new file mode 100644 index 0000000000..343f1dc4a8 --- /dev/null +++ b/elasticsearch-api/spec/integration/integration_helper.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'openssl' +require 'elasticsearch' + +CERTS_PATH = File.expand_path('./../../../.buildkite/certs', __dir__) +host = ENV['TEST_ES_SERVER'] || 'http://localhost:9200' +raise URI::InvalidURIError unless host =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ + +password = ENV['ELASTIC_PASSWORD'] || 'changeme' +HOST_URI = URI.parse(host) +raw_certificate = File.read("#{CERTS_PATH}/testnode.crt") +certificate = OpenSSL::X509::Certificate.new(raw_certificate) +raw_key = File.read("#{CERTS_PATH}/testnode.key") +key = OpenSSL::PKey::RSA.new(raw_key) +ca_file = File.expand_path("#{CERTS_PATH}/ca.crt") +TRANSPORT_OPTIONS = { ssl: { verify: false, client_cert: certificate, client_key: key, ca_file: ca_file } } +HOST = "https://elastic:#{password}@#{HOST_URI.host}:#{HOST_URI.port}" +CLIENT = Elasticsearch::Client.new(host: HOST, transport_options: TRANSPORT_OPTIONS) + +RSpec.configure do |config| + config.add_formatter('documentation') + config.add_formatter('RSpec::Core::Formatters::HtmlFormatter', "tmp/#{ENV['RUBY_VERSION']}-manual-integration.html") + config.color_mode = :on +end diff --git a/elasticsearch-api/spec/platinum/integration/analytics/usage_spec.rb b/elasticsearch-api/spec/platinum/integration/analytics/usage_spec.rb deleted file mode 100644 index 2f88973d9e..0000000000 --- a/elasticsearch-api/spec/platinum/integration/analytics/usage_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'analytics/usage stats API' do - let(:index) { 'analytics_test' } - before do - body = [ - {"index": {}}, - {"timestamp": "2017-01-01T05:00:00Z", "s": 1, "v1": 3.1415, "v2": 2.1415, "str": "a"}, - {"index": {}}, - {"timestamp": "2017-01-01T05:00:00Z", "s": 2, "v1": 1.0, "v2": 2.0, "str": "a"}, - {"index": {}}, - {"timestamp": "2017-01-01T05:00:00Z", "s": 3, "v1": 2.71828, "v2": 3.71828, "str": "b"}, - ] - ADMIN_CLIENT.bulk(body: body, index: index, refresh: true) - end - - after do - ADMIN_CLIENT.indices.delete(index: index) - end - - it 'gets memory for all nodes' do - response = ADMIN_CLIENT.xpack.usage - expect(response['analytics']['available']).to eq true - expect(response['analytics']['enabled']).to eq true - - boxplot_usage = response['analytics']['stats']['boxplot_usage'] - - response = ADMIN_CLIENT.search( - index: index, - body: { size: 0, aggs: { plot: { boxplot: { field: 's' } } } } - ) - expect(response['aggregations']['plot']['q2']).to eq 2.0 - - response = ADMIN_CLIENT.xpack.usage - expect(response['analytics']['available']).to eq true - expect(response['analytics']['enabled']).to eq true - expect(response['analytics']['stats']['boxplot_usage']).to be > boxplot_usage - end -end diff --git a/elasticsearch-api/spec/platinum/integration/api_key/api_key_cross_cluster_spec.rb b/elasticsearch-api/spec/platinum/integration/api_key/api_key_cross_cluster_spec.rb deleted file mode 100644 index 6b42dccd6f..0000000000 --- a/elasticsearch-api/spec/platinum/integration/api_key/api_key_cross_cluster_spec.rb +++ /dev/null @@ -1,129 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'base64' -require_relative '../platinum_helper' - -describe 'API keys API' do - let(:user) { 'admin_user' } - let(:password) { 'x-pack-test-password' } - before do - ADMIN_CLIENT.security.put_role( - name: 'admin_role', - body: { cluster: ['manage_security'] } - ) - ADMIN_CLIENT.security.put_user( - username: user, - body: { - password: password, - roles: [ 'admin_role' ], - full_name: 'Admin user' - } - ) - end - - after do - ADMIN_CLIENT.security.delete_role(name: 'admin_role', ignore: 404) - ADMIN_CLIENT.security.delete_user(username: user, ignore: 404) - end - - let(:client) do - Elasticsearch::Client.new( - host: "https://admin_user:x-pack-test-password@#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS - ) - end - - describe 'Cross Cluster API Key' do - it 'updates api key' do - response = client.security.create_cross_cluster_api_key( - body: { - name: "my-cc-api-key", - expiration: "1d", - access: { - search: [ - { - names: ["logs*"], - query: { - term: { "category": "shared" } - }, - field_security: { - grant: ["*"], - except: ["private"] - } - } - ], - replication: [ - { - names: ["archive"], - allow_restricted_indices: false - } - ] - }, - metadata: { - answer: 42, - tag: "dev" - } - } - ) - expect(response.status).to eq 200 - expect(response['name']).to eq 'my-cc-api-key' - id = response['id'] - expect(id).not_to be nil - expect(response['api_key']).not_to be nil - expect(response['expiration']).not_to be nil - credentials = Base64.strict_encode64("#{response['id']}:#{response['api_key']}") - expect(credentials).to eq response['encoded'] - - new_client = Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS - ) - expect do - new_client.security.authenticate(headers: { authorization: "ApiKey #{credentials}" }) - end.to raise_error(Elastic::Transport::Transport::Errors::Unauthorized) - - response = client.security.get_api_key(id: id, with_limited_by: true) - expect(response.status).to eq 200 - api_key = response['api_keys'].first - expect(api_key['name']) == 'my-cc-api-key' - expect(api_key['type']) == 'cross_cluster' - expect(api_key['invalidated']).to be false - expect(api_key['metadata']).to eq({'answer' => 42, 'tag' => 'dev'}) - - # Tests update cc api_key - response = client.security.update_cross_cluster_api_key( - id: id, - body: { - access: { - replication: [{ names: ["archive"] }] - }, - metadata: { "tag": "prod" } - } - ) - expect(response['updated']).to be true - - response = client.security.get_api_key(id: id, with_limited_by: true) - expect(response['api_keys'].length).to eq 1 - api_key = response['api_keys'].first - expect(api_key['name']) == 'my-cc-api-key' - expect(api_key['type']) == 'cross_cluster' - expect(api_key['invalidated']).to be false - expect(api_key['metadata']).to eq({'tag' => 'prod'}) - end - end -end diff --git a/elasticsearch-api/spec/platinum/integration/api_key/api_key_invalidation_spec.rb b/elasticsearch-api/spec/platinum/integration/api_key/api_key_invalidation_spec.rb deleted file mode 100644 index cc6b5a54cd..0000000000 --- a/elasticsearch-api/spec/platinum/integration/api_key/api_key_invalidation_spec.rb +++ /dev/null @@ -1,107 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'API keys API invalidation' do - before do - ADMIN_CLIENT.security.put_role( - name: 'admin_role', - body: { - cluster: ['manage_api_key'] - } - ) - ADMIN_CLIENT.security.put_role( - name: 'user_role', - body: { - cluster: ['manage_own_api_key'] - } - ) - ADMIN_CLIENT.security.put_user( - username: 'api_key_manager', - body: { - password: 'x-pack-test-password', - roles: [ 'admin_role' ], - full_name: 'API key manager' - } - ) - ADMIN_CLIENT.security.put_user( - username: 'api_key_user1', - body: { - password: 'x-pack-test-password', - roles: [ 'user_role' ], - full_name: 'API key user' - } - ) - end - - after do - ADMIN_CLIENT.security.delete_role(name: "admin_role", ignore: 404) - ADMIN_CLIENT.security.delete_role(name: "user_role", ignore: 404) - ADMIN_CLIENT.security.delete_user(username: "api_key_user1", ignore: 404) - ADMIN_CLIENT.security.delete_user(username: "api_key_manager", ignore: 404) - end - - let(:client) do - Elasticsearch::Client.new( - host: "https://api_key_manager:x-pack-test-password@#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS - ) - end - - it 'invalidates by realm name' do - response = client.security.create_api_key( - body: { - name: "manager-api-key", - expiration: "1d", - role_descriptors: {} - } - ) - expect(response['name']).to eq 'manager-api-key' - id = response['id'] - expect(id).not_to be nil - expect(response['api_key']).not_to be nil - expect(response['expiration']).not_to be nil - - user_client = Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - user: 'api_key_user1', - password: 'x-pack-test-password', - transport_options: TRANSPORT_OPTIONS - ) - response = user_client.security.create_api_key( - body: { - name: "user1-api-key", - expiration: "1d", - role_descriptors: {} - } - ) - expect(response['name']).to eq 'user1-api-key' - id = response['id'] - expect(id).not_to be nil - expect(response['api_key']).not_to be nil - expect(response['expiration']).not_to be nil - - expect do - user_client.security.invalidate_api_key(body: { realm_name: 'default_native'}) - end.to raise_error(Elastic::Transport::Transport::Errors::Forbidden) - - response = client.security.invalidate_api_key(body: { realm_name: 'default_native'}) - expect(response['invalidated_api_keys'].count).to be >= 2 - expect(response['error_count']).to eq 0 - end -end diff --git a/elasticsearch-api/spec/platinum/integration/api_key/api_key_query_spec.rb b/elasticsearch-api/spec/platinum/integration/api_key/api_key_query_spec.rb deleted file mode 100644 index 238d1aa4bb..0000000000 --- a/elasticsearch-api/spec/platinum/integration/api_key/api_key_query_spec.rb +++ /dev/null @@ -1,149 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'API keys' do - before do - ADMIN_CLIENT.security.put_role( - name: 'admin_role', - body: { cluster: ['manage_api_key'] } - ) - ADMIN_CLIENT.security.put_role( - name: 'user_role', - body: { - cluster: ['manage_own_api_key'], - } - ) - ADMIN_CLIENT.security.put_user( - username: 'api_key_manager', - body: { - password: 'x-pack-test-password', - roles: [ 'admin_role' ], - full_name: 'API key manager' - } - ) - ADMIN_CLIENT.security.put_user( - username: 'api_key_user_1', - body: { - password: 'x-pack-test-password', - roles: [ 'user_role' ], - full_name: 'API key user 1' - } - ) - ADMIN_CLIENT.security.put_user( - username: 'api_key_user_2', - body: { - password: 'x-pack-test-password', - roles: [ 'user_role' ], - full_name: 'API key user 2' - } - ) - end - - after do - ADMIN_CLIENT.security.delete_role(name: "admin_role", ignore: 404) - ADMIN_CLIENT.security.delete_role(name: "user_role", ignore: 404) - ADMIN_CLIENT.security.delete_user(username: "api_key_user_1", ignore: 404) - ADMIN_CLIENT.security.delete_user(username: "api_key_user_2", ignore: 404) - ADMIN_CLIENT.security.delete_user(username: "api_key_manager", ignore: 404) - end - - def client(headers) - Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS.merge(headers: headers) - ) - end - - let(:manager_auth) do - { Authorization: "Basic YXBpX2tleV9tYW5hZ2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } - end - let(:user1_auth) do - { Authorization: "Basic YXBpX2tleV91c2VyXzE6eC1wYWNrLXRlc3QtcGFzc3dvcmQ=" } - end - let(:user2_auth) do - { Authorization: "Basic YXBpX2tleV91c2VyXzI6eC1wYWNrLXRlc3QtcGFzc3dvcmQ=" } - end - - it 'queries api key' do - # api_key_manager authorization: - client = client(manager_auth) - response = client.security.create_api_key( - body: { - name: 'manager-api-key', - expiration: '10d', - metadata: { - letter: 'a', - number: 42 - } - } - ) - expect(response.status).to eq 200 - manager_key_id = response['id'] - - # api_key_user1 authorization: - client = client(user1_auth) - response = client.security.create_api_key( - body: { - name: 'user1-api-key', - expiration: '1d', - metadata: { - letter: 'a', - number: 1 - } - } - ) - expect(response.status).to eq 200 - user1_key_id = response['id'] - - # api_key_user2 authorization - client = client(user2_auth) - response = client.security.create_api_key( - body: { - name: 'user2-api-key', - expiration: '1d', - metadata: { - letter: 'b', - number: 42 - } - } - ) - expect(response.status).to eq 200 - user1_key_id = response['id'] - - client = client(manager_auth) - response = client.security.query_api_keys - expect(response.status).to eq 200 - manager_total = response['total'] - expect(manager_total).to be >= 3 - - client = client(user1_auth) - response = client.security.query_api_keys - expect(response.status).to eq 200 - user_1_total = response['total'] - expect(user_1_total).to be >= 1 - expect(user_1_total).to be < manager_total - - client = client(user2_auth) - response = client.security.query_api_keys - expect(response.status).to eq 200 - user_2_total = response['total'] - expect(user_2_total).to be >= 1 - expect(user_2_total).to be < manager_total - end -end diff --git a/elasticsearch-api/spec/platinum/integration/api_key/api_key_spec.rb b/elasticsearch-api/spec/platinum/integration/api_key/api_key_spec.rb deleted file mode 100644 index aadfd22c38..0000000000 --- a/elasticsearch-api/spec/platinum/integration/api_key/api_key_spec.rb +++ /dev/null @@ -1,157 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'base64' -require_relative '../platinum_helper' - -describe 'API keys' do - before do - ADMIN_CLIENT.security.put_role( - name: 'admin_role', - body: { - cluster: ['manage_api_key'], - indices: [ - { - names: '*', - privileges: ['all'] - } - ], - applications: [ - { - application: 'myapp', - privileges: ['*'], - resources: ['*'] - } - ] - } - ) - ADMIN_CLIENT.security.put_user( - username: 'api_key_user', - body: { - password: 'x-pack-test-password', - roles: [ 'admin_role' ], - full_name: 'API key user' - } - ) - ADMIN_CLIENT.security.put_privileges( - body: - { - myapp: { - read: { - application: 'myapp', - name: 'read', - actions: [ 'data:read/*' ] - }, - write: { - application: 'myapp', - name: 'write', - actions: [ 'data:write/*' ] - } - } - } - ) - end - - after do - ADMIN_CLIENT.security.delete_role(name: "admin_role", ignore: 404) - ADMIN_CLIENT.security.delete_user(username: "api_key_user", ignore: 404) - ADMIN_CLIENT.security.delete_privileges(application: 'myapp', name: "read,write", ignore: 404) - end - - let(:client) do - Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - user: 'api_key_user', - password: 'x-pack-test-password', - transport_options: TRANSPORT_OPTIONS - ) - end - - it 'creates api key' do - response = client.security.create_api_key( - body: { - name: "my-api-key", - expiration: "1d", - role_descriptors: { - 'role-a' => { - cluster: ["all"], - index: [ - { - names: ["index-a"], - privileges: ["read"] - } - ] - }, - 'role-b' => { - cluster: ["manage"], - index: [ - { - names: ["index-b"], - privileges: ["all"] - } - ] - } - } - } - ) - expect(response['name']).to eq 'my-api-key' - id = response['id'] - expect(id).not_to be nil - expect(response['api_key']).not_to be nil - expect(response['expiration']).not_to be nil - credentials = Base64.strict_encode64("#{response['id']}:#{response['api_key']}") - expect(credentials).to eq response['encoded'] - new_client = Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS, - api_key: credentials - ) - response = new_client.security.authenticate - expect(response['username']).to eq 'api_key_user' - expect(response['roles'].length).to eq 0 - expect(response['authentication_realm']['name']).to eq '_es_api_key' - expect(response['authentication_realm']['type']).to eq '_es_api_key' - expect(response['api_key']['id']).to eq id - expect(response['api_key']['name']).to eq 'my-api-key' - response = ADMIN_CLIENT.security.clear_api_key_cache(ids: id) - expect(response['_nodes']['failed']).to eq 0 - end - - context 'Test get api key' do - let(:name) { 'my-api-key-2'} - - it 'gets api key' do - response = ADMIN_CLIENT.security.create_api_key( - body: { name: name, expiration: '1d' } - ) - expect(response['name']).to eq name - id = response['id'] - expect(id).not_to be nil - expect(response['api_key']).not_to be nil - expect(response['expiration']).not_to be nil - - response = ADMIN_CLIENT.security.get_api_key(id: id) - expect(response['api_keys'].first['id']).to eq id - expect(response['api_keys'].first['name']).to eq name - expect(response['api_keys'].first['username']).to eq 'elastic' - expect(response['api_keys'].first['invalidated']).to eq false - expect(response['api_keys'].first['creation']).not_to be nil - response = ADMIN_CLIENT.security.get_api_key(owner: true) - expect(response['api_keys'].length).to be > 0 - end - end -end diff --git a/elasticsearch-api/spec/platinum/integration/api_key/api_key_update_spec.rb b/elasticsearch-api/spec/platinum/integration/api_key/api_key_update_spec.rb deleted file mode 100644 index f37eeae8fe..0000000000 --- a/elasticsearch-api/spec/platinum/integration/api_key/api_key_update_spec.rb +++ /dev/null @@ -1,134 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'base64' -require_relative '../platinum_helper' - -describe 'API keys API' do - before do - ADMIN_CLIENT.security.put_role( - name: 'user_role', - body: { - cluster: ['manage_own_api_key'], - indices: [ - { - names: '*', - privileges: ['all'] - } - ] - } - ) - ADMIN_CLIENT.security.put_user( - username: 'api_key_user_1', - body: { - password: 'x-pack-test-password', - roles: [ 'user_role' ], - full_name: 'API key user 1' - } - ) - end - - after do - ADMIN_CLIENT.security.delete_role(name: "user_role", ignore: 404) - ADMIN_CLIENT.security.delete_user(username: "api_key_user_1", ignore: 404) - end - - let(:client) do - Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS.merge( - headers: { Authorization: "Basic YXBpX2tleV91c2VyXzE6eC1wYWNrLXRlc3QtcGFzc3dvcmQ=" } - ) - ) - end - - it 'updates api key' do - response = client.security.create_api_key( - body: { - name: 'user1-api-key', - role_descriptors: { - "role-a" => { - cluster: ["none"], - index: [ - { - names: ["index-a"], - privileges: ["read"] - } - ] - } - } - } - ) - expect(response.status).to eq 200 - expect(response['name']).to eq 'user1-api-key' - id = response['id'] - expect(id).not_to be nil - expect(response['api_key']).not_to be nil - credentials = Base64.strict_encode64("#{response['id']}:#{response['api_key']}") - expect(credentials).to eq response['encoded'] - - new_client = Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS, - api_key: credentials - ) - privileges_body = { - cluster: ['manage_own_api_key'], - index: [ - { - names: ['index-a'], - privileges: ['write'] - }, - { - names: ['index-b'], - privileges: ['read'] - } - ] - } - response = new_client.security.has_privileges(body: privileges_body) - expect(response['has_all_requested']).to eq false - - response = client.security.update_api_key( - id: id, - body: { - role_descriptors: { - "role-a" => { - cluster: ["all"], - index: [ - { - names: ["index-a"], - privileges: ["write"] - }, - { - names: ["index-b"], - privileges: ["read"] - } - ] - } - }, - metadata: { - letter: "a", - number: 42 - } - } - ) - expect(response['updated']).to eq true - - response = new_client.security.has_privileges(user: nil, body: privileges_body) - expect(response['has_all_requested']).to eq true - end -end diff --git a/elasticsearch-api/spec/platinum/integration/eql/eql_async_spec.rb b/elasticsearch-api/spec/platinum/integration/eql/eql_async_spec.rb deleted file mode 100644 index 9149a1c3b6..0000000000 --- a/elasticsearch-api/spec/platinum/integration/eql/eql_async_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'eql/Executes async EQL with missing events' do - let(:index) { 'eql_test_m' } - before do - ADMIN_CLIENT.indices.create( - index: index, - body: { - mappings: { - properties: { - '@timestamp' => { type: 'date' }, - 'event.category' => { type: 'keyword' }, - user: { type: 'keyword' } - } - } - } - ) - ADMIN_CLIENT.bulk( - refresh: true, - body: [ - { index: { _index: 'eql_test_m', _id: '1' } }, - { event: [{ category: 'process' }], '@timestamp' => '2023-07-11T11:09:05.529Z', user: 'foo' }, - { index: { _index: 'eql_test_m', _id: '2'} }, - { event: [{ category: 'process' }], '@timestamp' => '2023-07-11T11:09:06.529Z', user: 'bar' } - ] - ) - end - - after do - ADMIN_CLIENT.indices.delete(index: index) - end - - it 'Executes async EQL with missing events' do - response = ADMIN_CLIENT.eql.search( - index: 'eql_test_m', - wait_for_completion_timeout: '0ms', - keep_on_completion: true, - body: { query: 'sequence with maxspan=24h [ process where true ] ![ process where true ]' } - ) - expect(response.status).to eq 200 - expect(response['id']).not_to be_nil - id = response['id'] - - response = ADMIN_CLIENT.eql.get(id: id, wait_for_completion_timeout: '10s') - expect(response.status).to eq 200 - expect(response['is_running']).to be false - expect(response['is_partial']).to be false - expect(response['timed_out']).to be false - expect(response['hits']['total']['value']).to eq 1 - expect(response['hits']['total']['relation']).to eq 'eq' - expect(response['hits']['total']['relation']).to eq 'eq' - expect(response['hits']['sequences'].first['events'].first['_source']['user']).to eq 'bar' - expect(response['hits']['sequences'].first['events'].last['missing']).to be true - end -end diff --git a/elasticsearch-api/spec/platinum/integration/health/health_spec.rb b/elasticsearch-api/spec/platinum/integration/health/health_spec.rb deleted file mode 100644 index eefa5f6237..0000000000 --- a/elasticsearch-api/spec/platinum/integration/health/health_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'Health API' do - context 'Usage stats on the health API' do - before do - ADMIN_CLIENT.indices.create( - index: 'red_index', - body: { - settings: { - number_of_shards: 1, - number_of_replicas: 0, - 'index.routing.allocation.enable' => 'none' - } - } - ) - end - - after do - ADMIN_CLIENT.indices.delete(index: 'red_index') - end - - it 'responds with health report' do - expect(ADMIN_CLIENT.health_report.status).to eq 200 - expect(ADMIN_CLIENT.health_report(feature: 'disk').status).to eq 200 - response = ADMIN_CLIENT.xpack.usage - expect(response['health_api']['available']).to eq true - expect(response['health_api']['enabled']).to eq true - expect(response['health_api']['invocations']['total']).to be >= 2 - expect(response['health_api']['invocations']['verbose_true']).to be >= 2 - end - end -end diff --git a/elasticsearch-api/spec/platinum/integration/ml/get_memory_stats_spec.rb b/elasticsearch-api/spec/platinum/integration/ml/get_memory_stats_spec.rb deleted file mode 100644 index a2932733f6..0000000000 --- a/elasticsearch-api/spec/platinum/integration/ml/get_memory_stats_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'ML/Get Memory Stats API' do - it 'gets memory for all nodes' do - response = ADMIN_CLIENT.ml.get_memory_stats - expect(response.status).to eq 200 - expect(response['cluster_name']).not_to be_nil - expect(response['_nodes']['total']).to be >= 1 - expect(response['nodes'].first[1]['mem']['total_in_bytes']).to be > 1 - end - - it 'gets memory for ML nodes' do - response = ADMIN_CLIENT.ml.get_memory_stats - expect(response.status).to eq 200 - expect(response['cluster_name']).not_to be_nil - expect(response['nodes'].first[1]['mem']['total_in_bytes']).to be > 1 - end - - it 'gets memory for specific node' do - response = ADMIN_CLIENT.ml.get_memory_stats - expect(response.status).to eq 200 - node_id = response['nodes'].keys.first - - response = ADMIN_CLIENT.ml.get_memory_stats(node_id: node_id, timeout: '29s') - expect(response.status).to eq 200 - expect(response['cluster_name']).not_to be_nil - expect(response['nodes'].first[1]['mem']['total_in_bytes']).to be > 1 - expect(response['_nodes']['total']).to be 1 - end -end diff --git a/elasticsearch-api/spec/platinum/integration/platinum_helper.rb b/elasticsearch-api/spec/platinum/integration/platinum_helper.rb deleted file mode 100644 index cc48f6d697..0000000000 --- a/elasticsearch-api/spec/platinum/integration/platinum_helper.rb +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'openssl' -require 'elasticsearch' - -CERTS_PATH = File.expand_path('./../.buildkite/certs') - -host = ENV['TEST_ES_SERVER'] || 'https://localhost:9200' -raise URI::InvalidURIError unless host =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ - -password = ENV['ELASTIC_PASSWORD'] || 'changeme' -HOST_URI = URI.parse(host) -raw_certificate = File.read("#{CERTS_PATH}/testnode.crt") -certificate = OpenSSL::X509::Certificate.new(raw_certificate) -raw_key = File.read("#{CERTS_PATH}/testnode.key") -key = OpenSSL::PKey::RSA.new(raw_key) -ca_file = File.expand_path("#{CERTS_PATH}/ca.crt") -TRANSPORT_OPTIONS = { ssl: { verify: false, client_cert: certificate, client_key: key, ca_file: ca_file } } -HOST = "https://elastic:#{password}@#{HOST_URI.host}:#{HOST_URI.port}".freeze - -ADMIN_CLIENT = Elasticsearch::Client.new(host: HOST, transport_options: TRANSPORT_OPTIONS) - -RSpec.configure do |config| - config.add_formatter('documentation') - config.add_formatter('RSpec::Core::Formatters::HtmlFormatter', "tmp/platinum-integration.html") - config.color_mode = :on -end diff --git a/elasticsearch-api/spec/platinum/integration/service_accounts/service_accounts_spec.rb b/elasticsearch-api/spec/platinum/integration/service_accounts/service_accounts_spec.rb deleted file mode 100644 index d3c8a8bb48..0000000000 --- a/elasticsearch-api/spec/platinum/integration/service_accounts/service_accounts_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'Service Accounts API' do - context 'service account tokens' do - before do - - end - - after do - ADMIN_CLIENT.security.delete_service_token( - namespace: 'elastic', - service: 'fleet-server', - name: 'api-token-fleet' - ) - end - - it 'responds with health report' do - response = ADMIN_CLIENT.security.create_service_token( - namespace: 'elastic', - service: 'fleet-server', - name: 'api-token-fleet' - ) - expect(response.status).to eq 200 - expect(response['created']).to eq true - service_token_fleet = response['token']['value'] - headers = { 'Authorization' => "Bearer #{service_token_fleet}"} - client = Elasticsearch::Client.new( - host: HOST, - transport_options: TRANSPORT_OPTIONS.merge(headers: headers) - ) - response = client.security.authenticate - - expect(response.status).to eq 200 - expect(response['username']).to eq 'elastic/fleet-server' - expect(response['full_name']).to eq 'Service account - elastic/fleet-server' - - - expect do - client.security.delete_user(username: 'foo') - end.to raise_error Elastic::Transport::Transport::Errors::Forbidden - - response = ADMIN_CLIENT.security.get_service_credentials( - namespace: 'elastic', service: 'fleet-server' - ) - expect(response['service_account']).to eq 'elastic/fleet-server' - end - end -end diff --git a/elasticsearch-api/spec/platinum/integration/snapshots/snapshots_spec.rb b/elasticsearch-api/spec/platinum/integration/snapshots/snapshots_spec.rb deleted file mode 100644 index 755915fcdf..0000000000 --- a/elasticsearch-api/spec/platinum/integration/snapshots/snapshots_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'Snapshots API' do - before do - ADMIN_CLIENT.snapshot.create_repository( - repository: 'test_repo_restore_1', - body: { - type: 'source', - settings: { - delegate_type: 'fs', - location: "test_repo_restore_1_loc" - } - } - ) - ADMIN_CLIENT.indices.create( - index: index, - body: { - settings: { - number_of_shards: 1, - number_of_replicas: 0 - } - } - ) - end - - after do - ADMIN_CLIENT.indices.delete(index: 'test_index') - ADMIN_CLIENT.snapshot.delete(repository: 'test_repo_restore_1', snapshot: 'test_snapshot') - end - - let(:index) { 'test_index' } - - it 'creates a source only snapshot and then restores it' do - ADMIN_CLIENT.index(index: index, id: '1', body: { foo: 'bar' }) - ADMIN_CLIENT.indices.flush(index: index) - response = ADMIN_CLIENT.snapshot.create( - repository: 'test_repo_restore_1', - snapshot: 'test_snapshot', - wait_for_completion: true, - body: { "indices": "test_index" } - ) - expect(response.status).to eq 200 - expect(response['snapshot']['snapshot']).to eq 'test_snapshot' - expect(response['snapshot']['state']).to eq 'SUCCESS' - expect(response['snapshot']['version']).not_to be_nil - - ADMIN_CLIENT.indices.close(index: index) - ADMIN_CLIENT.snapshot.restore( - repository: 'test_repo_restore_1', - snapshot: 'test_snapshot', - wait_for_completion: true, - ) - response = ADMIN_CLIENT.indices.recovery(index: 'test_index') - expect(response.status).to eq 200 - expect(response['test_index']['shards'].first['type']).to eq 'SNAPSHOT' - expect(response['test_index']['shards'].first['stage']).to eq 'DONE' - response = ADMIN_CLIENT.search( - rest_total_hits_as_int: true, - index: index, - body: { query: { match_all: {} } } - ) - expect(response.status).to eq 200 - expect(response['hits']['total']).to eq 1 - expect(response['hits']['hits'].length).to eq 1 - expect(response['hits']['hits'].first['_id']).to eq '1' - end -end diff --git a/elasticsearch-api/spec/platinum/integration/token/token_spec.rb b/elasticsearch-api/spec/platinum/integration/token/token_spec.rb deleted file mode 100644 index 10c2fe589c..0000000000 --- a/elasticsearch-api/spec/platinum/integration/token/token_spec.rb +++ /dev/null @@ -1,94 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 '../platinum_helper' - -describe 'Token API' do - before do - ADMIN_CLIENT.security.put_role( - name: 'admin_role', - body: { cluster: ['manage_security'] } - ) - ADMIN_CLIENT.security.put_user( - username: 'token_user', - body: { - password: 'x-pack-test-password', - roles: [ 'admin_role' ], - full_name: 'Token user' - } - ) - end - - after do - ADMIN_CLIENT.security.delete_role(name: "admin_role", ignore: 404) - ADMIN_CLIENT.security.delete_user(username: "token_user", ignore: 404) - end - - it 'invalidates user token' do - response = ADMIN_CLIENT.security.get_token( - body: { grant_type: "password", username: "token_user", password: "x-pack-test-password" } - ) - - expect(response.status).to eq 200 - expect(response['type']).to eq 'Bearer' - expect(response['access_token']).not_to be_nil - access_token = response['access_token'] - client = Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS.merge( - headers: { Authorization: "Bearer #{access_token}" } - ) - ) - response = client.security.authenticate - expect(response.status).to eq 200 - expect(response['username']).to eq 'token_user' - expect(response['roles'].first).to eq 'admin_role' - ADMIN_CLIENT.security.invalidate_token( - body: { username: 'token_user' } - ) - - expect do - client.security.authenticate - end.to raise_error(Elastic::Transport::Transport::Errors::Unauthorized) - end - - it 'invalidates realm token' do - response = ADMIN_CLIENT.security.get_token( - body: { grant_type: "password", username: "token_user", password: "x-pack-test-password" } - ) - expect(response.status).to eq 200 - expect(response['type']).to eq 'Bearer' - expect(response['access_token']).not_to be_nil - access_token = response['access_token'] - client = Elasticsearch::Client.new( - host: "https://#{HOST_URI.host}:#{HOST_URI.port}", - transport_options: TRANSPORT_OPTIONS.merge( - headers: { Authorization: "Bearer #{access_token}" } - ) - ) - response = client.security.authenticate - expect(response.status).to eq 200 - expect(response['username']).to eq 'token_user' - expect(response['roles'].first).to eq 'admin_role' - response = ADMIN_CLIENT.security.invalidate_token(body: { realm_name: 'default_native' }) - expect(response.status).to eq 200 - - expect do - client.security.authenticate - end.to raise_error(Elastic::Transport::Transport::Errors::Unauthorized) - end -end diff --git a/elasticsearch-api/spec/platinum/unit/async_search/delete_test.rb b/elasticsearch-api/spec/platinum/unit/async_search/delete_test.rb deleted file mode 100644 index 7efcde4ced..0000000000 --- a/elasticsearch-api/spec/platinum/unit/async_search/delete_test.rb +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackAsyncSearchDelete < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Async Search Delete' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('DELETE', method) - assert_equal('_async_search/foo', url) - assert_equal({}, params) - assert_nil(body) - end.returns(FakeResponse.new) - - subject.async_search.delete(id: 'foo') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/async_search/get_test.rb b/elasticsearch-api/spec/platinum/unit/async_search/get_test.rb deleted file mode 100644 index 76b5df5f79..0000000000 --- a/elasticsearch-api/spec/platinum/unit/async_search/get_test.rb +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackAsyncSearchGet < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Async Search Get' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_async_search/foo', url) - assert_equal({}, params) - assert_nil(body) - end.returns(FakeResponse.new) - - subject.async_search.get(id: 'foo') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/async_search/status_test.rb b/elasticsearch-api/spec/platinum/unit/async_search/status_test.rb deleted file mode 100644 index c65ca5e1da..0000000000 --- a/elasticsearch-api/spec/platinum/unit/async_search/status_test.rb +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackAsyncSearchStatus < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Async Search Status' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_async_search/status/foo', url) - assert_equal({}, params) - assert_nil(body) - end.returns(FakeResponse.new) - - subject.async_search.status(id: 'foo') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/async_search/submit_test.rb b/elasticsearch-api/spec/platinum/unit/async_search/submit_test.rb deleted file mode 100644 index 89261a1dbb..0000000000 --- a/elasticsearch-api/spec/platinum/unit/async_search/submit_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackAsyncSearchSubmit < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Async Search Submit' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_async_search', url) - assert_equal({}, params) - assert_nil(body) - end.returns(FakeResponse.new) - - subject.async_search.submit - end - - should 'perform correct request with index' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('foo/_async_search', url) - assert_equal({}, params) - assert_nil(body) - end.returns(FakeResponse.new) - - subject.async_search.submit(index: 'foo') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/autoscaling/delete_autoscaling_policy_test.rb b/elasticsearch-api/spec/platinum/unit/autoscaling/delete_autoscaling_policy_test.rb deleted file mode 100644 index c973b47b43..0000000000 --- a/elasticsearch-api/spec/platinum/unit/autoscaling/delete_autoscaling_policy_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackAutoscalingDeleteAutoscalingPolicyTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Get Autoscaling Policy' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('DELETE', method) - assert_equal('_autoscaling/policy/a_policy', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.autoscaling.delete_autoscaling_policy(name: 'a_policy') - end - - should 'raise argument error without name' do - assert_raises ArgumentError do - subject.autoscaling.delete_autoscaling_policy - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/autoscaling/get_autoscaling_capacity_test.rb b/elasticsearch-api/spec/platinum/unit/autoscaling/get_autoscaling_capacity_test.rb deleted file mode 100644 index e9e2b8d196..0000000000 --- a/elasticsearch-api/spec/platinum/unit/autoscaling/get_autoscaling_capacity_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackAutoscalingGetAutoscalingCapacityTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Get Autoscaling Capacity' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_autoscaling/capacity', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.autoscaling.get_autoscaling_capacity - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/autoscaling/get_autoscaling_policy_test.rb b/elasticsearch-api/spec/platinum/unit/autoscaling/get_autoscaling_policy_test.rb deleted file mode 100644 index 0fc6a38125..0000000000 --- a/elasticsearch-api/spec/platinum/unit/autoscaling/get_autoscaling_policy_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackAutoscalingGetAutoscalingPolicyTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Get Autoscaling Policy' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_autoscaling/policy/a_policy', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.autoscaling.get_autoscaling_policy(name: 'a_policy') - end - - should 'raise argument error without name' do - assert_raises ArgumentError do - subject.autoscaling.get_autoscaling_policy - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/autoscaling/put_autoscaling_policy_test.rb b/elasticsearch-api/spec/platinum/unit/autoscaling/put_autoscaling_policy_test.rb deleted file mode 100644 index 409aec0aaa..0000000000 --- a/elasticsearch-api/spec/platinum/unit/autoscaling/put_autoscaling_policy_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackAutoscalingPutAutoscalingPolicyTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Put Autoscaling Policy' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('PUT', method) - assert_equal('_autoscaling/policy/a_policy', url) - assert_equal({}, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.autoscaling.put_autoscaling_policy(name: 'a_policy', body: {}) - end - - should 'raise argument error without name' do - assert_raises ArgumentError do - subject.autoscaling.put_autoscaling_policy(body: {}) - end - end - - should 'raise argument error without body' do - assert_raises ArgumentError do - subject.autoscaling.put_autoscaling_policy(name: 'a_policy') - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/enrich/delete_policy_test.rb b/elasticsearch-api/spec/platinum/unit/enrich/delete_policy_test.rb deleted file mode 100644 index 4f661d5cb2..0000000000 --- a/elasticsearch-api/spec/platinum/unit/enrich/delete_policy_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackEnrichDeletePolicyTest < Minitest::Test - - context "XPack Enrich: Delete policy" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_enrich/policy/foo', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.enrich.delete_policy(name: 'foo') - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/eql/delete_test.rb b/elasticsearch-api/spec/platinum/unit/eql/delete_test.rb deleted file mode 100644 index 202daa6cf6..0000000000 --- a/elasticsearch-api/spec/platinum/unit/eql/delete_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackEqlDeleteTest < Minitest::Test - context 'Eql: Delete' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_eql/search/foo', url - assert_equal({}, params) - assert_nil body - true - end.returns(FakeResponse.new) - - subject.eql.delete(id: 'foo') - end - - should 'raise argument error without id' do - assert_raises ArgumentError do - subject.eql.delete - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/eql/get_status_test.rb b/elasticsearch-api/spec/platinum/unit/eql/get_status_test.rb deleted file mode 100644 index 552cd30404..0000000000 --- a/elasticsearch-api/spec/platinum/unit/eql/get_status_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackEqlGetStatusTest < Minitest::Test - context 'Eql: Get Status' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_eql/search/status/foo', url - assert_equal({}, params) - assert_nil body - true - end.returns(FakeResponse.new) - - subject.eql.get_status(id: 'foo') - end - - should 'raise argument error without id' do - assert_raises ArgumentError do - subject.eql.get_status - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/eql/get_test.rb b/elasticsearch-api/spec/platinum/unit/eql/get_test.rb deleted file mode 100644 index 7f63be2e8a..0000000000 --- a/elasticsearch-api/spec/platinum/unit/eql/get_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackEqlGetTest < Minitest::Test - context 'Eql: Get' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_eql/search/foo', url - assert_equal({}, params) - assert_nil body - true - end.returns(FakeResponse.new) - - subject.eql.get(id: 'foo') - end - - should 'raise argument error without id' do - assert_raises ArgumentError do - subject.eql.get - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/eql/search_test.rb b/elasticsearch-api/spec/platinum/unit/eql/search_test.rb deleted file mode 100644 index 5b5bc3015d..0000000000 --- a/elasticsearch-api/spec/platinum/unit/eql/search_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackEqlSearchTest < Minitest::Test - context 'Eql: Search' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal 'foo/_eql/search', url - assert_equal({}, params) - assert_equal body, 'test' - true - end.returns(FakeResponse.new) - - subject.eql.search(index: 'foo', body: 'test') - end - - should 'raise argument error without body' do - assert_raises ArgumentError do - subject.eql.search(index: 'foo') - end - end - - should 'raise argument error without index' do - assert_raises ArgumentError do - subject.eql.search(body: 'test') - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/graph/explore_test.rb b/elasticsearch-api/spec/platinum/unit/graph/explore_test.rb deleted file mode 100644 index 0d9d581ca3..0000000000 --- a/elasticsearch-api/spec/platinum/unit/graph/explore_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class GraphExploreTest < Minitest::Test - - context "Graph: Explore" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal 'my_index/_graph/explore', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.graph.explore(index: 'my_index') - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/explain_test.rb b/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/explain_test.rb deleted file mode 100644 index 6dbe35d209..0000000000 --- a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/explain_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndexLifecycleManagementExplainTest < Minitest::Test - - context "XPack Index Lifecycle Management: explain" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal 'foo/_ilm/explain', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ilm.explain_lifecycle(index: 'foo') - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/get_status_test.rb b/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/get_status_test.rb deleted file mode 100644 index 069e84bcf9..0000000000 --- a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/get_status_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndexLifecycleManagementGetStatusTest < Minitest::Test - - context "XPack Index Lifecycle Management: Get status" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_ilm/status', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ilm.get_status - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/move_to_step.rb b/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/move_to_step.rb deleted file mode 100644 index 273ef80c5b..0000000000 --- a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/move_to_step.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndexLifecycleManagementMoveStepTest < Minitest::Test - - context "XPack Index Lifecycle Management: Move to step" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_ilm/move/foo', url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ilm.move_to_step :index => 'foo', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/remove_policy_test.rb b/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/remove_policy_test.rb deleted file mode 100644 index 29da1c4a98..0000000000 --- a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/remove_policy_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndexLifecycleManagementRemovePolicyTest < Minitest::Test - - context "XPack Index Lifecycle Management: Remove policy" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal 'foo/_ilm/remove', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ilm.remove_policy :index => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/retry_policy_test.rb b/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/retry_policy_test.rb deleted file mode 100644 index 8b5593dfb5..0000000000 --- a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/retry_policy_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndexLifecycleManagementRetryTest < Minitest::Test - - context "XPack Index Lifecycle Management: retry" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal 'foo/_ilm/retry', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ilm.retry(index: 'foo') - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/start_test.rb b/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/start_test.rb deleted file mode 100644 index cc393a0ff2..0000000000 --- a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/start_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndexLifecycleManagementStartTest < Minitest::Test - - context "XPack Index Lifecycle Management: start" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_ilm/start', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ilm.start - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/stop_test.rb b/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/stop_test.rb deleted file mode 100644 index 0f51d8aec2..0000000000 --- a/elasticsearch-api/spec/platinum/unit/index_lifecycle_management/stop_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndexLifecycleManagementStopTest < Minitest::Test - - context "XPack Index Lifecycle Management: stop" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_ilm/stop', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ilm.stop - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/indices/create_data_stream_test.rb b/elasticsearch-api/spec/platinum/unit/indices/create_data_stream_test.rb deleted file mode 100644 index 04ba1fd10d..0000000000 --- a/elasticsearch-api/spec/platinum/unit/indices/create_data_stream_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndicesCreateDataStreamTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Create Data Stream' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('PUT', method) - assert_equal('_data_stream/foo', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.indices.create_data_stream(name: 'foo') - end - - should 'raise argument error without name' do - assert_raises ArgumentError do - subject.indices.create_data_stream - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/indices/data_stream_stats_test.rb b/elasticsearch-api/spec/platinum/unit/indices/data_stream_stats_test.rb deleted file mode 100644 index de4efba9d0..0000000000 --- a/elasticsearch-api/spec/platinum/unit/indices/data_stream_stats_test.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndicesDataStreamStatsTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Data Stream Stats' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_data_stream/_stats', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.indices.data_streams_stats - end - end - - context 'when name is specified' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_data_stream/foo/_stats', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.indices.data_streams_stats(name: 'foo') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/indices/delete_data_stream_test.rb b/elasticsearch-api/spec/platinum/unit/indices/delete_data_stream_test.rb deleted file mode 100644 index c8d4233783..0000000000 --- a/elasticsearch-api/spec/platinum/unit/indices/delete_data_stream_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndicesDeleteDataStreamTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Delete Data Stream' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('DELETE', method) - assert_equal('_data_stream/foo', url) - assert_equal({}, params) - assert_nil(body) - end.returns(FakeResponse.new) - - subject.indices.delete_data_stream(name: 'foo') - end - end - - - should 'raise argument error without name' do - assert_raises ArgumentError do - subject.indices.create_data_stream - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/indices/downsample_test.rb b/elasticsearch-api/spec/platinum/unit/indices/downsample_test.rb deleted file mode 100644 index 4b6e917907..0000000000 --- a/elasticsearch-api/spec/platinum/unit/indices/downsample_test.rb +++ /dev/null @@ -1,58 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class IndicesDownsampleTest < Minitest::Test - context "Indices Downsample: Downsample an index" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('foo/_downsample/bar', url) - assert_equal({}, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.indices.downsample(body: {}, index: 'foo', target_index: 'bar') - end - - should 'raise argument error without body' do - assert_raises ArgumentError do - subject.indices.downsample(index: 'foo', target_index: 'bar') - end - end - - should 'raise argument error without index' do - assert_raises ArgumentError do - subject.indices.downsample(body: {}, target_index: 'bar') - end - end - - should 'raise argument error without rollup_index' do - assert_raises ArgumentError do - subject.indices.downsample(body: {}, index: 'foo') - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/indices/get_data_stream_test.rb b/elasticsearch-api/spec/platinum/unit/indices/get_data_stream_test.rb deleted file mode 100644 index 38d3c828cd..0000000000 --- a/elasticsearch-api/spec/platinum/unit/indices/get_data_stream_test.rb +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndicesGetDataStreamTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Get Data Stream' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_data_stream', url) - assert_equal({}, params) - assert_nil(body) - end.returns(FakeResponse.new) - - subject.indices.get_data_stream - end - end - - context 'Get Data Stream with name' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_data_stream/foo', url) - end.returns(FakeResponse.new) - - subject.indices.get_data_stream(name: 'foo') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/indices/migrate_to_data_stream_test.rb b/elasticsearch-api/spec/platinum/unit/indices/migrate_to_data_stream_test.rb deleted file mode 100644 index c9b4151571..0000000000 --- a/elasticsearch-api/spec/platinum/unit/indices/migrate_to_data_stream_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndicesMigrateToDataStream < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Migrate to Data Stream' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_data_stream/_migrate/foo', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.indices.migrate_to_data_stream(name: 'foo') - end - - should 'raise argument error without name' do - assert_raises ArgumentError do - subject.indices.create_data_stream - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/indices/modify_data_stream_test.rb b/elasticsearch-api/spec/platinum/unit/indices/modify_data_stream_test.rb deleted file mode 100644 index 79a5c23f3e..0000000000 --- a/elasticsearch-api/spec/platinum/unit/indices/modify_data_stream_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndicesModifyDataStreamTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Modify Data Stream' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_data_stream/_modify', url) - assert_equal({}, params) - assert_equal({}, body) - true - end.returns(FakeResponse.new) - - subject.indices.modify_data_stream(body: {}) - end - - should 'raise argument error without name' do - assert_raises ArgumentError do - subject.indices.modify_data_stream - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/indices/promote_data_stream_test.rb b/elasticsearch-api/spec/platinum/unit/indices/promote_data_stream_test.rb deleted file mode 100644 index c9e787fd1d..0000000000 --- a/elasticsearch-api/spec/platinum/unit/indices/promote_data_stream_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackIndicesPromoteDataStreamTest < Minitest::Test - subject { FakeClient.new } - - context 'XPack: Promote Data Stream' do - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_data_stream/_promote/foo', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.indices.promote_data_stream(name: 'foo') - end - - should 'raise argument error without name' do - assert_raises ArgumentError do - subject.indices.promote_data_stream - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/info_test.rb b/elasticsearch-api/spec/platinum/unit/info_test.rb deleted file mode 100644 index 066b9b6fb2..0000000000 --- a/elasticsearch-api/spec/platinum/unit/info_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackInfoTest < Minitest::Test - context "XPack: Info" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_xpack', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.xpack.info - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/knn_search_test.rb b/elasticsearch-api/spec/platinum/unit/knn_search_test.rb deleted file mode 100644 index 341dd2e563..0000000000 --- a/elasticsearch-api/spec/platinum/unit/knn_search_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackInfoTest < Minitest::Test - context 'Knn Search' do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('foo/_knn_search', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.knn_search(index: 'foo') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/license/delete_test.rb b/elasticsearch-api/spec/platinum/unit/license/delete_test.rb deleted file mode 100644 index 2ddfc49771..0000000000 --- a/elasticsearch-api/spec/platinum/unit/license/delete_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackLicenseDeleteTest < Minitest::Test - - context "License: Delete" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_license', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.license.delete - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/license/get_test.rb b/elasticsearch-api/spec/platinum/unit/license/get_test.rb deleted file mode 100644 index 494de8d0ae..0000000000 --- a/elasticsearch-api/spec/platinum/unit/license/get_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackLicenseGetTest < Minitest::Test - - context "License: Get" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_license', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.license.get - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/license/post_test.rb b/elasticsearch-api/spec/platinum/unit/license/post_test.rb deleted file mode 100644 index f9a4163041..0000000000 --- a/elasticsearch-api/spec/platinum/unit/license/post_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackLicensePostTest < Minitest::Test - - context "License: Post" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_license', url - assert_equal Hash.new, params - assert_equal [], body - true - end.returns(FakeResponse.new) - - subject.license.post body: [] - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/logstash/delete_pipeline_test.rb b/elasticsearch-api/spec/platinum/unit/logstash/delete_pipeline_test.rb deleted file mode 100644 index 21e6d955d3..0000000000 --- a/elasticsearch-api/spec/platinum/unit/logstash/delete_pipeline_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackLogstashDeletePipelineTest < Minitest::Test - context 'Logstash: Delete Pipeline' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_logstash/pipeline/foo', url - assert_equal({}, params) - assert_nil body - true - end.returns(FakeResponse.new) - - subject.logstash.delete_pipeline(id: 'foo') - end - - should 'raise argument error without id' do - assert_raises ArgumentError do - subject.logstash.delete_pipeline - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/logstash/get_pipeline_test.rb b/elasticsearch-api/spec/platinum/unit/logstash/get_pipeline_test.rb deleted file mode 100644 index d0d6dc3161..0000000000 --- a/elasticsearch-api/spec/platinum/unit/logstash/get_pipeline_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackLogstashGetPipelineTest < Minitest::Test - context 'Logstash: Get Pipeline' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_logstash/pipeline/foo', url - assert_equal({}, params) - assert_nil body - true - end.returns(FakeResponse.new) - - subject.logstash.get_pipeline(id: 'foo') - end - - should 'raise argument error without id' do - assert_raises ArgumentError do - subject.logstash.get_pipeline - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/logstash/put_pipeline_test.rb b/elasticsearch-api/spec/platinum/unit/logstash/put_pipeline_test.rb deleted file mode 100644 index c42e269553..0000000000 --- a/elasticsearch-api/spec/platinum/unit/logstash/put_pipeline_test.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackLogstashPutPipelineTest < Minitest::Test - context 'Logstash: Put Pipeline' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_logstash/pipeline/foo', url - assert_equal({}, params) - assert_equal({}, body) - true - end.returns(FakeResponse.new) - - subject.logstash.put_pipeline(id: 'foo', body: {}) - end - - should 'raise argument error without body' do - assert_raises ArgumentError do - subject.logstash.put_pipeline(id: 'foo') - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/clear_trained_model_deployment_cache_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/clear_trained_model_deployment_cache_test.rb deleted file mode 100644 index 97d398aa19..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/clear_trained_model_deployment_cache_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class MachineLearningClearTrainedModelDeploymentCacheTest < Minitest::Test - context 'Machine Learning: Clear trained model deployment cache' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_ml/trained_models/model/deployment/cache/_clear', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.ml.clear_trained_model_deployment_cache(model_id: 'model') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/close_job_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/close_job_test.rb deleted file mode 100644 index 80a4adaeab..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/close_job_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlCloseJobTest < Minitest::Test - - context "XPack MachineLearning: Close job" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/foo/_close", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.close_job :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_datafeed_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/delete_datafeed_test.rb deleted file mode 100644 index 2c6a905069..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_datafeed_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlDeleteDatafeedTest < Minitest::Test - - context "XPack MachineLearning: Delete datafeed" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal "_ml/datafeeds/foo", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.delete_datafeed :datafeed_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_expired_data_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/delete_expired_data_test.rb deleted file mode 100644 index 4e22eac168..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_expired_data_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlDeleteExpiredDataTest < Minitest::Test - - context "XPack MachineLearning: Delete expired data" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal "_ml/_delete_expired_data", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.delete_expired_data - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_filter_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/delete_filter_test.rb deleted file mode 100644 index a65ee8e9c7..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_filter_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlDeleteFilterTest < Minitest::Test - - context "XPack MachineLearning: Delete filter" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal "_ml/filters/foo", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.delete_filter :filter_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_forecast_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/delete_forecast_test.rb deleted file mode 100644 index 753852d1c5..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_forecast_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlDeleteForecastTest < Minitest::Test - - context "XPack MachineLearning: Delete forecast" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal "_ml/anomaly_detectors/foo/_forecast", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.delete_forecast :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_job_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/delete_job_test.rb deleted file mode 100644 index 2692743f86..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_job_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlDeleteJobTest < Minitest::Test - - context "XPack MachineLearning: Delete job" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal "_ml/anomaly_detectors/foo", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.delete_job :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_model_alias_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/delete_model_alias_test.rb deleted file mode 100644 index 0e8523256d..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_model_alias_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlDeleteTrainedModelAliasTest < Minitest::Test - context "XPack MachineLearning: Delete trained model alias" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('DELETE', method) - assert_equal("_ml/trained_models/foo/model_aliases/alias", url) - assert_equal(Hash.new, params) - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.delete_trained_model_alias(model_id: 'foo', model_alias: 'alias') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_model_snapshot_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/delete_model_snapshot_test.rb deleted file mode 100644 index 6a1fe0d1f7..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/delete_model_snapshot_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlDeleteModelSnapshotTest < Minitest::Test - - context "XPack MachineLearning: Delete model snapshot" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal "_ml/anomaly_detectors/foo/model_snapshots/bar", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.delete_model_snapshot :job_id => 'foo', :snapshot_id => 'bar' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/flush_job_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/flush_job_test.rb deleted file mode 100644 index 2a315637cd..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/flush_job_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlFlushJobTest < Minitest::Test - - context "XPack MachineLearning: Flush job" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/foo/_flush", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.flush_job :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/forecast_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/forecast_test.rb deleted file mode 100644 index b41eb52bbf..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/forecast_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlForecastTest < Minitest::Test - - context "XPack MachineLearning: Forecast" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_ml/anomaly_detectors/foo/_forecast', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.forecast :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_buckets_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_buckets_test.rb deleted file mode 100644 index 4394331b89..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_buckets_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetBucketsTest < Minitest::Test - - context "XPack MachineLearning: Get buckets" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/anomaly_detectors/foo/results/buckets", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_buckets :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_categories_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_categories_test.rb deleted file mode 100644 index 2847f522a8..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_categories_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetCategoriesTest < Minitest::Test - - context "XPack MachineLearning: Get categories" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/anomaly_detectors/foo/results/categories", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_categories :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_datafeed_stats_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_datafeed_stats_test.rb deleted file mode 100644 index c997e99efe..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_datafeed_stats_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetDatafeedStatsTest < Minitest::Test - - context "XPack MachineLearning: Get datafeed stats" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/datafeeds/_stats", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_datafeed_stats - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_datafeeds_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_datafeeds_test.rb deleted file mode 100644 index 41769681c5..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_datafeeds_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetDatafeedsTest < Minitest::Test - - context "XPack MachineLearning: Get datafeeds" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/datafeeds/foo", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_datafeeds :datafeed_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_filters_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_filters_test.rb deleted file mode 100644 index 41f85943bc..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_filters_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetFiltersTest < Minitest::Test - - context "XPack MachineLearning: Get filters" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/filters/foo", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_filters :filter_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_influencers_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_influencers_test.rb deleted file mode 100644 index c409d38b04..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_influencers_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetInfluencersTest < Minitest::Test - - context "XPack MachineLearning: Get influencers" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/anomaly_detectors/foo/results/influencers", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_influencers :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_job_stats_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_job_stats_test.rb deleted file mode 100644 index 08de0c35f0..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_job_stats_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetJobStatsTest < Minitest::Test - - context "XPack MachineLearning: Get job stats" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/anomaly_detectors/foo/_stats", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_job_stats :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_jobs_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_jobs_test.rb deleted file mode 100644 index 80be74726c..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_jobs_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetJobsTest < Minitest::Test - - context "XPack MachineLearning: Get jobs" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/anomaly_detectors/foo", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_jobs :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_model_snapshots_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_model_snapshots_test.rb deleted file mode 100644 index 840f38e8f4..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_model_snapshots_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetModelSnapshotsTest < Minitest::Test - - context "XPack MachineLearning: Get model snapshots" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/anomaly_detectors/foo/model_snapshots/bar", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_model_snapshots :job_id => 'foo', :snapshot_id => 'bar' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_overall_buckets_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_overall_buckets_test.rb deleted file mode 100644 index e47463f601..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_overall_buckets_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetOverallBucketsTest < Minitest::Test - - context "XPack MachineLearning: Get overall buckets" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_ml/anomaly_detectors/foo/results/overall_buckets', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_overall_buckets :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/get_records_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/get_records_test.rb deleted file mode 100644 index 3ffab1e62d..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/get_records_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlGetRecordsTest < Minitest::Test - - context "XPack MachineLearning: Get records" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/anomaly_detectors/foo/results/records", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.get_records :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/open_job_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/open_job_test.rb deleted file mode 100644 index 1e3338cb08..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/open_job_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlOpenJobTest < Minitest::Test - - context "XPack MachineLearning: Open job" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/foo/_open", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.open_job :job_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/post_data_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/post_data_test.rb deleted file mode 100644 index e78a00a131..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/post_data_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlPostDataTest < Minitest::Test - - context "XPack MachineLearning: Post data" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/foo/_data", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.post_data :job_id => 'foo', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/preview_data_frame_analytics_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/preview_data_frame_analytics_test.rb deleted file mode 100644 index e45965ac90..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/preview_data_frame_analytics_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlPreviewDataFrameAnalyticsTest < Minitest::Test - context 'XPack MachineLearning: Preview data frame analytics' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_ml/data_frame/analytics/_preview', url) - assert_equal(Hash.new, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.ml.preview_data_frame_analytics - end - - should 'perform correct request with body' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_ml/data_frame/analytics/_preview', url) - assert_equal(Hash.new, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.ml.preview_data_frame_analytics(body: {}) - end - - should 'perform correct request with id' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_ml/data_frame/analytics/3/_preview', url) - assert_equal(Hash.new, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.ml.preview_data_frame_analytics(id: 3) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/preview_datafeed_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/preview_datafeed_test.rb deleted file mode 100644 index ff2eba29c1..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/preview_datafeed_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlPreviewDatafeedTest < Minitest::Test - - context "XPack MachineLearning: Preview datafeed" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_ml/datafeeds/foo/_preview", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.preview_datafeed :datafeed_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/put_datafeed_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/put_datafeed_test.rb deleted file mode 100644 index 15eebb4a45..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/put_datafeed_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlPutDatafeedTest < Minitest::Test - - context "XPack MachineLearning: Put datafeed" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal "_ml/datafeeds/foo", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.put_datafeed :datafeed_id => 'foo', body: {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/put_filter_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/put_filter_test.rb deleted file mode 100644 index d51748b7c5..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/put_filter_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlPutFilterTest < Minitest::Test - - context "XPack MachineLearning: Put filter" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal "_ml/filters/foo", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.put_filter :filter_id => 'foo', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/put_job_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/put_job_test.rb deleted file mode 100644 index 4a105c12b3..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/put_job_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlPutJobTest < Minitest::Test - - context "XPack MachineLearning: Put job" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal "_ml/anomaly_detectors/foo", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.put_job :job_id => 'foo', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/put_trained_model_alias_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/put_trained_model_alias_test.rb deleted file mode 100644 index c62f4fe424..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/put_trained_model_alias_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlPutTrainedModelAliasTest < Minitest::Test - context "XPack MachineLearning: Put trained model alias" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('PUT', method) - assert_equal("_ml/trained_models/foo/model_aliases/alias", url) - assert_equal(Hash.new, params) - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.put_trained_model_alias(model_id: 'foo', model_alias: 'alias') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/revert_model_snapshot_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/revert_model_snapshot_test.rb deleted file mode 100644 index 2d4dd6de1f..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/revert_model_snapshot_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlRevertModelSnapshotTest < Minitest::Test - - context "XPack MachineLearning: Revert model snapshot" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/foo/model_snapshots/bar/_revert", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.revert_model_snapshot :job_id => 'foo', :snapshot_id => 'bar' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/start_datafeed_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/start_datafeed_test.rb deleted file mode 100644 index b090ead16c..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/start_datafeed_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlStartDatafeedTest < Minitest::Test - - context "XPack MachineLearning: Start datafeed" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/datafeeds/foo/_start", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.start_datafeed :datafeed_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/stop_datafeed_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/stop_datafeed_test.rb deleted file mode 100644 index 0dcafd675e..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/stop_datafeed_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlStopDatafeedTest < Minitest::Test - - context "XPack MachineLearning: Stop datafeed" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/datafeeds/foo/_stop", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.stop_datafeed :datafeed_id => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/update_data_frame_analytics_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/update_data_frame_analytics_test.rb deleted file mode 100644 index e7afb9227c..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/update_data_frame_analytics_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlUpdateDataFrameAnalyticsTest < Minitest::Test - context "XPack MachineLearning: Update data frame analytics" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/data_frame/analytics/foo/_update", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.update_data_frame_analytics id: 'foo', body: {} - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/update_datafeed_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/update_datafeed_test.rb deleted file mode 100644 index c509520f3b..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/update_datafeed_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlUpdateDatafeedTest < Minitest::Test - - context "XPack MachineLearning: Update datafeed" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/datafeeds/foo/_update", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.update_datafeed :datafeed_id => 'foo', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/update_filter_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/update_filter_test.rb deleted file mode 100644 index 7b58b0eb21..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/update_filter_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlUpdateFilterTest < Minitest::Test - - context "XPack MachineLearning: Update filter" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/filters/foo/_update", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.update_filter :filter_id => 'foo', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/update_job_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/update_job_test.rb deleted file mode 100644 index 15f55690ed..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/update_job_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlUpdateJobTest < Minitest::Test - - context "XPack MachineLearning: Update job" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/foo/_update", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.update_job :job_id => 'foo', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/update_model_snapshot_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/update_model_snapshot_test.rb deleted file mode 100644 index 9cf4081018..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/update_model_snapshot_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlUpdateModelSnapshotTest < Minitest::Test - - context "XPack MachineLearning: Update model snapshot" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/foo/model_snapshots/bar/_update", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.update_model_snapshot :job_id => 'foo', :snapshot_id => 'bar', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/upgrade_job_snapshot_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/upgrade_job_snapshot_test.rb deleted file mode 100644 index 94b8f1c1d1..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/upgrade_job_snapshot_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlUpdateJobSnapshotTest < Minitest::Test - - context "XPack MachineLearning: Upgrade job snapshot" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/foo/model_snapshots/bar/_upgrade", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ml.upgrade_job_snapshot(job_id: 'foo', snapshot_id: 'bar') - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/validate_detector_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/validate_detector_test.rb deleted file mode 100644 index 474535a82d..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/validate_detector_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlValidateDetectorTest < Minitest::Test - - context "XPack MachineLearning: Validate detector" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/_validate/detector", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.validate_detector :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/machine_learning/validate_test.rb b/elasticsearch-api/spec/platinum/unit/machine_learning/validate_test.rb deleted file mode 100644 index 78a9650628..0000000000 --- a/elasticsearch-api/spec/platinum/unit/machine_learning/validate_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMlValidateTest < Minitest::Test - - context "XPack MachineLearning: Validate" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_ml/anomaly_detectors/_validate", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.ml.validate :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/migration/deprecations_test.rb b/elasticsearch-api/spec/platinum/unit/migration/deprecations_test.rb deleted file mode 100644 index bfda05b72a..0000000000 --- a/elasticsearch-api/spec/platinum/unit/migration/deprecations_test.rb +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMigrationDeprecationsTest < Minitest::Test - context "XPack Migration: Deprecations" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_migration/deprecations', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.migration.deprecations - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/monitoring/bulk_test.rb b/elasticsearch-api/spec/platinum/unit/monitoring/bulk_test.rb deleted file mode 100644 index 62d6868794..0000000000 --- a/elasticsearch-api/spec/platinum/unit/monitoring/bulk_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackMonitoringBulkTest < Minitest::Test - - context "XPack Monitoring: Bulk" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_monitoring/bulk', url - assert_equal Hash.new, params - assert_equal "", body - true - end.returns(FakeResponse.new) - - subject.monitoring.bulk body: [] - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/rollup/get_rollup_index_caps_test.rb b/elasticsearch-api/spec/platinum/unit/rollup/get_rollup_index_caps_test.rb deleted file mode 100644 index f0b9bc35e0..0000000000 --- a/elasticsearch-api/spec/platinum/unit/rollup/get_rollup_index_caps_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackGetRollupIndexCapsTest < Minitest::Test - context "XPack Rollup: Get index caps" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "foo/_rollup/data", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.rollup.get_rollup_index_caps :index => 'foo' - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/activate_user_profile_test.rb b/elasticsearch-api/spec/platinum/unit/security/activate_user_profile_test.rb deleted file mode 100644 index 02af83e72d..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/activate_user_profile_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class SecurityAuthenticateTest < Minitest::Test - context 'Security: Activate User Profile' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_security/profile/_activate', url) - assert_equal({}, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.security.activate_user_profile(body: {}) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/authenticate_test.rb b/elasticsearch-api/spec/platinum/unit/security/authenticate_test.rb deleted file mode 100644 index 8e40d4bee9..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/authenticate_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityAuthenticateTest < Minitest::Test - - context "XPack Security: Authenticate" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/_authenticate', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.authenticate - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/bulk_update_api_key_test.rb b/elasticsearch-api/spec/platinum/unit/security/bulk_update_api_key_test.rb deleted file mode 100644 index bb37d59589..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/bulk_update_api_key_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class SecurityBulkUpdateApiKeys < Minitest::Test - context 'Security: Bulk Update Api Keys' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_security/api_key/_bulk_update', url) - assert_equal({}, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.security.bulk_update_api_keys(body: {}) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/change_password_test.rb b/elasticsearch-api/spec/platinum/unit/security/change_password_test.rb deleted file mode 100644 index 69aa130903..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/change_password_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityChangePasswordTest < Minitest::Test - - context "XPack Security: Change password" do - subject { FakeClient.new } - - should "perform correct request for a specific user" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_security/user/foo/_password', url - assert_equal Hash.new, params - assert_equal 'bar', body[:password] - true - end.returns(FakeResponse.new) - - subject.security.change_password username: 'foo', body: { password: 'bar' } - end - - should "perform correct request for current user" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_security/user/_password', url - assert_equal Hash.new, params - assert_equal 'bar', body[:password] - true - end.returns(FakeResponse.new) - - subject.security.change_password body: { password: 'bar' } - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/clear_api_key_cache_test.rb b/elasticsearch-api/spec/platinum/unit/security/clear_api_key_cache_test.rb deleted file mode 100644 index c0539a65ff..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/clear_api_key_cache_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityClearCachedRolesTest < Minitest::Test - context 'XPack Security: Clear api key cache' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_security/api_key/3/_clear_cache', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.clear_api_key_cache(ids: '3') - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/clear_cached_privileges_test.rb b/elasticsearch-api/spec/platinum/unit/security/clear_cached_privileges_test.rb deleted file mode 100644 index b03354dc08..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/clear_cached_privileges_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityClearCachedPrivilegesTest < Minitest::Test - context "XPack Security: Clear cached privileges" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_security/privilege/test/_clear_cache", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.clear_cached_privileges application: 'test' - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/clear_cached_realms_test.rb b/elasticsearch-api/spec/platinum/unit/security/clear_cached_realms_test.rb deleted file mode 100644 index d245a9edce..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/clear_cached_realms_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityClearCachedRealmsTest < Minitest::Test - - context "XPack Security: Clear cached realms" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_security/realm/foo,bar/_clear_cache", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.clear_cached_realms :realms => ['foo', 'bar'] - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/clear_cached_roles_test.rb b/elasticsearch-api/spec/platinum/unit/security/clear_cached_roles_test.rb deleted file mode 100644 index 3c797ce291..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/clear_cached_roles_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityClearCachedRolesTest < Minitest::Test - - context "XPack Security: Clear cached roles" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_security/role/foo/_clear_cache', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.clear_cached_roles :name => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/delete_privileges_test.rb b/elasticsearch-api/spec/platinum/unit/security/delete_privileges_test.rb deleted file mode 100644 index 4742c40a6b..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/delete_privileges_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityDeletePrivilegesTest < Minitest::Test - - context "XPack Security: Delete privileges" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_security/privilege/foo/bar', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.delete_privileges :application => 'foo', name: 'bar' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/delete_role_mapping_test.rb b/elasticsearch-api/spec/platinum/unit/security/delete_role_mapping_test.rb deleted file mode 100644 index 8cf05543b3..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/delete_role_mapping_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityDeleteRoleMappingTest < Minitest::Test - - context "XPack Security: Delete role mapping" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_security/role_mapping/foo', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.delete_role_mapping :name => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/delete_role_test.rb b/elasticsearch-api/spec/platinum/unit/security/delete_role_test.rb deleted file mode 100644 index a3e76c1c97..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/delete_role_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityDeleteRoleTest < Minitest::Test - - context "XPack Security: Delete role" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_security/role/foo', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.delete_role :name => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/delete_user_test.rb b/elasticsearch-api/spec/platinum/unit/security/delete_user_test.rb deleted file mode 100644 index 5ffeef5904..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/delete_user_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityDeleteUserTest < Minitest::Test - - context "XPack Security: Delete user" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_security/user/foo', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.delete_user :username => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/disable_user_test.rb b/elasticsearch-api/spec/platinum/unit/security/disable_user_test.rb deleted file mode 100644 index 37d235308a..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/disable_user_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityDisableUserTest < Minitest::Test - - context "XPack Security: Disable user" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal "_security/user/foo/_disable", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.disable_user :username => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/enable_user_test.rb b/elasticsearch-api/spec/platinum/unit/security/enable_user_test.rb deleted file mode 100644 index c738ac9086..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/enable_user_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityEnableUserTest < Minitest::Test - - context "XPack Security: Enable user" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal "_security/user/foo/_enable", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.enable_user :username => 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/get_privileges_test.rb b/elasticsearch-api/spec/platinum/unit/security/get_privileges_test.rb deleted file mode 100644 index 72ef116e56..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/get_privileges_test.rb +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityGetPrivilegesTest < Minitest::Test - - context "XPack Security: Get privileges" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/privilege', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_privileges - end - - should "perform correct request for an application but no name" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/privilege/foo', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_privileges application: 'foo' - end - - should "perform correct request for an application and a single name" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/privilege/foo/bar', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_privileges application: 'foo', name: 'bar' - end - - should "perform correct request for an application and multiple names" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/privilege/foo/bar,baz', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_privileges application: 'foo', name: ['bar', 'baz'] - end - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/get_role_mapping_test.rb b/elasticsearch-api/spec/platinum/unit/security/get_role_mapping_test.rb deleted file mode 100644 index 75fdf41c93..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/get_role_mapping_test.rb +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityGetRoleMappingTest < Minitest::Test - - context "XPack Security: Get role mapping" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_security/role_mapping/foo", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_role_mapping :name => 'foo' - end - - should "handle a list of roles" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_security/role_mapping/foo,bar", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_role_mapping :name => ['foo', 'bar'] - end - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/get_role_test.rb b/elasticsearch-api/spec/platinum/unit/security/get_role_test.rb deleted file mode 100644 index e76128dede..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/get_role_test.rb +++ /dev/null @@ -1,62 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityGetRoleTest < Minitest::Test - - context "XPack Security: Get role" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/role', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_role - end - - should "perform correct request for multiple roles" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/role/foo,bar', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_role name: ['foo', 'bar'] - end - - should "catch a NotFound exception with the ignore parameter" do - subject.expects(:perform_request).raises(NotFound) - - assert_nothing_raised do - subject.security.get_role name: 'foo', ignore: 404 - end - end - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/get_token_test.rb b/elasticsearch-api/spec/platinum/unit/security/get_token_test.rb deleted file mode 100644 index ebb7a77053..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/get_token_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityGetTokenTest < Minitest::Test - - context "XPack Security: Get token" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal "_security/oauth2/token", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.security.get_token :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/get_user_privileges_test.rb b/elasticsearch-api/spec/platinum/unit/security/get_user_privileges_test.rb deleted file mode 100644 index 42b909a7f9..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/get_user_privileges_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityGetUserPrivilegesTest < Minitest::Test - - context "XPack Security: Get user privileges" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal "_security/user/_privileges", url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_user_privileges - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/get_user_profile_test.rb b/elasticsearch-api/spec/platinum/unit/security/get_user_profile_test.rb deleted file mode 100644 index 4b38340354..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/get_user_profile_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class SecurityGetUserProfileTest < Minitest::Test - context 'Security: Get User Profile' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_security/profile/1', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.security.get_user_profile(uid: 1) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/get_user_test.rb b/elasticsearch-api/spec/platinum/unit/security/get_user_test.rb deleted file mode 100644 index 8a0e036429..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/get_user_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityGetUserTest < Minitest::Test - - context "XPack Security: Get user" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/user', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_user - end - - should "perform correct request for multiple roles" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_security/user/foo,bar', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.security.get_user username: ['foo', 'bar'] - end - - should "catch a NotFound exception with the ignore parameter" do - subject.expects(:perform_request).raises(NotFound) - - assert_nothing_raised do - subject.security.get_user username: 'foo', ignore: 404 - end - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/grant_api_key_test.rb b/elasticsearch-api/spec/platinum/unit/security/grant_api_key_test.rb deleted file mode 100644 index da372a01ed..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/grant_api_key_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityGrantApiKey < Minitest::Test - context "XPack Security: Grant API Key" do - subject { FakeClient.new } - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_security/api_key/grant', url) - assert_equal(Hash.new, params) - assert_equal(body, {access_token: 'access_token', api_key: 'api_key', grant_type: 'access_token'}) - true - end.returns(FakeResponse.new) - - subject.security.grant_api_key( - body: {access_token: 'access_token', api_key: 'api_key', grant_type: 'access_token'} - ) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/has_privileges_test.rb b/elasticsearch-api/spec/platinum/unit/security/has_privileges_test.rb deleted file mode 100644 index 9c1a250550..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/has_privileges_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityHasPrivilegesTest < Minitest::Test - - context "XPack Security: Has Privileges" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_security/user/_has_privileges', url - assert_equal Hash.new, params - assert_equal({ cluster: [], index: [], application: [] }, body) - true - end.returns(FakeResponse.new) - - subject.security.has_privileges(body: { cluster: [], index: [], application: [] }) - end - - should "check privileges for a specific user" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_security/user/foo/_has_privileges', url - assert_equal Hash.new, params - assert_equal({ cluster: [], index: [], application: [] }, body) - true - end.returns(FakeResponse.new) - - subject.security.has_privileges(user: 'foo', body: { cluster: [], index: [], application: [] }) - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/invalidate_token_test.rb b/elasticsearch-api/spec/platinum/unit/security/invalidate_token_test.rb deleted file mode 100644 index 797650c4fe..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/invalidate_token_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityInvalidateTokenTest < Minitest::Test - - context "XPack Security: Invalidate token" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal "_security/oauth2/token", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.security.invalidate_token :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/oidc_authenticate_test.rb b/elasticsearch-api/spec/platinum/unit/security/oidc_authenticate_test.rb deleted file mode 100644 index 1191c49add..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/oidc_authenticate_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class SecurityOidcAuthenticateTest < Minitest::Test - context 'Security: OIDC Authenticate' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_security/oidc/authenticate', url) - assert_equal({}, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.security.oidc_authenticate(body: {}) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/oidc_logout_test.rb b/elasticsearch-api/spec/platinum/unit/security/oidc_logout_test.rb deleted file mode 100644 index 539bd23bfb..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/oidc_logout_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class SecurityOidcLogoutTest < Minitest::Test - context 'Security: OIDC Logout' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_security/oidc/logout', url) - assert_equal({}, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.security.oidc_logout(body: {}) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/oidc_prepare_authentication_test.rb b/elasticsearch-api/spec/platinum/unit/security/oidc_prepare_authentication_test.rb deleted file mode 100644 index f3c90da71c..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/oidc_prepare_authentication_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class SecurityOidcPrepareAuthenticationTest < Minitest::Test - context 'Security: OIDC Prepare_Authentication' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_security/oidc/prepare', url) - assert_equal({}, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.security.oidc_prepare_authentication(body: {}) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/put_privileges_test.rb b/elasticsearch-api/spec/platinum/unit/security/put_privileges_test.rb deleted file mode 100644 index 3ede21219f..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/put_privileges_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityPutPrivilegesTest < Minitest::Test - - context "XPack Security: Put role" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_security/privilege', url - assert_equal Hash.new, params - assert_equal({ "app-allow": { read: { actions: [ "data:read/*" ] } } }, body) - true - end.returns(FakeResponse.new) - - subject.security.put_privileges(body: { "app-allow": { read: { actions: [ "data:read/*" ] } } }) - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/put_role_mapping_test.rb b/elasticsearch-api/spec/platinum/unit/security/put_role_mapping_test.rb deleted file mode 100644 index 9cc883fb39..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/put_role_mapping_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityPutRoleMappingTest < Minitest::Test - - context "XPack Security: Put role mapping" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal "_security/role_mapping/foo", url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.security.put_role_mapping :name => 'foo', :body => {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/put_role_test.rb b/elasticsearch-api/spec/platinum/unit/security/put_role_test.rb deleted file mode 100644 index 388e64e944..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/put_role_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityPutRoleTest < Minitest::Test - - context "XPack Security: Put role" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_security/role/foo', url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.security.put_role :name => 'foo', body: {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/put_user_test.rb b/elasticsearch-api/spec/platinum/unit/security/put_user_test.rb deleted file mode 100644 index 3273fce310..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/put_user_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSecurityPutUserTest < Minitest::Test - - context "XPack Security: Put user" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_security/user/foo', url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.security.put_user username: 'foo', body: {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/security/update_user_profile_data_test.rb b/elasticsearch-api/spec/platinum/unit/security/update_user_profile_data_test.rb deleted file mode 100644 index e87738bfe8..0000000000 --- a/elasticsearch-api/spec/platinum/unit/security/update_user_profile_data_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class SecurityUpdateUserProfileTest < Minitest::Test - context 'Security: Update User Profile Data' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('PUT', method) - assert_equal('_security/profile/1/_data', url) - assert_equal({}, params) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.security.update_user_profile_data(uid: 1, body: {}) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/ssl/certificates_test.rb b/elasticsearch-api/spec/platinum/unit/ssl/certificates_test.rb deleted file mode 100644 index e72774946c..0000000000 --- a/elasticsearch-api/spec/platinum/unit/ssl/certificates_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackSslCertificatesTest < Minitest::Test - - context "XPack Ssl: Certificates" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_ssl/certificates', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.ssl.certificates - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/text_structure/find_structure_test.rb b/elasticsearch-api/spec/platinum/unit/text_structure/find_structure_test.rb deleted file mode 100644 index 0f5ef0aca0..0000000000 --- a/elasticsearch-api/spec/platinum/unit/text_structure/find_structure_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackTextStructureFindStructureTest < Minitest::Test - context "XPack Text Structure: Find structure" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_text_structure/find_structure', url) - assert_equal(params, {}) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.text_structure.find_structure(body: {}) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/usage_test.rb b/elasticsearch-api/spec/platinum/unit/usage_test.rb deleted file mode 100644 index cf999776fa..0000000000 --- a/elasticsearch-api/spec/platinum/unit/usage_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackUsageTest < Minitest::Test - context 'XPack: Usage' do - subject { FakeClient.new } - - should 'perform correct request' do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_xpack/usage', url) - assert_equal({}, params) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.xpack.usage - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/ack_watch_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/ack_watch_test.rb deleted file mode 100644 index 33f2d3bc2e..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/ack_watch_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherAckWatchTest < Minitest::Test - - context "XPack Watcher: Ack watch" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_watcher/watch/foo/_ack', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.ack_watch watch_id: 'foo' - end - - should "perform correct request when action id is provided" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_watcher/watch/foo/_ack/bar', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.ack_watch watch_id: 'foo', action_id: 'bar' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/activate_watch_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/activate_watch_test.rb deleted file mode 100644 index 1cb1aa0621..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/activate_watch_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherActivateWatchTest < Minitest::Test - - context "XPack Watcher: Activate watch" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_watcher/watch/foo/_activate', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.activate_watch watch_id: 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/deactivate_watch_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/deactivate_watch_test.rb deleted file mode 100644 index f51080579c..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/deactivate_watch_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherDeactivateWatchTest < Minitest::Test - - context "XPack Watcher: Deactivate watch" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_watcher/watch/foo/_deactivate', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.deactivate_watch watch_id: 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/delete_watch_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/delete_watch_test.rb deleted file mode 100644 index 674299adec..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/delete_watch_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherDeleteWatchTest < Minitest::Test - - context "XPack Watcher: Delete watch" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'DELETE', method - assert_equal '_watcher/watch/foo', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.delete_watch id: 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/execute_watch_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/execute_watch_test.rb deleted file mode 100644 index 6b387f04f6..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/execute_watch_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherExecuteWatchTest < Minitest::Test - - context "XPack Watcher: Execute watch" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_watcher/watch/foo/_execute', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.execute_watch id: 'foo' - end - - should "perform correct request with no id specified" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_watcher/watch/_execute', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.execute_watch - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/get_watch_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/get_watch_test.rb deleted file mode 100644 index f3c866e0ef..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/get_watch_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherGetWatchTest < Minitest::Test - - context "XPack Watcher: Get watch" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_watcher/watch/foo', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.get_watch id: 'foo' - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/put_watch_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/put_watch_test.rb deleted file mode 100644 index 782c8334a1..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/put_watch_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherPutWatchTest < Minitest::Test - - context "XPack Watcher: Put watch" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'PUT', method - assert_equal '_watcher/watch/foo', url - assert_equal Hash.new, params - assert_equal Hash.new, body - true - end.returns(FakeResponse.new) - - subject.watcher.put_watch id: 'foo', body: {} - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/query_watches_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/query_watches_test.rb deleted file mode 100644 index c544bed6ca..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/query_watches_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherQueryWatchesTest < Minitest::Test - context "XPack Watcher: Query watches" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('GET', method) - assert_equal('_watcher/_query/watches', url) - assert_equal(params, {}) - assert_nil(body) - true - end.returns(FakeResponse.new) - - subject.watcher.query_watches - end - - should "perform correct request when sending body" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal('POST', method) - assert_equal('_watcher/_query/watches', url) - assert_equal(params, {}) - assert_equal(body, {}) - true - end.returns(FakeResponse.new) - - subject.watcher.query_watches(body: {}) - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/start_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/start_test.rb deleted file mode 100644 index 0387758fc5..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/start_test.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherStartTest < Minitest::Test - - context "XPack Watcher: Start" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_watcher/_start', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.start - end - end - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/stats_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/stats_test.rb deleted file mode 100644 index ca272d9eb2..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/stats_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherStatsTest < Minitest::Test - - context "XPack Watcher: Stats" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'GET', method - assert_equal '_watcher/stats', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.stats - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/platinum/unit/watcher/stop_test.rb b/elasticsearch-api/spec/platinum/unit/watcher/stop_test.rb deleted file mode 100644 index 2a1e8a8a54..0000000000 --- a/elasticsearch-api/spec/platinum/unit/watcher/stop_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'test_helper' - -module Elasticsearch - module Test - class XPackWatcherStopTest < Minitest::Test - - context "XPack Watcher: Stop" do - subject { FakeClient.new } - - should "perform correct request" do - subject.expects(:perform_request).with do |method, url, params, body| - assert_equal 'POST', method - assert_equal '_watcher/_stop', url - assert_equal Hash.new, params - assert_nil body - true - end.returns(FakeResponse.new) - - subject.watcher.stop - end - - end - - end - end -end diff --git a/elasticsearch-api/spec/rest_api/README.md b/elasticsearch-api/spec/rest_api/README.md new file mode 100644 index 0000000000..776a0e9f9b --- /dev/null +++ b/elasticsearch-api/spec/rest_api/README.md @@ -0,0 +1 @@ +This directory contains the files to run the Elasticsearch REST API Spec tests. See [../../api-spec-testing/README.md'](api-spec-testing). diff --git a/elasticsearch-api/spec/rest_api/rest_api_tests_helper.rb b/elasticsearch-api/spec/rest_api/rest_api_tests_helper.rb index 6a15c5def3..e62eb6b8e1 100644 --- a/elasticsearch-api/spec/rest_api/rest_api_tests_helper.rb +++ b/elasticsearch-api/spec/rest_api/rest_api_tests_helper.rb @@ -48,14 +48,21 @@ transport_options = {} end -ADMIN_CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options) +# DEBUG: For easier debugging, set LOG_STDOUT env variable to true +output = if ENV['LOG_STDOUT'] == 'true' + $stdout + else + File.expand_path("../../tmp/tracer_log-#{ENV['TEST_SUITE']}-#{ENV['RUBY_VERSION']}.log", __dir__) + end +logger = Logger.new(output) +ADMIN_CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options, tracer: logger) DEFAULT_CLIENT = if ENV['QUIET'] == 'true' Elasticsearch::Client.new(host: host, transport_options: transport_options) else Elasticsearch::Client.new( host: host, - tracer: Logger.new($stdout), + tracer: logger, transport_options: transport_options ) end @@ -65,7 +72,10 @@ exit end -Elasticsearch::RestAPIYAMLTests::WipeCluster.create_xpack_rest_user(ADMIN_CLIENT) if test_suite == 'platinum' +if test_suite == 'platinum' + Elasticsearch::RestAPIYAMLTests::WipeCluster.create_xpack_rest_user(ADMIN_CLIENT) + Elasticsearch::RestAPIYAMLTests::WipeCluster.create_enterprise_search_users(ADMIN_CLIENT) +end YAML_FILES_DIRECTORY = "#{PROJECT_PATH}/../../tmp/rest-api-spec/test/#{test_suite}".freeze @@ -97,4 +107,4 @@ end # The features to skip -REST_API_YAML_SKIP_FEATURES = ['warnings', 'node_selector'].freeze +REST_API_YAML_SKIP_FEATURES = ['warnings', 'node_selector', 'close_to'].freeze diff --git a/elasticsearch-api/spec/rest_api/rest_api_yaml_spec.rb b/elasticsearch-api/spec/rest_api/rest_api_yaml_spec.rb index ebe1d58e81..b9bf5808d9 100644 --- a/elasticsearch-api/spec/rest_api/rest_api_yaml_spec.rb +++ b/elasticsearch-api/spec/rest_api/rest_api_yaml_spec.rb @@ -19,12 +19,28 @@ require_relative 'rest_api_tests_helper' require_relative './run_rspec_matchers' +# LOGGER logs to stdout since we want to see if there are any errors in the running of the tests. +# The client has a tracer/logger defined in ./rest_api_tests_helper.rb, ENV['LOG_STDOUT'] set to +# true will log to stdout instead of a log file: LOGGER = Logger.new($stdout) +CLUSTER_FEATURES = ADMIN_CLIENT.features.get_features['features'].map { |f| f['name'] } + +def skip_test?(test) + # To support new features skipping in YAML tests. This will go away with new YAML tests: + if (feature_to_skip = test.skip&.first&.[]('skip')&.[]('cluster_features')) + return true unless CLUSTER_FEATURES.include?(feature_to_skip) + end + # Support skipping 'awaits_fix' + !!test.test_file.instance_variable_get('@skip')&.first&.[]('skip')&.[]('awaits_fix') || + !!test.skip&.first&.[]('skip')&.[]('awaits_fix') +end describe 'Rest API YAML tests' do + LOGGER.info "Elastic Transport version: #{Elastic::Transport::VERSION}" + if REST_API_YAML_FILES.empty? LOGGER.error 'No test files found!' - LOGGER.info 'Use rake rake elasticsearch:download_artifacts in the root directory of the project to download the test artifacts.' + LOGGER.info 'Use rake rake es:download_artifacts in the root directory of the project to download the test artifacts.' exit 1 end @@ -44,6 +60,8 @@ let(:client) { DEFAULT_CLIENT } test_file.tests.each do |test| + next if skip_test?(test) + context test.description do if test.skip_test?(ADMIN_CLIENT) skip 'Test contains feature(s) not yet supported or version is not satisfied' @@ -67,6 +85,9 @@ # ./run_task_groups.rb run_rspec_matchers_on_task_group(task_group, test) end + rescue StandardError => e + LOGGER.error "#{context_name} - #{e}" + raise e end end end diff --git a/elasticsearch-api/spec/rest_api/skipped_tests_free.yml b/elasticsearch-api/spec/rest_api/skipped_tests_free.yml index 8a67ebc175..44f000d8d3 100644 --- a/elasticsearch-api/spec/rest_api/skipped_tests_free.yml +++ b/elasticsearch-api/spec/rest_api/skipped_tests_free.yml @@ -25,7 +25,6 @@ - :file: 'tsdb/80_index_resize.yml' :description: 'clone' - - :file: 'cluster.desired_nodes/10_basic.yml' :description: 'Test update desired nodes is idempotent' @@ -33,5 +32,193 @@ :file: 'cluster.desired_nodes/10_basic.yml' :description: 'Test update desired nodes is idempotent with different order' - - :file: 'cluster.desired_balance/10_basic.yml' - :description: 'Test cluster_balance_stats' + :file: 'cluster.desired_nodes/10_basic.yml' + :description: 'Test node version must be at least the current master version' +- + :file: 'cluster.desired_nodes/10_basic.yml' + :description: 'Test node version must have content' +- + :file: 'search.vectors/40_knn_search.yml' + :description: 'Direct kNN queries are disallowed' +- + :file: 'search.vectors/40_knn_search.yml' + :description: 'Knn search with mip' +- + :file: 'search.vectors/45_knn_search_byte.yml' + :description: 'Direct kNN queries are disallowed' +- + :file: 'tsdb/25_id_generation.yml' + :description: 'generates a consistent id' +- + :file: 'indices.resolve_cluster/10_basic_resolve_cluster.yml' + :description: 'Resolve cluster using alias and index that does not exist' +- + :file: 'health/10_basic.yml' # Migrated to written manually + :description: 'cluster health basic test' +- + :file: 'cat.allocation/10_basic.yml' + :description: 'One index' +- + :file: 'cat.allocation/10_basic.yml' + :description: 'Node ID' +- + :file: 'cat.allocation/10_basic.yml' + :description: 'All Nodes' +- + :file: 'cat.allocation/10_basic.yml' + :description: 'Column headers' +- + :file: 'cat.allocation/10_basic.yml' + :description: 'Bytes' +- + :file: 'search.vectors/120_knn_query_multiple_shards.yml' + :description: 'Search for 2 knn queries combines scores from them' +- + :file: 'search.vectors/140_knn_query_with_other_queries.yml' + :description: 'Function score query with knn query' +- + :file: 'search.vectors/60_knn_search_filter_alias.yml' + :description: 'kNN filter alias' +- + :file: 'cluster.desired_nodes/11_old_format.yml' + :description: 'Test node version must be at least the current master version' +- + :file: 'cluster.desired_nodes/11_old_format.yml' + :description: 'Test node version must have content' +- + :file: 'aggregations/stats_metric_fail_formatting.yml' + :description: 'fail formatting' +# TODO: Test failing due to implementation +- + :file: 'capabilities/10_basic.yml' + :description: '*' +- + :file: 'indices.simulate_index_template/10_basic.yml' + :description: 'Simulate index matches overlapping legacy and composable templates' +- + :file: 'indices.simulate_template/10_basic.yml' + :description: 'Simulate template matches overlapping legacy and composable templates' +- + :file: 'search.vectors/180_update_dense_vector_type.yml' + :description: 'Test create and update dense vector mapping with per-doc indexing and flush' +- + :file: 'search.vectors/180_update_dense_vector_type.yml' + :description: 'Test create and update dense vector mapping with bulk indexing' +- + :file: 'search.vectors/180_update_dense_vector_type.yml' + :description: 'Index, update and merge' +- + :file: 'search.vectors/90_sparse_vector.yml' + :description: 'Indexing and searching multi-value sparse vectors in >=8.15' +- + :file: 'search/330_disallow_scripted_metrics.yml' + :description: 'all scripts allowed by default' +- + :file: 'search/330_disallow_scripted_metrics.yml' + :description: 'disallow all for empty allow lists' +- + :file: 'search/330_disallow_scripted_metrics.yml' + :description: 'allowed stored scripts do not affect allowed inline scripts' +- + :file: 'aggregations/scripted_metric_allow_list.yml' + :description: 'allowed stored scripts do not affect allowed inline scripts' +- + :file: 'logsdb/10_settings.yml' + :description: '*' +- + :file: 'search.vectors/180_update_dense_vector_type.yml' + :description: 'Test create and update dense vector mapping to int4 with per-doc indexing and flush' +- + :file: 'simulate.ingest/10_basic.yml' + :description: 'Test mapping validation' +- + :file: 'nodes.stats/11_indices_metrics.yml' + :description: 'Lucene segment level fields stats' +- + :file: 'search.suggest/20_phrase.yml' + :description: 'breaks ties by sorting terms' +# Regexp issues with catching an error +- + :file: 'analysis-common/40_token_filters.yml' + :description: 'stemmer_override file access' +- # Migrated to YAML tests: + :file: 'ingest_geoip/30_geoip_stats.yml' + :description: '*' +- # Testing server: + :file: 'ingest_geoip/20_geoip_processor.yml' + :description: '*' +- + :file: 'simulate.ingest/10_basic.yml' + :description: 'Test mapping validation from templates' +- + :file: 'indices.split/40_routing_partition_size.yml' + :description: '*' +- + :file: 'range/20_synthetic_source.yml' + :description: '*' +- + :file: 'ingest_geoip/40_geoip_databases.yml' + :description: 'Test adding, getting, and removing geoip databases' +- + :file: 'ingest_geoip/50_ip_lookup_processor.yml' + :description: '*' +- + :file: 'ingest_geoip/60_ip_location_databases.yml' + :description: '*' +- + :file: 'get/100_synthetic_source.yml' + :description: 'fetch without refresh also produces synthetic source' +- + :file: 'get/100_synthetic_source.yml' + :description: 'flattened field' +- + :file: 'get/100_synthetic_source.yml' + :description: 'flattened field with ignore_above and arrays' +- + :file: 'index/91_metrics_no_subobjects.yml' + :description: 'Metrics object indexing with synthetic source' +- + :file: 'indices.create/20_synthetic_source.yml' + :description: '*' +- + :file: 'indices.create/21_synthetic_source_stored.yml' + :description: '*' +- + :file: 'indices.put_mapping/10_basic.yml' + :description: 'disabling synthetic source fails' +- + :file: 'logsdb/20_source_mapping.yml' + :description: 'synthetic _source is default' +- + :file: 'index/92_metrics_auto_subobjects.yml' + :description: 'Metrics object indexing with synthetic source' +- + :file: 'tsdb/20_mapping.yml' + :description: 'Synthetic source' +- + :file: 'update/100_synthetic_source.yml' + :description: 'keyword' +- + :file: 'search.highlight/50_synthetic_source.yml' + :description: 'text multi fvh source order' +- + :file: 'search.highlight/50_synthetic_source.yml' + :description: 'text multi fvh score order' +- + :file: 'update/100_synthetic_source.yml' + :description: 'stored text' +- + :file: 'cluster.desired_nodes/11_old_format.yml' + :description: '*' +- + :file: 'tsdb/20_mapping.yml' + :description: 'disabled source is not supported' +- + :file: 'tsdb/20_mapping.yml' + :description: 'source include/exclude' +- + :file: 'logsdb/20_source_mapping.yml' + :description: 'disabled _source is not supported' +- + :file: 'logsdb/20_source_mapping.yml' + :description: 'include/exclude is not supported with synthetic _source' diff --git a/elasticsearch-api/spec/rest_api/skipped_tests_platinum.yml b/elasticsearch-api/spec/rest_api/skipped_tests_platinum.yml index f3fd07c547..8fb1839d9a 100644 --- a/elasticsearch-api/spec/rest_api/skipped_tests_platinum.yml +++ b/elasticsearch-api/spec/rest_api/skipped_tests_platinum.yml @@ -99,3 +99,150 @@ - :file: 'eql/30_async_missing_events.yml' :description: 'Execute async EQL with missing events' +- + :file: 'api_key/60_admin_user.yml' + :description: 'Test get api key (with role descriptors + metadata)' +- + :file: 'api_key/60_admin_user.yml' + :description: 'Test query api keys' + +- + :file: 'spatial/70_script_doc_values.yml' + :description: '*' +- + :file: 'esql/60_usage.yml' + :description: 'Basic ESQL usage output (telemetry)' +- + :file: 'users/40_query.yml' + :description: 'Test query user' +- + :file: 'api_key/21_query_with_aggs.yml' + :description: 'Test composite aggs api key' + +# Issue: key_as_string should not be parsed to date: +- + :file: 'analytics/empty_field_metric.yml' + :description: 'Rate test' +# Migrated to yaml tests in elastic/elasticsearch-clients-tests +- + :file: 'roles/10_basic.yml' + :description: '*' +- + :file: 'roles/50_remote_only.yml' + :description: '*' +- + :file: 'entsearch/connector/secret/10_connector_secret_post.yml' + :description: '*' +- + :file: 'entsearch/connector/secret/30_connector_secret_get.yml' + :description: '*' +- + :file: 'entsearch/connector/secret/40_connector_secret_delete.yml' + :description: '*' +- + :file: 'entsearch/search/20_search_application_put.yml' + :description: '*' +- + :file: 'entsearch/search/30_search_application_get.yml' + :description: '*' +- + :file: 'entsearch/search/40_search_application_delete.yml' + :description: '*' +- + :file: 'entsearch/search/50_search_application_list.yml' + :description: '*' +- + :file: 'entsearch/search/56_search_application_search_with_apikey.yml' + :description: '*' +- + :file: 'entsearch/connector/secret/20_connector_secret_put.yml' + :description: '*' +- + :file: 'entsearch/connector/sync_job/50_connector_sync_job_get.yml' + :description: '*' +- + :file: 'entsearch/connector/sync_job/70_connector_sync_job_update_stats.yml' + :description: '*' +- + :file: 'entsearch/analytics/40_behavioral_analytics_event_post.yml' + :description: '*' +- + :file: 'entsearch/connector/20_connector_list.yml' + :description: '*' +- + :file: 'entsearch/rules/5_query_rulesets_before_setup.yml' + :description: '*' +- + :file: 'entsearch/rules/10_query_ruleset_put.yml' + :description: '*' +- + :file: 'entsearch/rules/20_query_ruleset_list.yml' + :description: '*' +- + :file: 'entsearch/rules/50_query_rule_put.yml' + :description: '*' +- + :file: 'entsearch/rules/10_query_ruleset_put.yml' + :description: '*' +- + :file: 'entsearch/rules/40_rule_query_search.yml' + :description: '*' +- + :file: 'entsearch/rules/60_query_rule_delete.yml' + :description: '*' +- + :file: 'entsearch/rules/30_query_ruleset_delete.yml' + :description: '*' +- + :file: 'roles/60_bulk_roles.yml' + :description: '*' +- + :file: 'entsearch/analytics/30_behavioral_analytics_delete.yml' + :description: '*' +- + :file: 'entsearch/analytics/40_behavioral_analytics_event_post.yml' + :description: '*' +- + :file: 'entsearch/20_usage.yml' + :description: '*' +# TODO: Update test runnner. Error is ok but Regexp shenanigans +- + :file: 'eql/60_no_exact.yml' + :description: 'Case insensitive match on text field' +- + :file: 'esql/180_match_operator.yml' + :description: '*' +- + :file: 'snapshot/10_basic.yml' + :description: 'Failed to snapshot indices with synthetic source' +# Private APIs +- + :file: 'ml/validate.yml' + :description: '*' +- + :file: 'ml/validate_detector.yml' + :description: '*' +- + :file: 'monitoring/bulk/10_basic.yml' + :description: '*' +- + :file: 'monitoring/bulk/20_privileges.yml' + :description: '*' +- + :file: 'profiling/10_basic.yml' + :description: '*' +- + :file: 'security/settings/10_update_security_settings.yml' + :description: '*' +- + :file: 'user_profile/10_basic.yml' + :description: '*' +- + :file: 'user_profile/40_has_privileges.yml' + :description: '*' +- + :file: 'esql/60_usage.yml' + :description: 'Basic ESQL usage output (telemetry) non-snapshot version' +- + :file: 'ml/inference_crud.yml' + :description: '*' # Being tested in elasticsearch-clients-tests diff --git a/elasticsearch-api/spec/spec_helper.rb b/elasticsearch-api/spec/spec_helper.rb index 99d6d350a6..420a4aecd3 100644 --- a/elasticsearch-api/spec/spec_helper.rb +++ b/elasticsearch-api/spec/spec_helper.rb @@ -14,18 +14,21 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -if ENV['COVERAGE'] && ENV['CI'].nil? +if ENV['COVERAGE'] require 'simplecov' - SimpleCov.start { add_filter %r{^/test|spec/} } + SimpleCov.start do + add_filter %r{^/test|spec/} + add_filter 'utils/thor' + end end if defined?(JRUBY_VERSION) require 'pry-nav' else - require 'pry-byebug' + require 'debug' end require 'yaml' -require 'active_support/isolated_execution_state' unless RUBY_VERSION < '2.7.0' +# require 'active_support/isolated_execution_state' unless RUBY_VERSION < '2.7.0' require 'jbuilder' require 'jsonify' require 'elasticsearch' @@ -58,9 +61,15 @@ def self.included(context) RSpec.configure do |config| config.include(HelperModule) - config.add_formatter('documentation') - config.add_formatter('RspecJunitFormatter', "tmp/elasticsearch-#{ENV['TEST_SUITE']}-#{RUBY_VERSION}-junit.xml") - config.add_formatter('RSpec::Core::Formatters::HtmlFormatter', "tmp/elasticsearch-#{ENV['TEST_SUITE']}-#{RUBY_VERSION}.html") + config.filter_run_excluding skip: true + config.add_formatter('progress') + if defined?(JRUBY_VERSION) + config.add_formatter('RSpec::Core::Formatters::HtmlFormatter', "tmp/elasticsearch-#{ENV['TEST_SUITE']}-jruby-#{JRUBY_VERSION}.html") + config.add_formatter('documentation', "tmp/elasticsearch-#{ENV['TEST_SUITE']}-jruby-#{JRUBY_VERSION}.log") + else + config.add_formatter('RSpec::Core::Formatters::HtmlFormatter', "tmp/elasticsearch-#{ENV['TEST_SUITE']}-#{RUBY_VERSION}.html") + config.add_formatter('documentation', "tmp/elasticsearch-#{ENV['TEST_SUITE']}-#{RUBY_VERSION}.html") + end if ENV['BUILDKITE'] require_relative "./rspec_formatter.rb" config.add_formatter('RSpecCustomFormatter') diff --git a/elasticsearch-api/spec/unit/actions/async_search/delete_spec.rb b/elasticsearch-api/spec/unit/actions/async_search/delete_spec.rb new file mode 100644 index 0000000000..ec320a4f73 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/async_search/delete_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#async_search.delete' do + let(:expected_args) do + [ + 'DELETE', + '_async_search/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'async_search.delete' } + ] + end + + it 'performs the request' do + expect(client_double.async_search.delete(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/async_search/get_spec.rb b/elasticsearch-api/spec/unit/actions/async_search/get_spec.rb new file mode 100644 index 0000000000..4eab487c50 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/async_search/get_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#async_search.get' do + let(:expected_args) do + [ + 'GET', + '_async_search/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'async_search.get' } + ] + end + + it 'performs the request' do + expect(client_double.async_search.get(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/async_search/status_spec.rb b/elasticsearch-api/spec/unit/actions/async_search/status_spec.rb new file mode 100644 index 0000000000..d170e8d3a2 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/async_search/status_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#async_search.status' do + let(:expected_args) do + [ + 'GET', + '_async_search/status/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'async_search.status' } + ] + end + + it 'performs the request' do + expect(client_double.async_search.status(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/async_search/submit_spec.rb b/elasticsearch-api/spec/unit/actions/async_search/submit_spec.rb new file mode 100644 index 0000000000..51c1b60dea --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/async_search/submit_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#async_search.submit' do + let(:expected_args) do + [ + 'POST', + 'foo/_async_search', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'async_search.submit' } + ] + end + + it 'performs the request' do + expect(client_double.async_search.submit(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/bulk_spec.rb b/elasticsearch-api/spec/unit/actions/bulk_spec.rb similarity index 86% rename from elasticsearch-api/spec/elasticsearch/api/actions/bulk_spec.rb rename to elasticsearch-api/spec/unit/actions/bulk_spec.rb index d18330b38c..25906f11c7 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/bulk_spec.rb +++ b/elasticsearch-api/spec/unit/actions/bulk_spec.rb @@ -24,11 +24,17 @@ url, params, body, - headers + headers, + { endpoint: 'bulk' } ] end - let(:headers) { { 'Content-Type' => 'application/x-ndjson' } } + let(:headers) { + { + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + } + } + let(:params) { {} } let(:url) { '_bulk' } let(:body) { '' } @@ -59,6 +65,17 @@ context 'when an index is specified' do let(:url) { 'myindex/_bulk' } + let(:expected_args) do + [ + 'POST', + url, + params, + body, + headers, + { defined_params: { index: 'myindex' }, :endpoint=>"bulk"} + ] + end + it 'performs the request' do expect(client_double.bulk(index: 'myindex', body: [])).to be_a Elasticsearch::API::Response end @@ -113,6 +130,17 @@ 'foo%5Ebar/_bulk' end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + headers, + { defined_params: { index: 'foo^bar' }, :endpoint=>"bulk"} + ] + end + it 'performs the request' do expect(client_double.bulk(index: 'foo^bar', body: [])).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/aliases_spec.rb b/elasticsearch-api/spec/unit/actions/cat/aliases_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/aliases_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/aliases_spec.rb index 934e4d3aa0..4524b24363 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/aliases_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/aliases_spec.rb @@ -25,7 +25,8 @@ '_cat/aliases', {}, nil, - {} + {}, + { endpoint: 'cat.aliases' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/allocation_spec.rb b/elasticsearch-api/spec/unit/actions/cat/allocation_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/allocation_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/allocation_spec.rb index ee5db7275e..81fd6cd1ea 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/allocation_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/allocation_spec.rb @@ -25,7 +25,8 @@ '_cat/allocation', {}, nil, - {} + {}, + { endpoint: 'cat.allocation' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/component_templates_spec.rb b/elasticsearch-api/spec/unit/actions/cat/component_templates_spec.rb similarity index 78% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/component_templates_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/component_templates_spec.rb index eb03af9102..1e3b559771 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/component_templates_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/component_templates_spec.rb @@ -18,19 +18,20 @@ require 'spec_helper' describe 'client.cat#component_templates' do - let(:expected_args) do - [ - 'GET', - url, - {}, - nil, - {} - ] - end - context 'without a name' do let(:url) { '_cat/component_templates' } + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'cat.component_templates' } + ] + end + it 'performs the request' do expect(client_double.cat.component_templates).to be_a Elasticsearch::API::Response end @@ -39,6 +40,17 @@ context 'with a name' do let(:url) { '_cat/component_templates/foo' } + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'cat.component_templates' } + ] + end + it 'performs the request' do expect(client_double.cat.component_templates(name: 'foo')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/cat/count_spec.rb b/elasticsearch-api/spec/unit/actions/cat/count_spec.rb new file mode 100644 index 0000000000..5db1051797 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cat/count_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cat#count' do + + let(:expected_args) do + [ + 'GET', + '_cat/count', + {}, + nil, + {}, + { endpoint: 'cat.count' } + ] + end + + it 'performs the request' do + expect(client_double.cat.count).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/fielddata_spec.rb b/elasticsearch-api/spec/unit/actions/cat/fielddata_spec.rb similarity index 90% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/fielddata_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/fielddata_spec.rb index 051622921d..30784474b3 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/fielddata_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/fielddata_spec.rb @@ -25,7 +25,8 @@ '_cat/fielddata', {}, nil, - {} + {}, + { endpoint: 'cat.fielddata' } ] end @@ -41,7 +42,8 @@ '_cat/fielddata/foo,bar', {}, nil, - {} + {}, + { defined_params: { fields: ['foo', 'bar'] }, endpoint: 'cat.fielddata' } ] end diff --git a/elasticsearch-api/spec/unit/actions/cat/health_spec.rb b/elasticsearch-api/spec/unit/actions/cat/health_spec.rb new file mode 100644 index 0000000000..dfbfbfb634 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cat/health_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cat#health' do + + let(:expected_args) do + [ + 'GET', + '_cat/health', + {}, + nil, + {}, + { endpoint: 'cat.health' } + ] + end + + it 'performs the request' do + expect(client_double.cat.health).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/help_spec.rb b/elasticsearch-api/spec/unit/actions/cat/help_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/help_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/help_spec.rb index eccfa32c29..5cff6878aa 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/help_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/help_spec.rb @@ -25,7 +25,8 @@ '_cat', {}, nil, - {} + {}, + { endpoint: 'cat.help' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/indices_spec.rb b/elasticsearch-api/spec/unit/actions/cat/indices_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/indices_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/indices_spec.rb index 823ec1f8fa..71663d555e 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/indices_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/indices_spec.rb @@ -25,7 +25,8 @@ '_cat/indices', {}, nil, - {} + {}, + { endpoint: 'cat.indices' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/master_spec.rb b/elasticsearch-api/spec/unit/actions/cat/master_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/master_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/master_spec.rb index 906c67fe05..5902ac355b 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/master_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/master_spec.rb @@ -25,7 +25,8 @@ '_cat/master', {}, nil, - {} + {}, + { endpoint: 'cat.master' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/nodeattrs_spec.rb b/elasticsearch-api/spec/unit/actions/cat/nodeattrs_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/nodeattrs_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/nodeattrs_spec.rb index b7caa40ea9..b950e602d8 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/nodeattrs_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/nodeattrs_spec.rb @@ -25,7 +25,8 @@ '_cat/nodeattrs', {}, nil, - {} + {}, + { endpoint: 'cat.nodeattrs' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/nodes_spec.rb b/elasticsearch-api/spec/unit/actions/cat/nodes_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/nodes_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/nodes_spec.rb index 8c21eeb698..05a05cf75e 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/nodes_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/nodes_spec.rb @@ -25,7 +25,8 @@ '_cat/nodes', {}, nil, - {} + {}, + { endpoint: 'cat.nodes' } ] end diff --git a/elasticsearch-api/spec/unit/actions/cat/pending_tasks_spec.rb b/elasticsearch-api/spec/unit/actions/cat/pending_tasks_spec.rb new file mode 100644 index 0000000000..e855aeb32e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cat/pending_tasks_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cat#pending_tasks' do + + let(:expected_args) do + [ + 'GET', + '_cat/pending_tasks', + {}, + nil, + {}, + { endpoint: 'cat.pending_tasks' } + ] + end + + it 'performs the request' do + expect(client_double.cat.pending_tasks).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/plugins_spec.rb b/elasticsearch-api/spec/unit/actions/cat/plugins_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/plugins_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/plugins_spec.rb index 186b3a4903..92e7fdf96d 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/plugins_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/plugins_spec.rb @@ -25,7 +25,8 @@ '_cat/plugins', {}, nil, - {} + {}, + { endpoint: 'cat.plugins' } ] end diff --git a/elasticsearch-api/spec/unit/actions/cat/recovery_spec.rb b/elasticsearch-api/spec/unit/actions/cat/recovery_spec.rb new file mode 100644 index 0000000000..d9170dbd99 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cat/recovery_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cat#recovery' do + + let(:expected_args) do + [ + 'GET', + '_cat/recovery', + {}, + nil, + {}, + { endpoint: 'cat.recovery' } + ] + end + + it 'performs the request' do + expect(client_double.cat.recovery).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/repositories_spec.rb b/elasticsearch-api/spec/unit/actions/cat/repositories_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/repositories_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/repositories_spec.rb index ac22e49eef..cccc304b44 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/repositories_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/repositories_spec.rb @@ -25,7 +25,8 @@ '_cat/repositories', {}, nil, - {} + {}, + { endpoint: 'cat.repositories'} ] end diff --git a/elasticsearch-api/spec/unit/actions/cat/segments_spec.rb b/elasticsearch-api/spec/unit/actions/cat/segments_spec.rb new file mode 100644 index 0000000000..5e0d3c3ce1 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cat/segments_spec.rb @@ -0,0 +1,61 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cat#segments' do + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'cat.segments' } + ] + end + + let(:url) do + '_cat/segments' + end + + it 'performs the request' do + expect(client_double.cat.segments).to be_a Elasticsearch::API::Response + end + + context 'when index is specified' do + let(:url) do + '_cat/segments/foo' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'cat.segments' } + ] + end + + it 'performs the request' do + expect(client_double.cat.segments(index: 'foo')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/shards_spec.rb b/elasticsearch-api/spec/unit/actions/cat/shards_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/shards_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/shards_spec.rb index acad84f522..a362502706 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/shards_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/shards_spec.rb @@ -25,7 +25,8 @@ '_cat/shards', {}, nil, - {} + {}, + { endpoint: 'cat.shards' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/snapshot_spec.rb b/elasticsearch-api/spec/unit/actions/cat/snapshot_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/snapshot_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/snapshot_spec.rb index 476fe1c3e3..59ee655f37 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/snapshot_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/snapshot_spec.rb @@ -25,7 +25,8 @@ '_cat/snapshots/foo', {}, nil, - {} + {}, + { defined_params: { repository: 'foo' }, endpoint: 'cat.snapshots' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/tasks_spec.rb b/elasticsearch-api/spec/unit/actions/cat/tasks_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/tasks_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/tasks_spec.rb index 5d64e3747b..174bac7439 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/tasks_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/tasks_spec.rb @@ -25,7 +25,8 @@ '_cat/tasks', {}, nil, - {} + {}, + { endpoint: 'cat.tasks' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/templates_spec.rb b/elasticsearch-api/spec/unit/actions/cat/templates_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/templates_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/templates_spec.rb index 102031870a..ad900bb2f6 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/templates_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/templates_spec.rb @@ -25,7 +25,8 @@ '_cat/templates', {}, nil, - {} + {}, + { endpoint: 'cat.templates' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cat/thread_pool_spec.rb b/elasticsearch-api/spec/unit/actions/cat/thread_pool_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cat/thread_pool_spec.rb rename to elasticsearch-api/spec/unit/actions/cat/thread_pool_spec.rb index 7ff9f7c374..16e2ed1493 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cat/thread_pool_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cat/thread_pool_spec.rb @@ -25,7 +25,8 @@ '_cat/thread_pool', {}, nil, - {} + {}, + { endpoint: 'cat.thread_pool' } ] end diff --git a/elasticsearch-api/spec/unit/actions/clear_scroll_spec.rb b/elasticsearch-api/spec/unit/actions/clear_scroll_spec.rb new file mode 100644 index 0000000000..f61f40b303 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/clear_scroll_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#clear_scroll' do + let(:expected_args) do + [ + 'DELETE', + '_search/scroll', + {}, + { scroll_id: 123 }, + {}, + { endpoint: 'clear_scroll' } + ] + end + + it 'performs the request' do + expect(client_double.clear_scroll(body: { scroll_id: 123 })).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/close_point_in_time_spec.rb b/elasticsearch-api/spec/unit/actions/close_point_in_time_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/close_point_in_time_spec.rb rename to elasticsearch-api/spec/unit/actions/close_point_in_time_spec.rb index 38af28c4ef..d770830179 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/close_point_in_time_spec.rb +++ b/elasticsearch-api/spec/unit/actions/close_point_in_time_spec.rb @@ -24,7 +24,8 @@ '_pit', {}, nil, - {} + {}, + { endpoint: 'close_point_in_time' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/allocation_explain_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/allocation_explain_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/cluster/allocation_explain_spec.rb rename to elasticsearch-api/spec/unit/actions/cluster/allocation_explain_spec.rb index 778d53514b..3577130b2c 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/allocation_explain_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cluster/allocation_explain_spec.rb @@ -25,7 +25,8 @@ '_cluster/allocation/explain', {}, nil, - {} + {}, + { endpoint: 'cluster.allocation_explain' } ] end diff --git a/elasticsearch-api/spec/unit/actions/cluster/get_settings_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/get_settings_spec.rb new file mode 100644 index 0000000000..6a9434546e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cluster/get_settings_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#get_settings' do + + let(:expected_args) do + [ + 'GET', + '_cluster/settings', + {}, + nil, + {}, + { endpoint: 'cluster.get_settings' } + ] + end + + it 'performs the request' do + expect(client_double.cluster.get_settings).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/cluster/health_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/health_spec.rb new file mode 100644 index 0000000000..8461ba018d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cluster/health_spec.rb @@ -0,0 +1,72 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#health' do + + let(:expected_args) do + [ + 'GET', + '_cluster/health', + {}, + nil, + {}, + { endpoint: 'cluster.health' } + ] + end + + it 'performs the request' do + expect(client_double.cluster.health).to be_a Elasticsearch::API::Response + end + + context 'when a level is specified' do + + let(:expected_args) do + [ + 'GET', + '_cluster/health', + { level: 'indices' }, + nil, + {}, + { endpoint: 'cluster.health' } + ] + end + + it 'performs the request' do + expect(client_double.cluster.health(level: 'indices')).to be_a Elasticsearch::API::Response + end + end + + context 'when an index is specified' do + + let(:expected_args) do + [ + 'GET', + '_cluster/health/foo', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'cluster.health' } + ] + end + + it 'performs the request' do + expect(client_double.cluster.health(index: 'foo')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/cluster/info_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/info_spec.rb new file mode 100644 index 0000000000..d2db5331c0 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cluster/info_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#info' do + + let(:expected_args) do + [ + 'GET', + '_info/foo', + {}, + nil, + {}, + { defined_params: { target: 'foo' }, endpoint: 'cluster.info' } + ] + end + + it 'performs the request' do + expect(client_double.cluster.info(target: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/cluster/pending_tasks_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/pending_tasks_spec.rb new file mode 100644 index 0000000000..bb939ca9d0 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cluster/pending_tasks_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#pending_tasks' do + + let(:expected_args) do + [ + 'GET', + '_cluster/pending_tasks', + {}, + nil, + {}, + { endpoint: 'cluster.pending_tasks' } + ] + end + + it 'performs the request' do + expect(client_double.cluster.pending_tasks).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/cluster/put_settings_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/put_settings_spec.rb new file mode 100644 index 0000000000..469d911b89 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cluster/put_settings_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#put_settings' do + + let(:expected_args) do + [ + 'PUT', + '_cluster/settings', + {}, + {}, + {}, + { endpoint: 'cluster.put_settings' } + ] + end + + it 'performs the request' do + expect(client_double.cluster.put_settings(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/remote_info_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/remote_info_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/cluster/remote_info_spec.rb rename to elasticsearch-api/spec/unit/actions/cluster/remote_info_spec.rb index b3618a29da..1f5cc20bbc 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/remote_info_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cluster/remote_info_spec.rb @@ -25,7 +25,8 @@ '_remote/info', {}, nil, - {} + {}, + { endpoint: 'cluster.remote_info' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/reroute_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/reroute_spec.rb similarity index 86% rename from elasticsearch-api/spec/elasticsearch/api/actions/cluster/reroute_spec.rb rename to elasticsearch-api/spec/unit/actions/cluster/reroute_spec.rb index 2cf0388cbd..b0278bbab8 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/reroute_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cluster/reroute_spec.rb @@ -21,11 +21,12 @@ let(:expected_args) do [ - 'POST', - '_cluster/reroute', - {}, - {}, - {} + 'POST', + '_cluster/reroute', + {}, + nil, + {}, + { endpoint: 'cluster.reroute' } ] end @@ -34,14 +35,14 @@ end context 'when a body is specified' do - let(:expected_args) do [ - 'POST', - '_cluster/reroute', - {}, - { commands: [ move: { index: 'myindex', shard: 0 }] }, - {} + 'POST', + '_cluster/reroute', + {}, + { commands: [ move: { index: 'myindex', shard: 0 }] }, + {}, + { endpoint: 'cluster.reroute' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/state_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/state_spec.rb similarity index 90% rename from elasticsearch-api/spec/elasticsearch/api/actions/cluster/state_spec.rb rename to elasticsearch-api/spec/unit/actions/cluster/state_spec.rb index 1f1852d621..9a62a4fc65 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/cluster/state_spec.rb +++ b/elasticsearch-api/spec/unit/actions/cluster/state_spec.rb @@ -25,7 +25,8 @@ '_cluster/state', {}, nil, - {} + {}, + { endpoint: 'cluster.state' } ] end @@ -41,7 +42,8 @@ '_cluster/state/foo,bar', {}, nil, - {} + {}, + { defined_params: { metric: ['foo', 'bar']}, endpoint: 'cluster.state' } ] end diff --git a/elasticsearch-api/spec/unit/actions/cluster/stats_spec.rb b/elasticsearch-api/spec/unit/actions/cluster/stats_spec.rb new file mode 100644 index 0000000000..c18fde3abf --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/cluster/stats_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#stats' do + + let(:expected_args) do + [ + 'GET', + '_cluster/stats', + {}, + nil, + {}, + { endpoint: 'cluster.stats' } + ] + end + + it 'performs the request' do + expect(client_double.cluster.stats).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/check_in_spec.rb b/elasticsearch-api/spec/unit/actions/connector/check_in_spec.rb new file mode 100644 index 0000000000..4a9d03ff91 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/check_in_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#check_in' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_check_in', + {}, + nil, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.check_in' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.check_in(connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/delete_spec.rb b/elasticsearch-api/spec/unit/actions/connector/delete_spec.rb new file mode 100644 index 0000000000..a59dc88daf --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/delete_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#delete' do + let(:expected_args) do + [ + 'DELETE', + '_connector/foo', + {}, + nil, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.delete' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.delete(connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/get_spec.rb b/elasticsearch-api/spec/unit/actions/connector/get_spec.rb new file mode 100644 index 0000000000..8e2b2388e4 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/get_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#get' do + let(:expected_args) do + [ + 'GET', + '_connector/foo', + {}, + nil, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.get' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.get(connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/list_spec.rb b/elasticsearch-api/spec/unit/actions/connector/list_spec.rb new file mode 100644 index 0000000000..426d0fbc4a --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/list_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#list' do + let(:expected_args) do + [ + 'GET', + '_connector', + {}, + nil, + {}, + { endpoint: 'connector.list' } + ] + end + + it 'performs the request' do + expect(client_double.connector.list).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/post_spec.rb b/elasticsearch-api/spec/unit/actions/connector/post_spec.rb new file mode 100644 index 0000000000..587a1fa0a5 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/post_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#post' do + let(:expected_args) do + [ + 'POST', + '_connector', + {}, + {}, + {}, + { endpoint: 'connector.post' } + ] + end + + it 'performs the request' do + expect(client_double.connector.post(connector_id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/put_spec.rb b/elasticsearch-api/spec/unit/actions/connector/put_spec.rb new file mode 100644 index 0000000000..632510b2e9 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/put_spec.rb @@ -0,0 +1,43 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#put' do + + let(:expected_args) do + [ + 'PUT', + '_connector/foo', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.put' + } + ] + end + + let(:body) do + {} + end + + it 'performs the request' do + expect(client_double.connector.put(body: body, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/sync_job_claim_spec.rb b/elasticsearch-api/spec/unit/actions/connector/sync_job_claim_spec.rb new file mode 100644 index 0000000000..07a6ebd26f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/sync_job_claim_spec.rb @@ -0,0 +1,40 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#sync_job_claim' do + let(:expected_args) do + [ + 'PUT', + '_connector/_sync_job/foo/_claim', + {}, + {}, + {}, + { + defined_params: { connector_sync_job_id: 'foo' }, + endpoint: 'connector.sync_job_claim' + } + ] + end + + it 'performs the request' do + expect( + client_double.connector.sync_job_claim(connector_sync_job_id: 'foo', body: {}) + ).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_active_filtering_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_active_filtering_spec.rb new file mode 100644 index 0000000000..7d91535e2c --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_active_filtering_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_active_filtering' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_filtering/_activate', + {}, + nil, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_active_filtering' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_active_filtering(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_api_key_id_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_api_key_id_spec.rb new file mode 100644 index 0000000000..ecc638fafb --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_api_key_id_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#check_in' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_api_key_id', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_api_key_id' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_api_key_id(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_configuration_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_configuration_spec.rb new file mode 100644 index 0000000000..df3da6f546 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_configuration_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_configuration' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_configuration', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_configuration' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_configuration(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_error_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_error_spec.rb new file mode 100644 index 0000000000..6258f35b40 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_error_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_error' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_error', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_error' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_error(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_features_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_features_spec.rb new file mode 100644 index 0000000000..c716a4774f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_features_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_features' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_features', + {}, + {}, + {}, + { + defined_params: { connector_id: 'foo' }, + endpoint: 'connector.update_features' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_features(connector_id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_filtering_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_filtering_spec.rb new file mode 100644 index 0000000000..4eac8738dd --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_filtering_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_filtering' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_filtering', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_filtering' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_filtering(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_filtering_validation_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_filtering_validation_spec.rb new file mode 100644 index 0000000000..50e9284157 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_filtering_validation_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_filtering_validation' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_filtering/_validation', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_filtering_validation' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_filtering_validation(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_index_name_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_index_name_spec.rb new file mode 100644 index 0000000000..e1e80ebc85 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_index_name_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_index_name' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_index_name', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_index_name' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_index_name(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_name_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_name_spec.rb new file mode 100644 index 0000000000..009154c688 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_name_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_name' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_name', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_name' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_name(connector_id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_native_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_native_spec.rb new file mode 100644 index 0000000000..4f4ca0d869 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_native_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_native' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_native', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_native' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_native(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_pipeline_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_pipeline_spec.rb new file mode 100644 index 0000000000..b686eafd2f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_pipeline_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_pipeline' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_pipeline', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_pipeline' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_pipeline(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_scheduling_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_scheduling_spec.rb new file mode 100644 index 0000000000..b598d033c6 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_scheduling_spec.rb @@ -0,0 +1,42 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_scheduling' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_scheduling', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_scheduling' + } + ] + end + + it 'performs the request' do + expect do + client_double.connector.update_scheduling( + connector_id: 'foo', + body: {}).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_service_type_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_service_type_spec.rb new file mode 100644 index 0000000000..389c7b3515 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_service_type_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_service_type' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_service_type', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_service_type' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_service_type(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector/update_status_spec.rb b/elasticsearch-api/spec/unit/actions/connector/update_status_spec.rb new file mode 100644 index 0000000000..5f91621acb --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector/update_status_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector#update_status' do + let(:expected_args) do + [ + 'PUT', + '_connector/foo/_status', + {}, + {}, + {}, + { + :defined_params=>{ connector_id: 'foo' }, + endpoint: 'connector.update_status' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.update_status(body: {}, connector_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector_sync_job/cancel_spec.rb b/elasticsearch-api/spec/unit/actions/connector_sync_job/cancel_spec.rb new file mode 100644 index 0000000000..47adc6a221 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector_sync_job/cancel_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector.sync_job_cancel' do + let(:expected_args) do + [ + 'PUT', + '_connector/_sync_job/foo/_cancel', + {}, + nil, + {}, + { + defined_params: {connector_sync_job_id: "foo"}, + endpoint: 'connector.sync_job_cancel' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.sync_job_cancel(connector_sync_job_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector_sync_job/check_in_spec.rb b/elasticsearch-api/spec/unit/actions/connector_sync_job/check_in_spec.rb new file mode 100644 index 0000000000..02182d5bb8 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector_sync_job/check_in_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector.sync_job_check_in' do + let(:expected_args) do + [ + 'PUT', + '_connector/_sync_job/foo/_check_in', + {}, + nil, + {}, + { + defined_params: {connector_sync_job_id: "foo"}, + endpoint: 'connector.sync_job_check_in' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.sync_job_check_in(connector_sync_job_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector_sync_job/delete_spec.rb b/elasticsearch-api/spec/unit/actions/connector_sync_job/delete_spec.rb new file mode 100644 index 0000000000..66603564be --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector_sync_job/delete_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector.sync_job_delete' do + let(:expected_args) do + [ + 'DELETE', + '_connector/_sync_job/foo', + {}, + nil, + {}, + { + defined_params: {connector_sync_job_id: 'foo'}, + endpoint: 'connector.sync_job_delete' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.sync_job_delete(connector_sync_job_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector_sync_job/error_spec.rb b/elasticsearch-api/spec/unit/actions/connector_sync_job/error_spec.rb new file mode 100644 index 0000000000..f850d003ba --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector_sync_job/error_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector.sync_job_error' do + let(:expected_args) do + [ + 'PUT', + '_connector/_sync_job/foo/_error', + {}, + {}, + {}, + { + defined_params: {connector_sync_job_id: "foo"}, + endpoint: 'connector.sync_job_error' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.sync_job_error(connector_sync_job_id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector_sync_job/get_spec.rb b/elasticsearch-api/spec/unit/actions/connector_sync_job/get_spec.rb new file mode 100644 index 0000000000..dcc9b4b4ec --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector_sync_job/get_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector.sync_job_get' do + let(:expected_args) do + [ + 'GET', + '_connector/_sync_job/foo', + {}, + nil, + {}, + { + defined_params: {connector_sync_job_id: "foo"}, + endpoint: 'connector.sync_job_get' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.sync_job_get(connector_sync_job_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector_sync_job/list_spec.rb b/elasticsearch-api/spec/unit/actions/connector_sync_job/list_spec.rb new file mode 100644 index 0000000000..2bfe10b52d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector_sync_job/list_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector.sync_job_list' do + let(:expected_args) do + [ + 'GET', + '_connector/_sync_job', + {}, + nil, + {}, + { endpoint: 'connector.sync_job_list' } + ] + end + + it 'performs the request' do + expect(client_double.connector.sync_job_list).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector_sync_job/post_spec.rb b/elasticsearch-api/spec/unit/actions/connector_sync_job/post_spec.rb new file mode 100644 index 0000000000..130c00c0b1 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector_sync_job/post_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector.sync_job_post' do + let(:expected_args) do + [ + 'POST', + '_connector/_sync_job', + {}, + {}, + {}, + { endpoint: 'connector.sync_job_post' } + ] + end + + it 'performs the request' do + expect(client_double.connector.sync_job_post(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/connector_sync_job/update_stats_spec.rb b/elasticsearch-api/spec/unit/actions/connector_sync_job/update_stats_spec.rb new file mode 100644 index 0000000000..b44f0c7198 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/connector_sync_job/update_stats_spec.rb @@ -0,0 +1,38 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.connector.sync_job_update_stats' do + let(:expected_args) do + [ + 'PUT', + '_connector/_sync_job/foo/_stats', + {}, + {}, + {}, + { + defined_params: {connector_sync_job_id: "foo"}, + endpoint: 'connector.sync_job_update_stats' + } + ] + end + + it 'performs the request' do + expect(client_double.connector.sync_job_update_stats(connector_sync_job_id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/count_spec.rb b/elasticsearch-api/spec/unit/actions/count_spec.rb new file mode 100644 index 0000000000..e7806501dd --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/count_spec.rb @@ -0,0 +1,69 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#count' do + let(:expected_args) do + [ + 'GET', + '_count', + {}, + nil, + {}, + { endpoint: 'count' } + ] + end + + it 'performs the request' do + expect(client_double.count).to be_a Elasticsearch::API::Response + end + + context 'when an index and type are specified' do + let(:expected_args) do + [ + 'GET', + 'foo,bar/_count', + {}, + nil, + {}, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'count' } + ] + end + + it 'performs the request' do + expect(client_double.count(index: ['foo','bar'])).to be_a Elasticsearch::API::Response + end + end + + context 'when there is a query provided' do + let(:expected_args) do + [ + 'POST', + '_count', + {}, + { match: { foo: 'bar' } }, + {}, + { endpoint: 'count' } + ] + end + + it 'performs the request' do + expect(client_double.count(body: { match: { foo: 'bar' } })).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/create_document_spec.rb b/elasticsearch-api/spec/unit/actions/create_document_spec.rb new file mode 100644 index 0000000000..f3c24c26e8 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/create_document_spec.rb @@ -0,0 +1,89 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#create_document' do + let(:expected_args) do + [ + 'PUT', + 'foo/_create/123', + {}, + { foo: 'bar' }, + {}, + { defined_params: { id: '123', index: 'foo' }, endpoint: 'create' } + ] + end + + it 'performs the request' do + expect(client_double.create(index: 'foo', id: '123', body: { foo: 'bar' })).to be_a Elasticsearch::API::Response + end + + context 'when the request needs to be URL-escaped' do + let(:expected_args) do + [ + 'PUT', + 'foo/_doc/123', + {}, + {}, + {} + ] + end + + let(:expected_args) do + [ + 'PUT', + 'foo/_create/123', + {}, + {}, + {}, + { defined_params: { id: '123', index: 'foo' }, endpoint: 'create' } + ] + end + + it 'performs the request' do + expect(client_double.create(index: 'foo', id: '123', body: {})).to be_a Elasticsearch::API::Response + 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 + + let(:expected_args) do + [ + 'PUT', + 'foo/_create/1', + {}, + { foo: 'bar' }, + {}, + { defined_params: { id: 1, index: 'foo' }, endpoint: 'create' } + ] + end + + it 'performs the request' do + expect(client_double.create(index: 'foo', id: 1, body: { foo: 'bar' })).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb b/elasticsearch-api/spec/unit/actions/dangling_indices/delete_dangling_indices_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb rename to elasticsearch-api/spec/unit/actions/dangling_indices/delete_dangling_indices_spec.rb index 4aaa50e897..95a25c958e 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/delete_dangling_indices_spec.rb +++ b/elasticsearch-api/spec/unit/actions/dangling_indices/delete_dangling_indices_spec.rb @@ -24,7 +24,8 @@ '_dangling/foo', {}, nil, - {} + {}, + { defined_params: { index_uuid:'foo' }, endpoint: 'dangling_indices.delete_dangling_index' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb b/elasticsearch-api/spec/unit/actions/dangling_indices/import_dangling_indices_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb rename to elasticsearch-api/spec/unit/actions/dangling_indices/import_dangling_indices_spec.rb index 7b46f5c17d..86f1da1fb5 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/import_dangling_indices_spec.rb +++ b/elasticsearch-api/spec/unit/actions/dangling_indices/import_dangling_indices_spec.rb @@ -24,7 +24,8 @@ '_dangling/foo', {}, nil, - {} + {}, + { defined_params: { index_uuid:'foo' }, endpoint: 'dangling_indices.import_dangling_index' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb b/elasticsearch-api/spec/unit/actions/dangling_indices/list_dangling_indices_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb rename to elasticsearch-api/spec/unit/actions/dangling_indices/list_dangling_indices_spec.rb index 82f6d896ab..105fbc8fa5 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/dangling_indices/list_dangling_indices_spec.rb +++ b/elasticsearch-api/spec/unit/actions/dangling_indices/list_dangling_indices_spec.rb @@ -24,7 +24,8 @@ '_dangling', {}, nil, - {} + {}, + { endpoint: 'dangling_indices.list_dangling_indices' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/data_frame/update_data_frame_transform_spec.rb b/elasticsearch-api/spec/unit/actions/data_frame/update_data_frame_transform_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/data_frame/update_data_frame_transform_spec.rb rename to elasticsearch-api/spec/unit/actions/data_frame/update_data_frame_transform_spec.rb index 53e4d4ac4e..ee03bc00ca 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/data_frame/update_data_frame_transform_spec.rb +++ b/elasticsearch-api/spec/unit/actions/data_frame/update_data_frame_transform_spec.rb @@ -25,7 +25,8 @@ '_transform/foo/_update', params, {}, - {} + {}, + { defined_params: { transform_id: 'foo'}, endpoint: 'transform.update_transform' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/delete_by_query_spec.rb b/elasticsearch-api/spec/unit/actions/delete_by_query_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/delete_by_query_spec.rb rename to elasticsearch-api/spec/unit/actions/delete_by_query_spec.rb index bf19dcb924..8445e04445 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/delete_by_query_spec.rb +++ b/elasticsearch-api/spec/unit/actions/delete_by_query_spec.rb @@ -25,7 +25,8 @@ 'foo/_delete_by_query', {}, { term: {} }, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'delete_by_query' } ] end @@ -46,7 +47,8 @@ 'foo/_delete_by_query', { q: 'foo:bar' }, { query: 'query' }, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'delete_by_query' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/delete_document_spec.rb b/elasticsearch-api/spec/unit/actions/delete_document_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/delete_document_spec.rb rename to elasticsearch-api/spec/unit/actions/delete_document_spec.rb index a5fd6652e5..7621060762 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/delete_document_spec.rb +++ b/elasticsearch-api/spec/unit/actions/delete_document_spec.rb @@ -25,7 +25,8 @@ 'foo/_doc/1', params, nil, - {} + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'delete' } ] end @@ -70,7 +71,8 @@ 'foo%5Ebar/_doc/1', params, nil, - {} + {}, + { defined_params: { id: 1, index: 'foo^bar' }, endpoint: 'delete' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/delete_script_spec.rb b/elasticsearch-api/spec/unit/actions/delete_script_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/delete_script_spec.rb rename to elasticsearch-api/spec/unit/actions/delete_script_spec.rb index 8bcc510c77..ec243185d1 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/delete_script_spec.rb +++ b/elasticsearch-api/spec/unit/actions/delete_script_spec.rb @@ -26,7 +26,8 @@ '_scripts/foo', {}, nil, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'delete_script' } ] end diff --git a/elasticsearch-api/spec/unit/actions/enrich/delete_policy_spec.rb b/elasticsearch-api/spec/unit/actions/enrich/delete_policy_spec.rb new file mode 100644 index 0000000000..e240b3217c --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/enrich/delete_policy_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#enrich.delete_policy' do + let(:expected_args) do + [ + 'DELETE', + '_enrich/policy/foo', + {}, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'enrich.delete_policy' } + ] + end + + it 'performs the request' do + expect(client_double.enrich.delete_policy(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/enrich/execute_policy_spec.rb b/elasticsearch-api/spec/unit/actions/enrich/execute_policy_spec.rb new file mode 100644 index 0000000000..1798a486f7 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/enrich/execute_policy_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#enrich.delete_policy' do + let(:expected_args) do + [ + 'PUT', + '_enrich/policy/foo/_execute', + {}, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'enrich.execute_policy' } + ] + end + + it 'performs the request' do + expect(client_double.enrich.execute_policy(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/enrich/get_policy_spec.rb b/elasticsearch-api/spec/unit/actions/enrich/get_policy_spec.rb new file mode 100644 index 0000000000..7a84856c2e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/enrich/get_policy_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#enrich.delete_policy' do + let(:expected_args) do + [ + 'GET', + '_enrich/policy/foo', + {}, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'enrich.get_policy' } + ] + end + + it 'performs the request' do + expect(client_double.enrich.get_policy(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/enrich/put_policy_spec.rb b/elasticsearch-api/spec/unit/actions/enrich/put_policy_spec.rb new file mode 100644 index 0000000000..6291cf4392 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/enrich/put_policy_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#enrich.delete_policy' do + let(:expected_args) do + [ + 'PUT', + '_enrich/policy/foo', + {}, + {}, + {}, + { defined_params: { name: 'foo' }, endpoint: 'enrich.put_policy' } + ] + end + + it 'performs the request' do + expect(client_double.enrich.put_policy(body: {}, name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/enrich/stats_spec.rb b/elasticsearch-api/spec/unit/actions/enrich/stats_spec.rb new file mode 100644 index 0000000000..2963d4790c --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/enrich/stats_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#enrich.delete_policy' do + let(:expected_args) do + [ + 'GET', + '_enrich/_stats', + {}, + nil, + {}, + { endpoint: 'enrich.stats' } + ] + end + + it 'performs the request' do + expect(client_double.enrich.stats).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/eql/delete_spec.rb b/elasticsearch-api/spec/unit/actions/eql/delete_spec.rb new file mode 100644 index 0000000000..8b070d8221 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/eql/delete_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#eql.search' do + let(:expected_args) do + [ + 'DELETE', + '_eql/search/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'eql.delete' } + ] + end + + it 'performs the request' do + expect(client_double.eql.delete(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/eql/get_spec.rb b/elasticsearch-api/spec/unit/actions/eql/get_spec.rb new file mode 100644 index 0000000000..4c8cc6dac0 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/eql/get_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#eql.search' do + let(:expected_args) do + [ + 'GET', + '_eql/search/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'eql.get' } + ] + end + + it 'performs the request' do + expect(client_double.eql.get(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/eql/get_status_spec.rb b/elasticsearch-api/spec/unit/actions/eql/get_status_spec.rb new file mode 100644 index 0000000000..6a7f53533b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/eql/get_status_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#eql.search' do + let(:expected_args) do + [ + 'GET', + '_eql/search/status/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'eql.get_status' } + ] + end + + it 'performs the request' do + expect(client_double.eql.get_status(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/eql/search_spec.rb b/elasticsearch-api/spec/unit/actions/eql/search_spec.rb new file mode 100644 index 0000000000..6364838f38 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/eql/search_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#eql.search' do + let(:expected_args) do + [ + 'POST', + 'foo/_eql/search', + {}, + {}, + {}, + { defined_params: { index: 'foo' }, endpoint: 'eql.search' } + ] + end + + it 'performs the request' do + expect(client_double.eql.search(index: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/esql/async_query_delete_spec.rb b/elasticsearch-api/spec/unit/actions/esql/async_query_delete_spec.rb new file mode 100644 index 0000000000..2eb85ef6eb --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/async_query_delete_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.esql#async_query_delete' do + let(:expected_args) do + [ + 'DELETE', + '_query/async/foo', + {}, + nil, + {}, + { defined_params: {id: 'foo' }, endpoint: 'esql.async_query_delete' } + ] + end + + it 'performs the request' do + expect(client_double.esql.async_query_delete(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/esql/async_query_get._spec.rb b/elasticsearch-api/spec/unit/actions/esql/async_query_get._spec.rb new file mode 100644 index 0000000000..e2b934853f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/async_query_get._spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.esql#async_query_get' do + let(:expected_args) do + [ + 'GET', + '_query/async/foo', + {}, + nil, + {}, + { defined_params: {id: 'foo' }, endpoint: 'esql.async_query_get' } + ] + end + + it 'performs the request' do + expect(client_double.esql.async_query_get(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/esql/async_query_spec.rb b/elasticsearch-api/spec/unit/actions/esql/async_query_spec.rb new file mode 100644 index 0000000000..acf1666189 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/async_query_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.esql#async_query' do + let(:expected_args) do + [ + 'POST', + '_query/async', + {}, + {}, + {}, + { endpoint: 'esql.async_query' } + ] + end + + it 'performs the request' do + expect(client_double.esql.async_query(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/esql/async_query_stop_spec.rb b/elasticsearch-api/spec/unit/actions/esql/async_query_stop_spec.rb new file mode 100644 index 0000000000..48f61e409f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/async_query_stop_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.esql#async_query_stop' do + let(:expected_args) do + [ + 'POST', + '_query/async/foo/stop', + {}, + nil, + {}, + { endpoint: 'esql.async_query_stop', defined_params: { id: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.esql.async_query_stop(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/esql/get_query_spec.rb b/elasticsearch-api/spec/unit/actions/esql/get_query_spec.rb new file mode 100644 index 0000000000..15c9d48bbe --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/get_query_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.esql#query' do + let(:expected_args) do + [ + 'GET', + '_query/queries/test', + {}, + nil, + {}, + { endpoint: 'esql.get_query', defined_params: { id: 'test' } } + ] + end + + it 'performs the request' do + expect(client_double.esql.get_query(id: 'test')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/esql/list_queries_spec.rb b/elasticsearch-api/spec/unit/actions/esql/list_queries_spec.rb new file mode 100644 index 0000000000..4bc4a99d73 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/list_queries_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.esql#list_queries' do + let(:expected_args) do + [ + 'GET', + '_query/queries', + {}, + nil, + {}, + { endpoint: 'esql.list_queries' } + ] + end + + it 'performs the request' do + expect(client_double.esql.list_queries).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/esql/query_spec.rb b/elasticsearch-api/spec/unit/actions/esql/query_spec.rb new file mode 100644 index 0000000000..681ecedd4a --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/query_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.esql#query' do + let(:expected_args) do + [ + 'POST', + '_query', + {}, + {}, + {}, + { endpoint: 'esql.query' } + ] + end + + it 'performs the request' do + expect(client_double.esql.query(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/exists_document_spec.rb b/elasticsearch-api/spec/unit/actions/exists_document_spec.rb similarity index 96% rename from elasticsearch-api/spec/elasticsearch/api/actions/exists_document_spec.rb rename to elasticsearch-api/spec/unit/actions/exists_document_spec.rb index cd394d88e5..bd4ed1e402 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/exists_document_spec.rb +++ b/elasticsearch-api/spec/unit/actions/exists_document_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'exists' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/explain_document_spec.rb b/elasticsearch-api/spec/unit/actions/explain_document_spec.rb similarity index 77% rename from elasticsearch-api/spec/elasticsearch/api/actions/explain_document_spec.rb rename to elasticsearch-api/spec/unit/actions/explain_document_spec.rb index 157f06d708..50f6ce7f88 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/explain_document_spec.rb +++ b/elasticsearch-api/spec/unit/actions/explain_document_spec.rb @@ -24,7 +24,8 @@ url, params, body, - {} + {}, + { defined_params: { id: 1, index: 'foo' }, endpoint: 'explain' } ] end @@ -68,6 +69,17 @@ { q: 'abc123' } end + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'explain' } + ] + end + let(:body) do nil end @@ -82,6 +94,17 @@ { query: { match: {} } } end + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'explain' } + ] + end + it 'passes the query definition' do expect(client_double.explain(index: 'foo', id: '1', body: { query: { match: {} } })).to be_a Elasticsearch::API::Response end @@ -92,6 +115,17 @@ 'foo%5Ebar/_explain/1' end + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { id: '1', index: 'foo^bar' }, endpoint: 'explain' } + ] + end + it 'URL-escapes the parts' do expect(client_double.explain(index: 'foo^bar', id: '1', body: { })).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/features/get_features_spec.rb b/elasticsearch-api/spec/unit/actions/features/get_features_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/features/get_features_spec.rb rename to elasticsearch-api/spec/unit/actions/features/get_features_spec.rb index d83ce6c00e..1fd5529b9e 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/features/get_features_spec.rb +++ b/elasticsearch-api/spec/unit/actions/features/get_features_spec.rb @@ -24,7 +24,8 @@ '_features', {}, nil, - {} + {}, + { endpoint: 'features.get_features' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/features/reset_features_spec.rb b/elasticsearch-api/spec/unit/actions/features/reset_features_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/features/reset_features_spec.rb rename to elasticsearch-api/spec/unit/actions/features/reset_features_spec.rb index e3be261c34..950b568f1f 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/features/reset_features_spec.rb +++ b/elasticsearch-api/spec/unit/actions/features/reset_features_spec.rb @@ -24,7 +24,8 @@ '_features/_reset', {}, nil, - {} + {}, + { endpoint: 'features.reset_features' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/field_caps_spec.rb b/elasticsearch-api/spec/unit/actions/field_caps_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/field_caps_spec.rb rename to elasticsearch-api/spec/unit/actions/field_caps_spec.rb index 8799ccda84..e7c905a27e 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/field_caps_spec.rb +++ b/elasticsearch-api/spec/unit/actions/field_caps_spec.rb @@ -25,7 +25,8 @@ 'foo/_field_caps', { fields: 'bar' }, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'field_caps' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/fleet/global_checkpoints_spec.rb b/elasticsearch-api/spec/unit/actions/fleet/global_checkpoints_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/fleet/global_checkpoints_spec.rb rename to elasticsearch-api/spec/unit/actions/fleet/global_checkpoints_spec.rb index d5eb4de812..0f934ad019 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/fleet/global_checkpoints_spec.rb +++ b/elasticsearch-api/spec/unit/actions/fleet/global_checkpoints_spec.rb @@ -24,7 +24,8 @@ 'foo/_fleet/global_checkpoints', {}, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'fleet.global_checkpoints' } ] end diff --git a/elasticsearch-api/spec/unit/actions/fleet/msearch_spec.rb b/elasticsearch-api/spec/unit/actions/fleet/msearch_spec.rb new file mode 100644 index 0000000000..40ef5f6584 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/fleet/msearch_spec.rb @@ -0,0 +1,51 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#fleet.msearch' do + let(:expected_args) do + [ + 'POST', + '_fleet/_fleet_msearch', + {}, + {}, + headers, + { endpoint: 'fleet.msearch' } + ] + end + + let(:headers) { + { + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + } + } + + it 'performs the request' do + expect(client_double.fleet.msearch(body: {})).to be_a Elasticsearch::API::Response + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :body argument' do + expect { + client.fleet.msearch + }.to raise_exception(ArgumentError) + end +end diff --git a/elasticsearch-api/spec/unit/actions/fleet/search_spec.rb b/elasticsearch-api/spec/unit/actions/fleet/search_spec.rb new file mode 100644 index 0000000000..6f49db20b4 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/fleet/search_spec.rb @@ -0,0 +1,45 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#fleet.search' do + let(:expected_args) do + [ + 'GET', + 'foo/_fleet/_fleet_search', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'fleet.search' } + ] + end + + it 'performs the request' do + expect(client_double.fleet.search(index: 'foo')).to be_a Elasticsearch::API::Response + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :index argument' do + expect { + client.fleet.search + }.to raise_exception(ArgumentError) + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/get_document_source_spec.rb b/elasticsearch-api/spec/unit/actions/get_document_source_spec.rb similarity index 88% rename from elasticsearch-api/spec/elasticsearch/api/actions/get_document_source_spec.rb rename to elasticsearch-api/spec/unit/actions/get_document_source_spec.rb index 29dc28500c..6c655ad76f 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/get_document_source_spec.rb +++ b/elasticsearch-api/spec/unit/actions/get_document_source_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'get_source' } ] end @@ -69,6 +70,17 @@ 'foo%5Ebar/_source/1' end + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { id: '1', index: 'foo^bar' }, endpoint: 'get_source' } + ] + end + it 'URL-escapes the parts' do expect(client_double.get_source(index: 'foo^bar', id: '1')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/get_document_spec.rb b/elasticsearch-api/spec/unit/actions/get_document_spec.rb similarity index 89% rename from elasticsearch-api/spec/elasticsearch/api/actions/get_document_spec.rb rename to elasticsearch-api/spec/unit/actions/get_document_spec.rb index e5335e723e..e0951a12bf 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/get_document_spec.rb +++ b/elasticsearch-api/spec/unit/actions/get_document_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'get' } ] end @@ -68,6 +69,17 @@ 'foo%5Ebar/_doc/1' end + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { id: '1', index: 'foo^bar' }, endpoint: 'get' } + ] + end + it 'URL-escapes the parts' do expect(client_double.get(index: 'foo^bar', id: '1')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/get_script_spec.rb b/elasticsearch-api/spec/unit/actions/get_script_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/get_script_spec.rb rename to elasticsearch-api/spec/unit/actions/get_script_spec.rb index ecd33cbaea..3c8cac827d 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/get_script_spec.rb +++ b/elasticsearch-api/spec/unit/actions/get_script_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'get_script' } ] end diff --git a/elasticsearch-api/spec/unit/actions/graph/explore_spec.rb b/elasticsearch-api/spec/unit/actions/graph/explore_spec.rb new file mode 100644 index 0000000000..7415a7b4ab --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/graph/explore_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#eql.search' do + let(:expected_args) do + [ + 'GET', + 'foo/_graph/explore', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'graph.explore' } + ] + end + + it 'performs the request' do + expect(client_double.graph.explore(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/hashie_spec.rb b/elasticsearch-api/spec/unit/actions/hashie_spec.rb similarity index 96% rename from elasticsearch-api/spec/elasticsearch/api/actions/hashie_spec.rb rename to elasticsearch-api/spec/unit/actions/hashie_spec.rb index 6081a21dd9..afba03698f 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/hashie_spec.rb +++ b/elasticsearch-api/spec/unit/actions/hashie_spec.rb @@ -17,9 +17,10 @@ require 'spec_helper' require 'hashie' +require 'hashie/logger' +Hashie.logger = Logger.new(nil) describe 'Hashie' do - let(:json) do <<-JSON { @@ -79,7 +80,7 @@ end let(:response) do - Hashie::Mash.new MultiJson.load(json) + Hashie::Mash.new(MultiJson.load(json)) end it 'wraps the response' do diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/health_report_spec.rb b/elasticsearch-api/spec/unit/actions/health_report_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/health_report_spec.rb rename to elasticsearch-api/spec/unit/actions/health_report_spec.rb index a268c98e4b..53819fc457 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/health_report_spec.rb +++ b/elasticsearch-api/spec/unit/actions/health_report_spec.rb @@ -24,7 +24,8 @@ '_health_report', {}, nil, - {} + {}, + { endpoint: 'health_report' } ] end @@ -39,7 +40,8 @@ '_health_report/foo', {}, nil, - {} + {}, + { defined_params: { feature: 'foo' }, endpoint: 'health_report' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/index_document_spec.rb b/elasticsearch-api/spec/unit/actions/index_document_spec.rb similarity index 84% rename from elasticsearch-api/spec/elasticsearch/api/actions/index_document_spec.rb rename to elasticsearch-api/spec/unit/actions/index_document_spec.rb index 0fef9c2504..b6f5abed74 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/index_document_spec.rb +++ b/elasticsearch-api/spec/unit/actions/index_document_spec.rb @@ -25,7 +25,8 @@ url, params, body, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'index' } ] end @@ -68,6 +69,17 @@ 'foo/_doc/1' end + let(:expected_args) do + [ + request_type, + url, + params, + body, + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'index' } + ] + end + it 'performs the request' do expect(client_double.index(index: 'foo', id: '1', body: body)).to be_a Elasticsearch::API::Response end @@ -103,6 +115,17 @@ { op_type: 'create' } end + let(:expected_args) do + [ + request_type, + url, + params, + body, + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'index' } + ] + end + it 'passes the URL params' do expect(client_double.index(index: 'foo', id: '1', op_type: 'create', body: body)).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/explain_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/explain_spec.rb new file mode 100644 index 0000000000..9f6bc2218f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/explain_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.index_lifecycle_management#explain' do + let(:expected_args) do + [ + 'GET', + 'foo/_ilm/explain', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'ilm.explain_lifecycle' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.index_lifecycle_management.explain_lifecycle(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/get_status_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/get_status_spec.rb new file mode 100644 index 0000000000..fd72263150 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/get_status_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.index_lifecycle_management#get_status' do + let(:expected_args) do + [ + 'GET', + '_ilm/status', + {}, + nil, + {}, + { endpoint: 'ilm.get_status' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.index_lifecycle_management.get_status(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/migrate_to_data_tiers_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers_spec.rb rename to elasticsearch-api/spec/unit/actions/index_lifecycle_management/migrate_to_data_tiers_spec.rb index e1bc703ea1..83d20814a1 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/index_lifecycle_management/migrate_to_data_tiers_spec.rb +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/migrate_to_data_tiers_spec.rb @@ -24,7 +24,8 @@ '_ilm/migrate_to_data_tiers', {}, nil, - {} + {}, + { endpoint: 'ilm.migrate_to_data_tiers' } ] end diff --git a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/move_to_step_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/move_to_step_spec.rb new file mode 100644 index 0000000000..35de205b91 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/move_to_step_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.index_lifecycle_management#move_to_step' do + let(:expected_args) do + [ + 'POST', + '_ilm/move/foo', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'ilm.move_to_step' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.index_lifecycle_management.move_to_step(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/remove_policy_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/remove_policy_spec.rb new file mode 100644 index 0000000000..900db9b56d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/remove_policy_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.index_lifecycle_management#remove_policy' do + let(:expected_args) do + [ + 'POST', + 'foo/_ilm/remove', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'ilm.remove_policy' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.index_lifecycle_management.remove_policy(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/retry_policy_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/retry_policy_spec.rb new file mode 100644 index 0000000000..979cadb1ef --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/retry_policy_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.index_lifecycle_management#retry' do + let(:expected_args) do + [ + 'POST', + 'foo/_ilm/retry', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'ilm.retry' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.index_lifecycle_management.retry(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/start_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/start_spec.rb new file mode 100644 index 0000000000..7c98f25335 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/start_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.index_lifecycle_management#start' do + let(:expected_args) do + [ + 'POST', + '_ilm/start', + {}, + nil, + {}, + { endpoint: 'ilm.start' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.index_lifecycle_management.start).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/index_lifecycle_management/stop_spec.rb b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/stop_spec.rb new file mode 100644 index 0000000000..f64441ea00 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/index_lifecycle_management/stop_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.index_lifecycle_management#stop' do + let(:expected_args) do + [ + 'POST', + '_ilm/stop', + {}, + nil, + {}, + { endpoint: 'ilm.stop' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.index_lifecycle_management.stop).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/add_block_spec.rb b/elasticsearch-api/spec/unit/actions/indices/add_block_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/add_block_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/add_block_spec.rb index 8373010f3a..efbbe1aa39 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/add_block_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/add_block_spec.rb @@ -24,7 +24,9 @@ url, {}, nil, - {} + {}, + { defined_params: { block: 'test_block', index: 'test_index' }, + endpoint: 'indices.add_block'} ] end let(:url) { "#{index}/_block/#{block}"} diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/analyze_spec.rb b/elasticsearch-api/spec/unit/actions/indices/analyze_spec.rb similarity index 87% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/analyze_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/analyze_spec.rb index d45de49ba5..c23218b8b7 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/analyze_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/analyze_spec.rb @@ -24,7 +24,8 @@ url, params, body, - {} + {}, + { endpoint: 'indices.analyze' } ] end let(:method) { 'GET' } @@ -50,6 +51,17 @@ 'foo/_analyze' end + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.analyze' } + ] + end + it 'performs the request' do expect(client_double.indices.analyze(index: 'foo')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/indices/clear_cache_spec.rb b/elasticsearch-api/spec/unit/actions/indices/clear_cache_spec.rb new file mode 100644 index 0000000000..c5797ef680 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/clear_cache_spec.rb @@ -0,0 +1,103 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices#clear_cache' do + + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { endpoint: 'indices.clear_cache' } + ] + end + + let(:url) do + '_cache/clear' + end + + let(:params) do + {} + end + + it 'performs the request' do + expect(client_double.indices.clear_cache).to be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + + let(:url) do + 'foo/_cache/clear' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.clear_cache' } + ] + end + + it 'performs the request' do + expect(client_double.indices.clear_cache(index: 'foo')).to be_a Elasticsearch::API::Response + 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 be_a Elasticsearch::API::Response + end + end + + context 'when the path must be URL-escaped' do + + let(:url) do + 'foo%5Ebar/_cache/clear' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.clear_cache' } + ] + end + + let(:params) do + { } + end + + it 'performs the request' do + expect(client_double.indices.clear_cache(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/clone_spec.rb b/elasticsearch-api/spec/unit/actions/indices/clone_spec.rb new file mode 100644 index 0000000000..ab080402ca --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/clone_spec.rb @@ -0,0 +1,124 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices#clone' do + + let(:expected_args) do + [ + 'PUT', + url, + params, + body, + {}, + { defined_params: { index: 'my_source_index', target: 'my_target_index' }, + endpoint: 'indices.clone' } + ] + 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 Elasticsearch::API }.new + end + + it 'raises an exception' do + expect { + client.indices.clone(target: 'my_target_index') + }.to raise_exception(ArgumentError) + end + end + + context 'when there is no index specified' do + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'raises an exception' do + expect { + client.indices.clone(index: 'my_source_index') + }.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 be_a Elasticsearch::API::Response + end + end + + context 'when params are provided' do + + let(:params) do + { + timeout: '1s', + master_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', + master_timeout: '10s', + wait_for_active_shards: 1)).to be_a Elasticsearch::API::Response + 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 be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/close_spec.rb b/elasticsearch-api/spec/unit/actions/indices/close_spec.rb similarity index 87% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/close_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/close_spec.rb index 300ad0c0e9..a0f4b2f837 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/close_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/close_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.close' } ] end @@ -78,6 +79,17 @@ 'foo%5Ebar/_close' end + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.close' } + ] + end + it 'performs the request' do expect(client_double.indices.close(index: 'foo^bar')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/indices/create_data_stream_spec.rb b/elasticsearch-api/spec/unit/actions/indices/create_data_stream_spec.rb new file mode 100644 index 0000000000..0297c8f4e5 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/create_data_stream_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices.create_data_stream' do + let(:expected_args) do + [ + 'PUT', + '_data_stream/foo', + {}, + nil, + {}, + { endpoint: 'indices.create_data_stream', defined_params: { name: 'foo' } } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.indices.create_data_stream(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/create_spec.rb b/elasticsearch-api/spec/unit/actions/indices/create_spec.rb new file mode 100644 index 0000000000..719b493ef9 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/create_spec.rb @@ -0,0 +1,97 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices#create' do + + let(:expected_args) do + [ + 'PUT', + url, + params, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.create' } + ] + end + + let(:params) do + {} + end + + context 'when there is no index specified' do + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'raises an exception' do + expect { + client.indices.create + }.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 be_a Elasticsearch::API::Response + 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 be_a Elasticsearch::API::Response + end + end + + context 'when the path must be URL-escaped' do + + let(:url) do + 'foo%5Ebar' + end + + let(:expected_args) do + [ + 'PUT', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.create' } + ] + end + + it 'performs the request' do + expect(client_double.indices.create(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/data_streams_stats_spec.rb b/elasticsearch-api/spec/unit/actions/indices/data_streams_stats_spec.rb similarity index 85% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/data_streams_stats_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/data_streams_stats_spec.rb index 25fae874e6..c3f271556d 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/data_streams_stats_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/data_streams_stats_spec.rb @@ -24,7 +24,8 @@ url, params, nil, - {} + {}, + { endpoint: 'indices.data_streams_stats' } ] end @@ -51,6 +52,17 @@ '_data_stream/foo/_stats' end + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.data_streams_stats' } + ] + end + it 'performs the request' do expect(client_double.indices.data_streams_stats(name: 'foo')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb b/elasticsearch-api/spec/unit/actions/indices/delete_alias_spec.rb similarity index 85% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/delete_alias_spec.rb index 3291a6f22c..fec80ef9d7 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/delete_alias_spec.rb @@ -25,7 +25,9 @@ url, params, nil, - {} + {}, + { defined_params: { index: 'foo', name: 'bar'}, + endpoint: 'indices.delete_alias' } ] end @@ -76,6 +78,18 @@ 'foo%5Ebar/_aliases/bar%2Fbam' end + let(:expected_args) do + [ + 'DELETE', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar', name: 'bar/bam'}, + endpoint: 'indices.delete_alias' } + ] + end + it 'performs the request' do expect(client_double.indices.delete_alias(index: 'foo^bar', name: 'bar/bam')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_data_lifecycle_spec.rb b/elasticsearch-api/spec/unit/actions/indices/delete_data_lifecycle_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_data_lifecycle_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/delete_data_lifecycle_spec.rb index 8c31a867f3..f8476c97b4 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_data_lifecycle_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/delete_data_lifecycle_spec.rb @@ -24,7 +24,8 @@ '_data_stream/foo/_lifecycle', {}, nil, - {} + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.delete_data_lifecycle' } ] end diff --git a/elasticsearch-api/spec/unit/actions/indices/delete_data_stream_spec.rb b/elasticsearch-api/spec/unit/actions/indices/delete_data_stream_spec.rb new file mode 100644 index 0000000000..f354681fa3 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/delete_data_stream_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices.delete_data_stream' do + let(:expected_args) do + [ + 'DELETE', + '_data_stream/foo', + {}, + nil, + {}, + { endpoint: 'indices.delete_data_stream', defined_params: { name: 'foo' } } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.indices.delete_data_stream(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/delete_spec.rb b/elasticsearch-api/spec/unit/actions/indices/delete_spec.rb new file mode 100644 index 0000000000..fd7742515b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/delete_spec.rb @@ -0,0 +1,131 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices#delete' do + + let(:expected_args) do + [ + 'DELETE', + url, + params, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.delete' } + ] + end + + let(:params) do + {} + end + + let(:url) do + 'foo' + end + + it 'performs the request' do + expect(client_double.indices.delete(index: 'foo')).to be_a Elasticsearch::API::Response + end + + context 'when more than one index is specified' do + + let(:url) do + 'foo,bar' + end + + let(:expected_args) do + [ + 'DELETE', + url, + params, + nil, + {}, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'indices.delete' } + ] + end + + it 'performs the request' do + expect(client_double.indices.delete(index: ['foo', 'bar'])).to be_a Elasticsearch::API::Response + 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 be_a Elasticsearch::API::Response + end + end + + context 'when the path must be URL-escaped' do + + let(:url) do + 'foo%5Ebar' + end + + let(:expected_args) do + [ + 'DELETE', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.delete' } + ] + end + + it 'performs the request' do + expect(client_double.indices.delete(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end + + context 'when a NotFound exception is raised by the request' do + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + before do + expect(client).to receive(:perform_request).and_raise(NotFound) + end + + it 'raises the exception' do + expect { + client.indices.delete(index: 'foo') + }.to raise_exception(NotFound) + end + end + + context 'when the ignore parameter is specified' do + + let(:client) do + Class.new { include Elasticsearch::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 eq(false) + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_template_spec.rb b/elasticsearch-api/spec/unit/actions/indices/delete_template_spec.rb similarity index 87% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_template_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/delete_template_spec.rb index d616c7fc4e..5949ff43d2 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/delete_template_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/delete_template_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.delete_template' } ] end @@ -47,6 +48,17 @@ '_template/foo%5Ebar' end + let(:expected_args) do + [ + 'DELETE', + url, + params, + nil, + {}, + { defined_params: { name: 'foo^bar' }, endpoint: 'indices.delete_template' } + ] + end + it 'performs the request' do expect(client_double.indices.delete_template(name: 'foo^bar')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/disk_usage_spec.rb b/elasticsearch-api/spec/unit/actions/indices/disk_usage_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/disk_usage_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/disk_usage_spec.rb index c674ab4a2f..e1001a8ff0 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/disk_usage_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/disk_usage_spec.rb @@ -24,7 +24,8 @@ "#{index}/_disk_usage", {}, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.disk_usage' } ] end diff --git a/elasticsearch-api/spec/unit/actions/indices/downsample_spec.rb b/elasticsearch-api/spec/unit/actions/indices/downsample_spec.rb new file mode 100644 index 0000000000..a6a71e4aaa --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/downsample_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices.downsample' do + let(:expected_args) do + [ + 'POST', + 'foo/_downsample/bar', + {}, + {}, + {}, + { endpoint: 'indices.downsample', defined_params: { index: 'foo', target_index: 'bar' } } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.indices.downsample(body: {}, index: 'foo', target_index: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_alias_spec.rb b/elasticsearch-api/spec/unit/actions/indices/exists_alias_spec.rb similarity index 83% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_alias_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/exists_alias_spec.rb index 6683ea8f2d..e1707a5413 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_alias_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/exists_alias_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { name: 'foo'}, endpoint: 'indices.exists_alias' } ] end @@ -51,6 +52,18 @@ 'foo,bar/_alias/bam' end + let(:expected_args) do + [ + 'HEAD', + url, + params, + nil, + {}, + { defined_params: { index: ['foo', 'bar'], name: 'bam'}, + endpoint: 'indices.exists_alias' } + ] + end + it 'performs the request' do expect(client_double.indices.exists_alias(index: ['foo','bar'], name: 'bam')).to eq(true) end @@ -62,6 +75,18 @@ 'foo%5Ebar/_alias/bar%2Fbam' end + let(:expected_args) do + [ + 'HEAD', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar', name: 'bar/bam'}, + endpoint: 'indices.exists_alias' } + ] + end + it 'performs the request' do expect(client_double.indices.exists_alias(index: 'foo^bar', name: 'bar/bam')).to eq(true) end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_spec.rb b/elasticsearch-api/spec/unit/actions/indices/exists_spec.rb similarity index 84% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/exists_spec.rb index 2637686c4f..9a1f635dee 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/exists_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.exists' } ] end @@ -51,6 +52,17 @@ 'foo,bar' end + let(:expected_args) do + [ + 'HEAD', + url, + params, + nil, + {}, + { defined_params: { index: ['foo','bar'] }, endpoint: 'indices.exists' } + ] + end + it 'performs the request' do expect(client_double.indices.exists(index: ['foo','bar'])).to eq(true) end @@ -62,6 +74,17 @@ 'foo%5Ebar' end + let(:expected_args) do + [ + 'HEAD', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.exists' } + ] + end + it 'performs the request' do expect(client_double.indices.exists(index: 'foo^bar')).to eq(true) end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_template_spec.rb b/elasticsearch-api/spec/unit/actions/indices/exists_template_spec.rb similarity index 89% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_template_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/exists_template_spec.rb index 19eda3b383..0048f7ca24 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/exists_template_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/exists_template_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.exists_template' } ] end @@ -47,6 +48,17 @@ '_template/bar%2Fbam' end + let(:expected_args) do + [ + 'HEAD', + url, + params, + nil, + {}, + { defined_params: { name: 'bar/bam' }, endpoint: 'indices.exists_template' } + ] + end + it 'performs the request' do expect(client_double.indices.exists_template(name: 'bar/bam')).to eq(true) end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/explain_data_lifecycle_spec.rb b/elasticsearch-api/spec/unit/actions/indices/explain_data_lifecycle_spec.rb similarity index 90% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/explain_data_lifecycle_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/explain_data_lifecycle_spec.rb index 06ff6b0362..9b072557d2 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/explain_data_lifecycle_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/explain_data_lifecycle_spec.rb @@ -24,7 +24,9 @@ 'foo/_lifecycle/explain', {}, nil, - {} + {}, + { defined_params: { index: 'foo' }, + endpoint: 'indices.explain_data_lifecycle' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/field_usage_stats_spec.rb b/elasticsearch-api/spec/unit/actions/indices/field_usage_stats_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/field_usage_stats_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/field_usage_stats_spec.rb index 970811655e..cf84578807 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/field_usage_stats_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/field_usage_stats_spec.rb @@ -24,7 +24,8 @@ 'foo/_field_usage_stats', {}, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.field_usage_stats' } ] end diff --git a/elasticsearch-api/spec/unit/actions/indices/flush_spec.rb b/elasticsearch-api/spec/unit/actions/indices/flush_spec.rb new file mode 100644 index 0000000000..3f81b40628 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/flush_spec.rb @@ -0,0 +1,136 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices#flush' do + + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { endpoint: 'indices.flush' } + ] + end + + let(:params) do + {} + end + + let(:url) do + '_flush' + end + + it 'performs the request' do + expect(client_double.indices.flush).to be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + + let(:url) do + 'foo/_flush' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.flush' } + ] + end + + it 'performs the request' do + expect(client_double.indices.flush(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indices are specified' do + + let(:url) do + 'foo,bar/_flush' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { defined_params: { index: ['foo','bar'] }, endpoint: 'indices.flush' } + ] + end + + it 'performs the request' do + expect(client_double.indices.flush(index: ['foo','bar'])).to be_a Elasticsearch::API::Response + end + end + + context 'when the path needs to be URL-escaped' do + + let(:url) do + 'foo%5Ebar/_flush' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.flush' } + ] + end + + it 'performs the request' do + expect(client_double.indices.flush(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end + + context 'when URL parameters are specified' do + + let(:url) do + 'foo/_flush' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.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 be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/forcemerge_spec.rb b/elasticsearch-api/spec/unit/actions/indices/forcemerge_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/forcemerge_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/forcemerge_spec.rb index 574d63d229..e64284e9b4 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/forcemerge_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/forcemerge_spec.rb @@ -25,7 +25,8 @@ '_forcemerge', {}, nil, - {} + {}, + { endpoint: 'indices.forcemerge' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_alias_spec.rb b/elasticsearch-api/spec/unit/actions/indices/get_alias_spec.rb similarity index 76% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/get_alias_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/get_alias_spec.rb index 7d99384beb..b1000df66f 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_alias_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/get_alias_spec.rb @@ -25,7 +25,8 @@ url, {}, nil, - {} + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.get_alias' } ] end @@ -43,6 +44,18 @@ 'foo,bar/_alias/bam' end + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: ['foo', 'bar'], name: 'bam' }, endpoint: 'indices.get_alias' } + ] + end + + it 'performs the request' do expect(client_double.indices.get_alias(index: ['foo','bar'], name: 'bam')).to be_a Elasticsearch::API::Response end @@ -54,6 +67,17 @@ 'foo%5Ebar/_alias/bar%2Fbam' end + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo^bar', name: 'bar/bam' }, endpoint: 'indices.get_alias' } + ] + end + it 'performs the request' do expect(client_double.indices.get_alias(index: 'foo^bar', name: 'bar/bam')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_data_lifecycle_spec.rb b/elasticsearch-api/spec/unit/actions/indices/get_data_lifecycle_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/get_data_lifecycle_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/get_data_lifecycle_spec.rb index d61c6274d1..5912ddfa10 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/get_data_lifecycle_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/get_data_lifecycle_spec.rb @@ -24,7 +24,8 @@ '_data_stream/foo/_lifecycle', {}, nil, - {} + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.get_data_lifecycle' } ] end diff --git a/elasticsearch-api/spec/unit/actions/indices/get_data_lifecycle_stats_spec.rb b/elasticsearch-api/spec/unit/actions/indices/get_data_lifecycle_stats_spec.rb new file mode 100644 index 0000000000..8938b5a156 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/get_data_lifecycle_stats_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices#get_data_lifecycle_stats' do + let(:expected_args) do + [ + 'GET', + '_lifecycle/stats', + {}, + nil, + {}, + { endpoint: 'indices.get_data_lifecycle_stats' } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_data_lifecycle_stats).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/get_data_stream_spec.rb b/elasticsearch-api/spec/unit/actions/indices/get_data_stream_spec.rb new file mode 100644 index 0000000000..487fe693ee --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/get_data_stream_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices.get_data_stream' do + let(:expected_args) do + [ + 'GET', + '_data_stream', + {}, + nil, + {}, + { endpoint: 'indices.get_data_stream' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.indices.get_data_stream).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/get_field_mapping_spec.rb b/elasticsearch-api/spec/unit/actions/indices/get_field_mapping_spec.rb new file mode 100644 index 0000000000..e9550b65e9 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/get_field_mapping_spec.rb @@ -0,0 +1,61 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#get_field_mapping' do + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'indices.get_field_mapping', defined_params: { fields: 'foo' } } + ] + end + + let(:url) do + '_mapping/field/foo' + end + + it 'performs the request' do + expect(client_double.indices.get_field_mapping(fields: 'foo')).to be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + let(:url) do + 'foo/_mapping/field/bam' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo', fields: 'bam' }, endpoint: 'indices.get_field_mapping' } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_field_mapping(index: 'foo', fields: 'bam')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/get_mapping_spec.rb b/elasticsearch-api/spec/unit/actions/indices/get_mapping_spec.rb new file mode 100644 index 0000000000..5a6f018d9d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/get_mapping_spec.rb @@ -0,0 +1,102 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#get_mapping' do + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'indices.get_mapping' } + ] + end + + let(:url) do + '_mapping' + end + + it 'performs the request' do + expect(client_double.indices.get_mapping).to be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + let(:url) do + 'foo/_mapping' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.get_mapping' } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_mapping(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indices are specified' do + let(:url) do + 'foo,bar/_mapping' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'indices.get_mapping' } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_mapping(index: ['foo', 'bar'])).to be_a Elasticsearch::API::Response + end + end + + context 'when the path must be URL-escaped' do + let(:url) do + 'foo%5Ebar/_mapping' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.get_mapping' } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_mapping(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/get_settings_spec.rb b/elasticsearch-api/spec/unit/actions/indices/get_settings_spec.rb new file mode 100644 index 0000000000..9d6bb92f22 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/get_settings_spec.rb @@ -0,0 +1,106 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#get_settings' do + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'indices.get_settings' } + ] + end + + let(:url) do + '_settings' + end + + it 'performs the request' do + expect(client_double.indices.get_settings).to be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + + let(:url) do + 'foo/_settings' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.get_settings' } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_settings(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when a name is specified' do + + let(:url) do + 'foo/_settings/foo.bar' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo', name: 'foo.bar' }, endpoint: 'indices.get_settings' } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_settings(index: 'foo', name: 'foo.bar')).to be_a Elasticsearch::API::Response + end + end + + context 'when the path must be URL-escaped' do + + let(:url) do + 'foo%5Ebar/_settings' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.get_settings' } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_settings(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/get_spec.rb b/elasticsearch-api/spec/unit/actions/indices/get_spec.rb new file mode 100644 index 0000000000..8d38d465a2 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/get_spec.rb @@ -0,0 +1,55 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices#get' do + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.get' } + ] + end + + let(:params) do + {} + end + + let(:url) do + 'foo' + end + + it 'performs the request' do + expect(client_double.indices.get(index: 'foo')).to be_a Elasticsearch::API::Response + 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 be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/indices_migrate_spec.rb b/elasticsearch-api/spec/unit/actions/indices/indices_migrate_spec.rb new file mode 100644 index 0000000000..7a53de9155 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/indices_migrate_spec.rb @@ -0,0 +1,88 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices' do + context 'migrate_reindex' do + let(:expected_args) do + [ + 'POST', + '_migration/reindex', + {}, + {}, + {}, + { endpoint: 'indices.migrate_reindex' } + ] + end + + it 'performs the request' do + expect(client_double.indices.migrate_reindex(body: {})).to be_a Elasticsearch::API::Response + end + end + + context 'get_migrate_reindex_status' do + let(:expected_args) do + [ + 'GET', + '_migration/reindex/foo/_status', + {}, + nil, + {}, + { endpoint: 'indices.get_migrate_reindex_status', defined_params: { index: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.indices.get_migrate_reindex_status(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'cancel_migrate_reindex' do + let(:expected_args) do + [ + 'POST', + '_migration/reindex/foo/_cancel', + {}, + nil, + {}, + { endpoint: 'indices.cancel_migrate_reindex', defined_params: { index: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.indices.cancel_migrate_reindex(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'create_from' do + let(:expected_args) do + [ + 'PUT', + '_create_from/foo/bar', + {}, + {}, + {}, + { endpoint: 'indices.create_from', defined_params: { source: 'foo', dest: 'bar' } } + ] + end + + it 'performs the request' do + expect(client_double.indices.create_from(body: {}, source: 'foo', dest: 'bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/migrate_to_data_stream_spec.rb b/elasticsearch-api/spec/unit/actions/indices/migrate_to_data_stream_spec.rb new file mode 100644 index 0000000000..a009ec4545 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/migrate_to_data_stream_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices.migrate_to_data_stream' do + let(:expected_args) do + [ + 'POST', + '_data_stream/_migrate/foo', + {}, + nil, + {}, + { endpoint: 'indices.migrate_to_data_stream', defined_params: { name: 'foo' } } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.indices.migrate_to_data_stream(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/modify_data_stream_spec.rb b/elasticsearch-api/spec/unit/actions/indices/modify_data_stream_spec.rb new file mode 100644 index 0000000000..107e01eb01 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/modify_data_stream_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices.modify_data_stream' do + let(:expected_args) do + [ + 'POST', + '_data_stream/_modify', + {}, + {}, + {}, + { endpoint: 'indices.modify_data_stream' } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.indices.modify_data_stream(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/open_spec.rb b/elasticsearch-api/spec/unit/actions/indices/open_spec.rb similarity index 85% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/open_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/open_spec.rb index a620efa0e4..3b3412a2b6 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/open_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/open_spec.rb @@ -25,7 +25,8 @@ url, params, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.open' } ] end @@ -58,6 +59,17 @@ 'foo%5Ebar/_open' end + let(:expected_args) do + [ + 'POST', + url, + params, + nil, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.open' } + ] + end + it 'performs the request' do expect(client_double.indices.open(index: 'foo^bar')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/indices/promote_data_stream_spec.rb b/elasticsearch-api/spec/unit/actions/indices/promote_data_stream_spec.rb new file mode 100644 index 0000000000..ec2b2ca08b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/promote_data_stream_spec.rb @@ -0,0 +1,37 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices.promote_data_stream' do + let(:expected_args) do + [ + 'POST', + '_data_stream/_promote/foo', + {}, + nil, + {}, + { endpoint: 'indices.promote_data_stream', defined_params: { name: 'foo' } } + ] + end + + let(:index) { 'foo' } + + it 'performs the request' do + expect(client_double.indices.promote_data_stream(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_alias_spec.rb b/elasticsearch-api/spec/unit/actions/indices/put_alias_spec.rb similarity index 80% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/put_alias_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/put_alias_spec.rb index 9cda71ae2b..12a1f71dd2 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/put_alias_spec.rb @@ -25,7 +25,9 @@ url, {}, body, - {} + {}, + { defined_params: { index: 'foo', name: 'bar' }, + endpoint: 'indices.put_alias' } ] end @@ -71,6 +73,18 @@ 'foo,bar/_aliases/bam' end + let(:expected_args) do + [ + 'PUT', + url, + {}, + body, + {}, + { defined_params: { index: ['foo','bar'], name: 'bam' }, + endpoint: 'indices.put_alias' } + ] + end + it 'performs the request' do expect(client_double.indices.put_alias(index: ['foo','bar'], name: 'bam')).to be_a Elasticsearch::API::Response end @@ -82,6 +96,18 @@ 'foo%5Ebar/_aliases/bar%2Fbam' end + let(:expected_args) do + [ + 'PUT', + url, + {}, + body, + {}, + { defined_params: { index: 'foo^bar', name: 'bar/bam' }, + endpoint: 'indices.put_alias' } + ] + end + it 'performs the request' do expect(client_double.indices.put_alias(index: 'foo^bar', name: 'bar/bam')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_data_lifecycle_spec.rb b/elasticsearch-api/spec/unit/actions/indices/put_data_lifecycle_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/put_data_lifecycle_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/put_data_lifecycle_spec.rb index 233788dbc5..fedb498df3 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_data_lifecycle_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/put_data_lifecycle_spec.rb @@ -24,7 +24,8 @@ '_data_stream/foo/_lifecycle', {}, nil, - {} + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.put_data_lifecycle' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb b/elasticsearch-api/spec/unit/actions/indices/put_mapping_spec.rb similarity index 83% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/put_mapping_spec.rb index ccd40712ee..ddce002359 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/put_mapping_spec.rb @@ -24,7 +24,8 @@ url, {}, body, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.put_mapping' } ] end @@ -79,6 +80,17 @@ 'foo,bar/_mapping' end + let(:expected_args) do + [ + 'PUT', + url, + {}, + body, + {}, + { defined_params: { index: ['foo','bar'] }, endpoint: 'indices.put_mapping' } + ] + end + it 'performs the request' do expect(client_double.indices.put_mapping(index: ['foo','bar'], body: {})).to be_a Elasticsearch::API::Response end @@ -89,6 +101,17 @@ 'foo%5Ebar/_mapping' end + let(:expected_args) do + [ + 'PUT', + url, + {}, + body, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.put_mapping' } + ] + end + it 'performs the request' do expect(client_double.indices.put_mapping(index: 'foo^bar', body: {})).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/indices/put_settings_spec.rb b/elasticsearch-api/spec/unit/actions/indices/put_settings_spec.rb new file mode 100644 index 0000000000..ef4009bc6e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/put_settings_spec.rb @@ -0,0 +1,153 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#put_settings' do + + let(:expected_args) do + [ + 'PUT', + url, + params, + body, + {}, + { endpoint: 'indices.put_settings' } + ] + 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 be_a Elasticsearch::API::Response + end + + context 'when there is no body specified' do + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'raises an exception' do + expect { + client.indices.put_settings + }.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 + + let(:expected_args) do + [ + 'PUT', + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.put_settings' } + ] + end + + it 'performs the request' do + expect(client_double.indices.put_settings(index: 'foo', flat_settings: true, body: {})).to be_a Elasticsearch::API::Response + end + end + + context 'when an index is specified' do + + let(:url) do + 'foo/_settings' + end + + let(:expected_args) do + [ + 'PUT', + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.put_settings' } + ] + end + + it 'performs the request' do + expect(client_double.indices.put_settings(index: 'foo', body: {})).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indices are specified' do + + let(:url) do + 'foo,bar/_settings' + end + + let(:expected_args) do + [ + 'PUT', + url, + params, + body, + {}, + { defined_params: { index: ['foo','bar'] }, endpoint: 'indices.put_settings' } + ] + end + + it 'performs the request' do + expect(client_double.indices.put_settings(index: ['foo','bar'], body: {})).to be_a Elasticsearch::API::Response + end + end + + context 'when the path needs to be URL-escaped' do + + let(:url) do + 'foo%5Ebar/_settings' + end + + let(:expected_args) do + [ + 'PUT', + url, + params, + body, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.put_settings' } + ] + end + + it 'performs the request' do + expect(client_double.indices.put_settings(index: 'foo^bar', body: {})).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_template_spec.rb b/elasticsearch-api/spec/unit/actions/indices/put_template_spec.rb similarity index 89% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/put_template_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/put_template_spec.rb index cba8aa18f5..a076da4e93 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/put_template_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/put_template_spec.rb @@ -25,7 +25,8 @@ url, params, body, - {} + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.put_template' } ] end @@ -100,6 +101,17 @@ {} end + let(:expected_args) do + [ + 'PUT', + url, + params, + body, + {}, + { defined_params: { name: 'foo^bar' }, endpoint: 'indices.put_template' } + ] + end + it 'performs the request' do expect(client_double.indices.put_template(name: 'foo^bar', body: {})).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/indices/recovery_spec.rb b/elasticsearch-api/spec/unit/actions/indices/recovery_spec.rb new file mode 100644 index 0000000000..cc9605dd43 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/recovery_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#recovery' do + + let(:expected_args) do + [ + 'GET', + 'foo/_recovery', + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.recovery' } + ] + end + + it 'performs the request' do + expect(client_double.indices.recovery(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/refresh_spec.rb b/elasticsearch-api/spec/unit/actions/indices/refresh_spec.rb new file mode 100644 index 0000000000..970cda977d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/refresh_spec.rb @@ -0,0 +1,136 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#refresh' do + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { endpoint: 'indices.refresh' } + ] + 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 be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + + let(:url) do + 'foo/_refresh' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.refresh' } + ] + end + + it 'performs the request' do + expect(client_double.indices.refresh(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indicies are specified as a list' do + + let(:url) do + 'foo,bar/_refresh' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'indices.refresh' } + ] + end + + it 'performs the request' do + expect(client_double.indices.refresh(index: ['foo', 'bar'])).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indicies are specified as a string' do + + let(:url) do + 'foo,bar/_refresh' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { index: 'foo,bar' }, endpoint: 'indices.refresh' } + ] + end + + it 'performs the request' do + expect(client_double.indices.refresh(index: 'foo,bar')).to be_a Elasticsearch::API::Response + end + end + + context 'when the path needs to be URL-escaped' do + + let(:url) do + 'foo%5Ebar/_refresh' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.refresh' } + ] + end + + it 'performs the request' do + expect(client_double.indices.refresh(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/indices/resolve_cluster_spec.rb b/elasticsearch-api/spec/unit/actions/indices/resolve_cluster_spec.rb new file mode 100644 index 0000000000..46c477a9c7 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/resolve_cluster_spec.rb @@ -0,0 +1,54 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.indices#delete_alias' do + context 'when there is no name specified' do + let(:expected_args) do + [ + 'GET', + '_resolve/cluster', + {}, + nil, + {}, + { endpoint: 'indices.resolve_cluster' } + ] + end + + it 'performs the request' do + expect(client_double.indices.resolve_cluster).to be_a Elasticsearch::API::Response + end + end + + context 'when name is specified' do + let(:expected_args) do + [ + 'GET', + '_resolve/cluster/foo', + {}, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'indices.resolve_cluster' } + ] + end + + it 'performs the request' do + expect(client_double.indices.resolve_cluster(name: 'foo')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/rollover_spec.rb b/elasticsearch-api/spec/unit/actions/indices/rollover_spec.rb similarity index 82% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/rollover_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/rollover_spec.rb index 70346ac04e..67a748a257 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/rollover_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/rollover_spec.rb @@ -25,7 +25,8 @@ url, params, body, - {} + {}, + { defined_params: { alias: 'foo' }, endpoint: 'indices.rollover' } ] end @@ -51,6 +52,17 @@ 'foo/_rollover/bar' end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { alias: 'foo', new_index: 'bar' }, endpoint: 'indices.rollover' } + ] + end + it 'performs the request' do expect(client_double.indices.rollover(alias: 'foo', new_index: 'bar')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/indices/segments_spec.rb b/elasticsearch-api/spec/unit/actions/indices/segments_spec.rb new file mode 100644 index 0000000000..aa2001b95d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/segments_spec.rb @@ -0,0 +1,136 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#segments' do + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { endpoint: 'indices.segments' } + ] + 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 be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + + let(:url) do + 'foo/_segments' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.segments' } + ] + end + + it 'performs the request' do + expect(client_double.indices.segments(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indicies are specified as a list' do + + let(:url) do + 'foo,bar/_segments' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'indices.segments' } + ] + end + + it 'performs the request' do + expect(client_double.indices.segments(index: ['foo', 'bar'])).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indicies are specified as a string' do + + let(:url) do + 'foo,bar/_segments' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: 'foo,bar' }, endpoint: 'indices.segments' } + ] + end + + it 'performs the request' do + expect(client_double.indices.segments(index: 'foo,bar')).to be_a Elasticsearch::API::Response + end + end + + context 'when the path needs to be URL-escaped' do + + let(:url) do + 'foo%5Ebar/_segments' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.segments' } + ] + end + + it 'performs the request' do + expect(client_double.indices.segments(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/shard_stores_spec.rb b/elasticsearch-api/spec/unit/actions/indices/shard_stores_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/shard_stores_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/shard_stores_spec.rb index a0eb410aa0..82a0eccda3 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/shard_stores_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/shard_stores_spec.rb @@ -25,7 +25,8 @@ '_shard_stores', {}, nil, - {} + {}, + { endpoint: 'indices.shard_stores' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/shrink_spec.rb b/elasticsearch-api/spec/unit/actions/indices/shrink_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/shrink_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/shrink_spec.rb index 36f15010c0..73e2682716 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/shrink_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/shrink_spec.rb @@ -25,7 +25,9 @@ 'foo/_shrink/bar', {}, nil, - {} + {}, + { defined_params: { index: 'foo', target: 'bar' }, + endpoint: 'indices.shrink' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/split_spec.rb b/elasticsearch-api/spec/unit/actions/indices/split_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/split_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/split_spec.rb index eeb1fd55b1..ba08085bdd 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/split_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/split_spec.rb @@ -25,7 +25,9 @@ 'foo/_split/bar', {}, nil, - {} + {}, + { defined_params: { index: 'foo', target: 'bar' }, + endpoint:'indices.split' } ] end diff --git a/elasticsearch-api/spec/unit/actions/indices/stats_spec.rb b/elasticsearch-api/spec/unit/actions/indices/stats_spec.rb new file mode 100644 index 0000000000..91b0ed7bb2 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/stats_spec.rb @@ -0,0 +1,186 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#stats' do + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { endpoint: 'indices.stats' } + ] + 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 be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + let(:url) do + 'foo/_stats' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.stats' } + ] + end + + it 'performs the request' do + expect(client_double.indices.stats(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indicies are specified as a list' do + let(:url) do + 'foo,bar/_stats' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'indices.stats' } + ] + end + + it 'performs the request' do + expect(client_double.indices.stats(index: ['foo', 'bar'])).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indicies are specified as a string' do + let(:url) do + 'foo,bar/_stats' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: 'foo,bar' }, endpoint: 'indices.stats' } + ] + end + + it 'performs the request' do + expect(client_double.indices.stats(index: 'foo,bar')).to be_a Elasticsearch::API::Response + end + end + + context 'when parameters are specified' do + let(:params) do + { expand_wildcards: true } + end + + let(:url) do + 'foo/_stats' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.stats' } + ] + end + + it 'performs the request' do + expect(client_double.indices.stats(index: 'foo', expand_wildcards: true)).to be_a Elasticsearch::API::Response + 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 + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { index: 'foo', metric: 'fielddata' }, endpoint: 'indices.stats' } + ] + end + + it 'performs the request' do + expect(client_double.indices.stats(index: 'foo', metric: 'fielddata', fields: ['foo', 'bar'])).to be_a Elasticsearch::API::Response + 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 + + let(:expected_args) do + [ + 'GET', + url, + params, + body, + {}, + { defined_params: { metric: 'search' }, endpoint: 'indices.stats' } + ] + end + + it 'performs the request' do + expect(client_double.indices.stats(groups: [ 'groupA', 'groupB'], metric: 'search')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/indices/update_aliases_spec.rb b/elasticsearch-api/spec/unit/actions/indices/update_aliases_spec.rb similarity index 96% rename from elasticsearch-api/spec/elasticsearch/api/actions/indices/update_aliases_spec.rb rename to elasticsearch-api/spec/unit/actions/indices/update_aliases_spec.rb index 3b6deab78a..0d18ca537a 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/indices/update_aliases_spec.rb +++ b/elasticsearch-api/spec/unit/actions/indices/update_aliases_spec.rb @@ -25,7 +25,8 @@ '_aliases', params, body, - {} + {}, + { endpoint: 'indices.update_aliases' } ] end diff --git a/elasticsearch-api/spec/unit/actions/indices/validate_query_spec.rb b/elasticsearch-api/spec/unit/actions/indices/validate_query_spec.rb new file mode 100644 index 0000000000..2aeb027e36 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/indices/validate_query_spec.rb @@ -0,0 +1,180 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.cluster#validate_query' do + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { endpoint: 'indices.validate_query' } + ] + 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 be_a Elasticsearch::API::Response + end + + context 'when an index is specified' do + let(:url) do + 'foo/_validate/query' + end + + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'indices.validate_query' } + ] + end + + it 'performs the request' do + expect(client_double.indices.validate_query(index: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indicies are specified as a list' do + let(:url) do + 'foo,bar/_validate/query' + end + + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'indices.validate_query' } + ] + end + + it 'performs the request' do + expect(client_double.indices.validate_query(index: ['foo', 'bar'])).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple indicies are specified as a string' do + let(:url) do + 'foo,bar/_validate/query' + end + + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { index: 'foo,bar' }, endpoint: 'indices.validate_query' } + ] + end + + it 'performs the request' do + expect(client_double.indices.validate_query(index: 'foo,bar')).to be_a Elasticsearch::API::Response + end + end + + context 'when parameters are specified' do + let(:params) do + { explain: true, q: 'foo' } + end + + let(:url) do + '_validate/query' + end + + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { endpoint: 'indices.validate_query' } + ] + end + + it 'performs the request' do + expect(client_double.indices.validate_query(explain: true, q: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when a body is specified' do + let(:body) do + { filtered: {} } + end + let(:method) { 'POST' } + + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { endpoint: 'indices.validate_query' } + ] + end + + it 'performs the request' do + expect(client_double.indices.validate_query(body: { filtered: {} })).to be_a Elasticsearch::API::Response + end + end + + context 'when the path needs to be URL-escaped' do + let(:url) do + 'foo%5Ebar/_validate/query' + end + + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'indices.validate_query' } + ] + end + + it 'performs the request' do + expect(client_double.indices.validate_query(index: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/chat_completion_unified_spec.rb b/elasticsearch-api/spec/unit/actions/inference/chat_completion_unified_spec.rb new file mode 100644 index 0000000000..180bcb3f64 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/chat_completion_unified_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.chat_completion_unified' do + let(:expected_args) do + [ + 'POST', + '_inference/chat_completion/bar/_stream', + {}, + {}, + {}, + { defined_params: { inference_id: 'bar' }, + endpoint: 'inference.chat_completion_unified' } + ] + end + + it 'performs the request' do + expect(client_double.inference.chat_completion_unified(inference_id: 'bar', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/completion_spec.rb b/elasticsearch-api/spec/unit/actions/inference/completion_spec.rb new file mode 100644 index 0000000000..8817e72a32 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/completion_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.completion' do + let(:expected_args) do + [ + 'POST', + '_inference/completion/bar', + {}, + nil, + {}, + { defined_params: { inference_id: 'bar' }, + endpoint: 'inference.completion' } + ] + end + + it 'performs the request' do + expect(client_double.inference.completion(inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/delete_spec.rb b/elasticsearch-api/spec/unit/actions/inference/delete_spec.rb new file mode 100644 index 0000000000..cd41a6c822 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/delete_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.delete' do + let(:expected_args) do + [ + 'DELETE', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.delete' } + ] + end + + it 'performs the request' do + expect(client_double.inference.delete(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/get_spec.rb b/elasticsearch-api/spec/unit/actions/inference/get_spec.rb new file mode 100644 index 0000000000..66cbd6e682 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/get_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.get' do + let(:expected_args) do + [ + 'GET', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.get' } + ] + end + + it 'performs the request' do + expect(client_double.inference.get(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/inference_spec.rb b/elasticsearch-api/spec/unit/actions/inference/inference_spec.rb new file mode 100644 index 0000000000..dfa2a51890 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/inference_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.inference' do + let(:expected_args) do + [ + 'POST', + '_inference/bar', + {}, + nil, + {}, + { defined_params: { inference_id: 'bar' }, + endpoint: 'inference.inference' } + ] + end + + it 'performs the request' do + expect(client_double.inference.inference(inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb new file mode 100644 index 0000000000..0ac550822f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_alibabacloud' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { alibabacloud_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_alibabacloud' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_alibabacloud(task_type: 'foo', alibabacloud_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb new file mode 100644 index 0000000000..23d5b57c39 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_amazonbedrock' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { amazonbedrock_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_amazonbedrock' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_amazonbedrock(task_type: 'foo', amazonbedrock_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb new file mode 100644 index 0000000000..3f4c22cbba --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_anthropic' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { anthropic_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_anthropic' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_anthropic(task_type: 'foo', anthropic_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb new file mode 100644 index 0000000000..add3ed7eec --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_azureaistudio' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { azureaistudio_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_azureaistudio' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_azureaistudio(task_type: 'foo', azureaistudio_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb new file mode 100644 index 0000000000..ca0ade65b7 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_azureopenai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { azureopenai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_azureopenai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_azureopenai(task_type: 'foo', azureopenai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb new file mode 100644 index 0000000000..7eb82de752 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_cohere' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { cohere_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_cohere' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_cohere(task_type: 'foo', cohere_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb new file mode 100644 index 0000000000..e91a89c850 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_elasticsearch' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { elasticsearch_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_elasticsearch' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_elasticsearch(task_type: 'foo', elasticsearch_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb new file mode 100644 index 0000000000..1862e22721 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_elser' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { elser_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_elser' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_elser(task_type: 'foo', elser_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb new file mode 100644 index 0000000000..22c5284990 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_googleaistudio' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { googleaistudio_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_googleaistudio' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_googleaistudio(task_type: 'foo', googleaistudio_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb new file mode 100644 index 0000000000..ccf6c883bf --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_googlevertexai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { googlevertexai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_googlevertexai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_googlevertexai(task_type: 'foo', googlevertexai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb new file mode 100644 index 0000000000..8feb11c28e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_hugging_face' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { huggingface_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_hugging_face' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_hugging_face(task_type: 'foo', huggingface_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb new file mode 100644 index 0000000000..bcbf0e0f00 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_jinaai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { jinaai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_jinaai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_jinaai(task_type: 'foo', jinaai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb new file mode 100644 index 0000000000..2d8d8dbd3f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_mistral' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { mistral_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_mistral' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_mistral(task_type: 'foo', mistral_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb new file mode 100644 index 0000000000..b58dd6e568 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_openai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { openai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_openai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_openai(task_type: 'foo', openai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_spec.rb new file mode 100644 index 0000000000..bdd6393727 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put' do + let(:expected_args) do + [ + 'PUT', + '_inference/bar', + {}, + {}, + {}, + { defined_params: { inference_id: 'bar' }, + endpoint: 'inference.put' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put(body: {}, inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb new file mode 100644 index 0000000000..8bac99b82d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_voyageai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { voyageai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_voyageai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_voyageai(task_type: 'foo', voyageai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_watsonx_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_watsonx_spec.rb new file mode 100644 index 0000000000..44245b8b02 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_watsonx_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.put_watsonx' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { watsonx_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_watsonx' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_watsonx(task_type: 'foo', watsonx_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/rerank_spec.rb b/elasticsearch-api/spec/unit/actions/inference/rerank_spec.rb new file mode 100644 index 0000000000..7417cd74fa --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/rerank_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.rerank' do + let(:expected_args) do + [ + 'POST', + '_inference/rerank/foo', + {}, + nil, + {}, + { defined_params: { inference_id: 'foo' }, endpoint: 'inference.rerank' } + ] + end + + it 'performs the request' do + expect(client_double.inference.rerank(inference_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/sparse_embedding_spec.rb b/elasticsearch-api/spec/unit/actions/inference/sparse_embedding_spec.rb new file mode 100644 index 0000000000..856dface5a --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/sparse_embedding_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.sparse_embedding' do + let(:expected_args) do + [ + 'POST', + '_inference/sparse_embedding/foo', + {}, + nil, + {}, + { defined_params: { inference_id: 'foo' }, endpoint: 'inference.sparse_embedding' } + ] + end + + it 'performs the request' do + expect(client_double.inference.sparse_embedding(inference_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/stream_completion_spec.rb b/elasticsearch-api/spec/unit/actions/inference/stream_completion_spec.rb new file mode 100644 index 0000000000..542b1d9941 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/stream_completion_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.stream_completion' do + let(:expected_args) do + [ + 'POST', + '_inference/completion/foo/_stream', + {}, + nil, + {}, + { defined_params: { inference_id: 'foo' }, endpoint: 'inference.stream_completion' } + ] + end + + it 'performs the request' do + expect(client_double.inference.stream_completion(inference_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/text_embedding_spec.rb b/elasticsearch-api/spec/unit/actions/inference/text_embedding_spec.rb new file mode 100644 index 0000000000..e97fda5865 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/text_embedding_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.text_embedding' do + let(:expected_args) do + [ + 'POST', + '_inference/text_embedding/foo', + {}, + nil, + {}, + { defined_params: { inference_id: 'foo' }, endpoint: 'inference.text_embedding' } + ] + end + + it 'performs the request' do + expect(client_double.inference.text_embedding(inference_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/update_spec.rb b/elasticsearch-api/spec/unit/actions/inference/update_spec.rb new file mode 100644 index 0000000000..0ee998ee5b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/update_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#inference.update' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar/_update', + {}, + {}, + {}, + { defined_params: { inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.update' } + ] + end + + it 'performs the request' do + expect(client_double.inference.update(task_type: 'foo', body: {}, inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/info_spec.rb b/elasticsearch-api/spec/unit/actions/info_spec.rb new file mode 100644 index 0000000000..8a26056683 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/info_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#info' do + let(:expected_args) do + [ + 'GET', + '', + { }, + nil, + {}, + { endpoint: 'info' } + ] + end + + it 'performs the request' do + expect(client_double.info).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/ingest/delete_geoip_database_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/delete_geoip_database_spec.rb new file mode 100644 index 0000000000..a7a3622777 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/delete_geoip_database_spec.rb @@ -0,0 +1,39 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#delete_geoip_database' do + let(:expected_args) do + [ + 'DELETE', + '_ingest/geoip/database/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.delete_geoip_database' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'performs the request' do + expect(client_double.ingest.delete_geoip_database(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/ingest/delete_ip_location_database_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/delete_ip_location_database_spec.rb new file mode 100644 index 0000000000..429faebe9c --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/delete_ip_location_database_spec.rb @@ -0,0 +1,39 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#delete_ip_location_database' do + let(:expected_args) do + [ + 'DELETE', + '_ingest/ip_location/database/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.delete_ip_location_database' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'performs the request' do + expect(client_double.ingest.delete_ip_location_database(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/ingest/delete_pipeline_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/delete_pipeline_spec.rb new file mode 100644 index 0000000000..5d7efa7c52 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/delete_pipeline_spec.rb @@ -0,0 +1,72 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#delete_pipeline' do + + let(:expected_args) do + [ + 'DELETE', + url, + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.delete_pipeline' } + ] + end + + let(:url) do + '_ingest/pipeline/foo' + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :id argument' do + expect { + client.ingest.delete_pipeline + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.ingest.delete_pipeline(id: 'foo')).to be_a Elasticsearch::API::Response + end + + context 'when the path must be URL-escaped' do + + let(:url) do + '_ingest/pipeline/foo%5Ebar' + end + + let(:expected_args) do + [ + 'DELETE', + url, + {}, + nil, + {}, + { defined_params: { id: 'foo^bar' }, endpoint: 'ingest.delete_pipeline' } + ] + end + + it 'performs the request' do + expect(client_double.ingest.delete_pipeline(id: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/geo_ip_stats_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/geo_ip_stats_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/ingest/geo_ip_stats_spec.rb rename to elasticsearch-api/spec/unit/actions/ingest/geo_ip_stats_spec.rb index 6f845d6963..91cc24079b 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/geo_ip_stats_spec.rb +++ b/elasticsearch-api/spec/unit/actions/ingest/geo_ip_stats_spec.rb @@ -24,7 +24,8 @@ '_ingest/geoip/stats', {}, nil, - {} + {}, + { endpoint: 'ingest.geo_ip_stats' } ] end diff --git a/elasticsearch-api/spec/unit/actions/ingest/get_geoip_database_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/get_geoip_database_spec.rb new file mode 100644 index 0000000000..535d653839 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/get_geoip_database_spec.rb @@ -0,0 +1,39 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#get_geoip_database' do + let(:expected_args) do + [ + 'GET', + '_ingest/geoip/database/foo', + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.get_geoip_database' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'performs the request' do + expect(client_double.ingest.get_geoip_database(id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/ingest/get_ip_location_database_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/get_ip_location_database_spec.rb new file mode 100644 index 0000000000..e8aeb2504d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/get_ip_location_database_spec.rb @@ -0,0 +1,39 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#get_ip_location_database' do + let(:expected_args) do + [ + 'GET', + '_ingest/ip_location/database/foo', + { body: {} }, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.get_ip_location_database' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'performs the request' do + expect(client_double.ingest.get_ip_location_database(id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/ingest/get_pipeline_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/get_pipeline_spec.rb new file mode 100644 index 0000000000..5a8c3e0fd4 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/get_pipeline_spec.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#get_pipeline' do + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.get_pipeline' } + ] + end + + let(:url) do + '_ingest/pipeline/foo' + end + + it 'performs the request' do + expect(client_double.ingest.get_pipeline(id: 'foo')).to be_a Elasticsearch::API::Response + end + + context 'when the path must be URL-escaped' do + + let(:url) do + '_ingest/pipeline/foo%5Ebar' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { id: 'foo^bar' }, endpoint: 'ingest.get_pipeline' } + ] + end + + it 'performs the request' do + expect(client_double.ingest.get_pipeline(id: 'foo^bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/ingest/put_geoip_database_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/put_geoip_database_spec.rb new file mode 100644 index 0000000000..e1df722c52 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/put_geoip_database_spec.rb @@ -0,0 +1,45 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#put_geoip_database' do + let(:expected_args) do + [ + 'PUT', + '_ingest/geoip/database/foo', + {}, + {}, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.put_geoip_database' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :id argument' do + expect { + client.ingest.put_geoip_database + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.ingest.put_geoip_database(id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/ingest/put_ip_location_database_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/put_ip_location_database_spec.rb new file mode 100644 index 0000000000..6e3ea29c77 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/put_ip_location_database_spec.rb @@ -0,0 +1,45 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#put_ip_location_database' do + let(:expected_args) do + [ + 'PUT', + '_ingest/ip_location/database/foo', + {}, + {}, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.put_ip_location_database' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :id argument' do + expect { + client.ingest.put_ip_location_database + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.ingest.put_ip_location_database(id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/ingest/put_pipeline_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/put_pipeline_spec.rb new file mode 100644 index 0000000000..32b56fa97f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ingest/put_pipeline_spec.rb @@ -0,0 +1,72 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.ingest#put_pipeline' do + + let(:expected_args) do + [ + 'PUT', + url, + {}, + {}, + {}, + { defined_params:{ id: 'foo' }, endpoint: 'ingest.put_pipeline' } + ] + end + + let(:url) do + '_ingest/pipeline/foo' + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :id argument' do + expect { + client.ingest.put_pipeline + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.ingest.put_pipeline(id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end + + context 'when the path must be URL-escaped' do + + let(:url) do + '_ingest/pipeline/foo%5Ebar' + end + + let(:expected_args) do + [ + 'PUT', + url, + {}, + {}, + {}, + { defined_params:{ id: 'foo^bar' }, endpoint: 'ingest.put_pipeline' } + ] + end + + it 'performs the request' do + expect(client_double.ingest.put_pipeline(id: 'foo^bar', body: {})).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/simulate_spec.rb b/elasticsearch-api/spec/unit/actions/ingest/simulate_spec.rb similarity index 85% rename from elasticsearch-api/spec/elasticsearch/api/actions/ingest/simulate_spec.rb rename to elasticsearch-api/spec/unit/actions/ingest/simulate_spec.rb index 6fddb32e1d..616f6e835a 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/ingest/simulate_spec.rb +++ b/elasticsearch-api/spec/unit/actions/ingest/simulate_spec.rb @@ -24,7 +24,8 @@ url, {}, {}, - {} + {}, + { endpoint: 'ingest.simulate' } ] end let(:method) { 'POST' } @@ -42,6 +43,17 @@ '_ingest/pipeline/foo/_simulate' end + let(:expected_args) do + [ + method, + url, + {}, + {}, + {}, + { defined_params: { id: 'foo' }, endpoint: 'ingest.simulate' } + ] + end + it 'performs the request' do expect(client_double.ingest.simulate(id: 'foo', body: {})).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/json_builders_spec.rb b/elasticsearch-api/spec/unit/actions/json_builders_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/json_builders_spec.rb rename to elasticsearch-api/spec/unit/actions/json_builders_spec.rb index 792ca0e270..899674590e 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/json_builders_spec.rb +++ b/elasticsearch-api/spec/unit/actions/json_builders_spec.rb @@ -25,7 +25,8 @@ '_search', {}, body, - {} + {}, + { endpoint: 'search' } ] end @@ -57,7 +58,8 @@ '_search', {}, body, - {} + {}, + { endpoint: 'search' } ] end diff --git a/elasticsearch-api/spec/unit/actions/license/delete_spec.rb b/elasticsearch-api/spec/unit/actions/license/delete_spec.rb new file mode 100644 index 0000000000..01d90496b4 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/license/delete_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#license.delete' do + let(:expected_args) do + [ + 'DELETE', + '_license', + { }, + nil, + {}, + { endpoint: 'license.delete' } + ] + end + + it 'performs the request' do + expect(client_double.license.delete).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/license/get_spec.rb b/elasticsearch-api/spec/unit/actions/license/get_spec.rb new file mode 100644 index 0000000000..00727f86d3 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/license/get_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#license.get' do + let(:expected_args) do + [ + 'GET', + '_license', + { }, + nil, + {}, + { endpoint: 'license.get' } + ] + end + + it 'performs the request' do + expect(client_double.license.get).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/license/post_spec.rb b/elasticsearch-api/spec/unit/actions/license/post_spec.rb new file mode 100644 index 0000000000..7805b8824b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/license/post_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#license.post' do + let(:expected_args) do + [ + 'PUT', + '_license', + { }, + nil, + {}, + { endpoint: 'license.post' } + ] + end + + it 'performs the request' do + expect(client_double.license.post).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/logstash/delete_pipeline_spec.rb b/elasticsearch-api/spec/unit/actions/logstash/delete_pipeline_spec.rb new file mode 100644 index 0000000000..00e18b7740 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/logstash/delete_pipeline_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#logstash.delete_pipeline' do + let(:expected_args) do + [ + 'DELETE', + '_logstash/pipeline/foo', + {}, + nil, + {}, + { endpoint: 'logstash.delete_pipeline', defined_params: { id: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.logstash.delete_pipeline(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/logstash/get_pipeline_spec.rb b/elasticsearch-api/spec/unit/actions/logstash/get_pipeline_spec.rb new file mode 100644 index 0000000000..85f7e7fdf7 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/logstash/get_pipeline_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#logstash.get_pipeline' do + let(:expected_args) do + [ + 'GET', + '_logstash/pipeline/foo', + {}, + nil, + {}, + { endpoint: 'logstash.get_pipeline', defined_params: { id: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.logstash.get_pipeline(id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/logstash/put_pipeline_spec.rb b/elasticsearch-api/spec/unit/actions/logstash/put_pipeline_spec.rb new file mode 100644 index 0000000000..5f6aaf50f9 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/logstash/put_pipeline_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#logstash.put_pipeline' do + let(:expected_args) do + [ + 'PUT', + '_logstash/pipeline/foo', + {}, + {}, + {}, + { endpoint: 'logstash.put_pipeline', defined_params: { id: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.logstash.put_pipeline(body: {}, id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/machine_learning/clear_trained_model_deployment_cache_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/clear_trained_model_deployment_cache_spec.rb new file mode 100644 index 0000000000..48031ad8a4 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/machine_learning/clear_trained_model_deployment_cache_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#ml.clear_trained_model_deployment_cache' do + let(:expected_args) do + [ + 'POST', + '_ml/trained_models/foo/deployment/cache/_clear', + {}, + nil, + {}, + { endpoint: 'ml.clear_trained_model_deployment_cache', defined_params: { model_id: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.ml.clear_trained_model_deployment_cache(model_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/machine_learning/get_memory_stats_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/get_memory_stats_spec.rb new file mode 100644 index 0000000000..fbf15c743e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/machine_learning/get_memory_stats_spec.rb @@ -0,0 +1,59 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#ml.get_memory_stats' do + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'ml.get_memory_stats' } + ] + end + + context 'without a node id' do + let(:url) { '_ml/memory/_stats' } + + it 'performs the request' do + expect(client_double.ml.get_memory_stats).to be_a Elasticsearch::API::Response + end + end + + context 'with a node id' do + let(:url) { '_ml/memory/foo/_stats' } + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { node_id: 'foo' }, endpoint: 'ml.get_memory_stats' } + ] + end + + it 'performs the request' do + expect(client_double.ml.get_memory_stats(node_id: 'foo')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb index 6fee4733a3..df21e3b626 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/get_model_snapshot_upgrade_stats_spec.rb @@ -24,7 +24,11 @@ '_ml/anomaly_detectors/foo/model_snapshots/bar/_upgrade/_stats', {}, nil, - {} + {}, + { defined_params: { + job_id: 'foo', + snapshot_id: 'bar' }, + endpoint: 'ml.get_model_snapshot_upgrade_stats' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/infer_trained_model_deployment_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/infer_trained_model_deployment_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/infer_trained_model_deployment_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/infer_trained_model_deployment_spec.rb index 78d386530d..77964040e4 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/infer_trained_model_deployment_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/infer_trained_model_deployment_spec.rb @@ -21,10 +21,11 @@ let(:expected_args) do [ 'POST', - '_ml/trained_models/foo/deployment/_infer', + '_ml/trained_models/foo/_infer', {}, {}, - {} + {}, + { defined_params: { model_id: 'foo' }, endpoint: 'ml.infer_trained_model' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/put_trained_model_definition_part_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/put_trained_model_definition_part_spec.rb index 6070109668..68c35b2e4f 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/put_trained_model_definition_part_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/put_trained_model_definition_part_spec.rb @@ -24,7 +24,9 @@ '_ml/trained_models/foo/definition/3', {}, {}, - {} + {}, + { defined_params: { model_id: 'foo', part: 3 }, + endpoint: 'ml.put_trained_model_definition_part' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/put_trained_model_vocabulary_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/put_trained_model_vocabulary_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/put_trained_model_vocabulary_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/put_trained_model_vocabulary_spec.rb index 7d8dd8e4fb..62846cc751 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/put_trained_model_vocabulary_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/put_trained_model_vocabulary_spec.rb @@ -24,7 +24,9 @@ '_ml/trained_models/foo/vocabulary', {}, {}, - {} + {}, + { defined_params: { model_id: 'foo' }, + endpoint: 'ml.put_trained_model_vocabulary' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/reset_job_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/reset_job_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/reset_job_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/reset_job_spec.rb index 61e4ea3412..9e498a7d3b 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/reset_job_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/reset_job_spec.rb @@ -24,7 +24,8 @@ '_ml/anomaly_detectors/foo/_reset', {}, nil, - {} + {}, + { defined_params: { job_id: 'foo' }, endpoint: 'ml.reset_job' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/set_upgrade_mode_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/set_upgrade_mode_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/set_upgrade_mode_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/set_upgrade_mode_spec.rb index 26193929aa..376b37dad0 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/set_upgrade_mode_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/set_upgrade_mode_spec.rb @@ -24,7 +24,8 @@ '_ml/set_upgrade_mode', {}, nil, - {} + {}, + { endpoint: 'ml.set_upgrade_mode' } ] end @@ -40,7 +41,8 @@ '_ml/set_upgrade_mode', { enabled: true, timeout: '10m' }, nil, - {} + {}, + { endpoint: 'ml.set_upgrade_mode' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/start_trained_model_deployment_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/start_trained_model_deployment_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/start_trained_model_deployment_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/start_trained_model_deployment_spec.rb index 39bca8779c..7e30fe7773 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/start_trained_model_deployment_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/start_trained_model_deployment_spec.rb @@ -24,7 +24,9 @@ '_ml/trained_models/foo/deployment/_start', {}, nil, - {} + {}, + { defined_params: { model_id: 'foo' }, + endpoint: 'ml.start_trained_model_deployment' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/stop_trained_model_deployment_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/stop_trained_model_deployment_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/stop_trained_model_deployment_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/stop_trained_model_deployment_spec.rb index f40f502c22..eb42c9a37d 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/stop_trained_model_deployment_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/stop_trained_model_deployment_spec.rb @@ -24,7 +24,9 @@ '_ml/trained_models/foo/deployment/_stop', {}, nil, - {} + {}, + { defined_params: { model_id: 'foo' }, + endpoint: 'ml.stop_trained_model_deployment' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/update_trained_model_deployment_spec.rb b/elasticsearch-api/spec/unit/actions/machine_learning/update_trained_model_deployment_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/update_trained_model_deployment_spec.rb rename to elasticsearch-api/spec/unit/actions/machine_learning/update_trained_model_deployment_spec.rb index 7626c17bae..a3a2f26ca7 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/machine_learning/update_trained_model_deployment_spec.rb +++ b/elasticsearch-api/spec/unit/actions/machine_learning/update_trained_model_deployment_spec.rb @@ -24,7 +24,9 @@ '_ml/trained_models/foo/deployment/_update', {}, {}, - {} + {}, + { defined_params: { model_id: 'foo' }, + endpoint: 'ml.update_trained_model_deployment' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/mget_spec.rb b/elasticsearch-api/spec/unit/actions/mget_spec.rb similarity index 82% rename from elasticsearch-api/spec/elasticsearch/api/actions/mget_spec.rb rename to elasticsearch-api/spec/unit/actions/mget_spec.rb index 550d6136fd..893231f112 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/mget_spec.rb +++ b/elasticsearch-api/spec/unit/actions/mget_spec.rb @@ -24,7 +24,8 @@ url, params, body, - {} + {}, + { endpoint: 'mget' } ] end @@ -50,6 +51,17 @@ 'foo/_mget' end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: 'mget' } + ] + end + it 'performs the request' do expect(client_double.mget(index: 'foo', body: { :docs => [] })).to be_a Elasticsearch::API::Response end @@ -80,6 +92,17 @@ { ids: [ '1', '2' ]} end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { index: 'foo^bar' }, endpoint: 'mget' } + ] + end + it 'performs the request' do expect(client_double.mget(index: 'foo^bar', body: { :ids => [ '1', '2'] })).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/migration/deprecation_spec.rb b/elasticsearch-api/spec/unit/actions/migration/deprecation_spec.rb new file mode 100644 index 0000000000..e636f904c2 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/migration/deprecation_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#migration.deprecations' do + let(:expected_args) do + [ + 'GET', + '_migration/deprecations', + {}, + nil, + {}, + { endpoint: 'migration.deprecations' } + ] + end + + it 'performs the request' do + expect(client_double.migration.deprecations).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/migration/get_feature_upgrade_status_spec.rb b/elasticsearch-api/spec/unit/actions/migration/get_feature_upgrade_status_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/migration/get_feature_upgrade_status_spec.rb rename to elasticsearch-api/spec/unit/actions/migration/get_feature_upgrade_status_spec.rb index 4ef5135c15..81c8375ed2 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/migration/get_feature_upgrade_status_spec.rb +++ b/elasticsearch-api/spec/unit/actions/migration/get_feature_upgrade_status_spec.rb @@ -24,7 +24,8 @@ '_migration/system_features', {}, nil, - {} + {}, + { endpoint: 'migration.get_feature_upgrade_status' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/migration/post_feature_upgrade_spec.rb b/elasticsearch-api/spec/unit/actions/migration/post_feature_upgrade_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/migration/post_feature_upgrade_spec.rb rename to elasticsearch-api/spec/unit/actions/migration/post_feature_upgrade_spec.rb index 5ac4015250..0b84b8ad43 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/migration/post_feature_upgrade_spec.rb +++ b/elasticsearch-api/spec/unit/actions/migration/post_feature_upgrade_spec.rb @@ -24,7 +24,8 @@ '_migration/system_features', {}, nil, - {} + {}, + { endpoint: 'migration.post_feature_upgrade' } ] end diff --git a/elasticsearch-api/spec/unit/actions/msearch_spec.rb b/elasticsearch-api/spec/unit/actions/msearch_spec.rb new file mode 100644 index 0000000000..a7b576e02c --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/msearch_spec.rb @@ -0,0 +1,187 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#msearch' do + let(:expected_args) do + [ + 'POST', + url, + params, + body, + headers, + { endpoint: 'msearch' } + ] + end + + let(:body) do + nil + end + + let(:url) do + '_msearch' + end + + let(:params) do + {} + end + + let(:headers) { + { + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + } + } + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :body argument' do + expect { + client.msearch + }.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 + %Q|{"foo":"bar"}\n{"moo":"lam"}| + end + + it 'performs the request' do + expect(client_double.msearch(body: %Q|{"foo":"bar"}\n{"moo":"lam"}|)).to be_a Elasticsearch::API::Response + end + end + + context 'when an index is specified' do + let(:url) do + 'foo/_msearch' + end + + let(:body) do + '' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + headers, + { defined_params: { index: 'foo' }, endpoint: 'msearch' } + ] + 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 + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + headers, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'msearch' } + ] + end + + it 'performs the request' do + expect(client_double.msearch(index: ['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 + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + headers, + { defined_params: { index: 'foo^bar' }, endpoint: 'msearch' } + ] + end + + it 'performs the request' do + expect(client_double.msearch(index: 'foo^bar', body: [])).to be_a Elasticsearch::API::Response + 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 be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/msearch_template_spec.rb b/elasticsearch-api/spec/unit/actions/msearch_template_spec.rb similarity index 85% rename from elasticsearch-api/spec/elasticsearch/api/actions/msearch_template_spec.rb rename to elasticsearch-api/spec/unit/actions/msearch_template_spec.rb index c08b988c5a..8b30d7d189 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/msearch_template_spec.rb +++ b/elasticsearch-api/spec/unit/actions/msearch_template_spec.rb @@ -24,7 +24,8 @@ url, params, body, - headers + headers, + { endpoint: 'msearch_template' } ] end @@ -36,16 +37,17 @@ {} end - let(:headers) do - { 'Content-Type' => 'application/x-ndjson' } - end + let(:headers) { + { + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + } + } let(:url) do '_msearch/template' end context 'when a body is provided as a document' do - let(:body) do <<-PAYLOAD.gsub(/^\s+/, '') {"index":"foo"} @@ -66,7 +68,6 @@ end context 'when a body is provided as a string' do - let(:body) do %Q|{"foo":"bar"}\n{"moo":"lam"}| end @@ -77,7 +78,6 @@ end context 'when an index is provided' do - let(:url) do 'foo/_msearch/template' end @@ -86,6 +86,17 @@ '' end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + headers, + { defined_params: { index: 'foo' }, endpoint: 'msearch_template' } + ] + end + it 'performs the request' do expect(client_double.msearch_template(index: 'foo', body: [])) end diff --git a/elasticsearch-api/spec/unit/actions/mtermvectors_spec.rb b/elasticsearch-api/spec/unit/actions/mtermvectors_spec.rb new file mode 100644 index 0000000000..cc4265f391 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/mtermvectors_spec.rb @@ -0,0 +1,54 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#mtermvectors' do + context 'in body' do + let(:expected_args) do + [ + 'POST', + 'my-index/_mtermvectors', + {}, + { ids: [1, 2, 3] }, + {}, + { defined_params: { index: 'my-index' }, endpoint: 'mtermvectors' } + ] + end + + it 'performs the request' do + expect(client_double.mtermvectors(index: 'my-index', body: { ids: [1, 2, 3] })).to be_a Elasticsearch::API::Response + end + end + + context 'when a list of ids is passed instead of a body' do + let(:expected_args) do + [ + 'GET', + 'my-index/_mtermvectors', + { ids: '1,2,3' }, + nil, + {}, + { defined_params: { index: 'my-index' }, endpoint: 'mtermvectors' } + ] + end + + it 'performs the request' do + expect(client_double.mtermvectors(index: 'my-index', ids: [1, 2, 3])).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/clear_repositories_metering_archive_spec.rb b/elasticsearch-api/spec/unit/actions/nodes/clear_repositories_metering_archive_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/nodes/clear_repositories_metering_archive_spec.rb rename to elasticsearch-api/spec/unit/actions/nodes/clear_repositories_metering_archive_spec.rb index 0d45d075bb..f42397d7f5 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/clear_repositories_metering_archive_spec.rb +++ b/elasticsearch-api/spec/unit/actions/nodes/clear_repositories_metering_archive_spec.rb @@ -25,7 +25,9 @@ '_nodes/foo/_repositories_metering/bar', {}, nil, - {} + {}, + { defined_params: { max_archive_version: 'bar', node_id: 'foo' }, + endpoint: 'nodes.clear_repositories_metering_archive' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/get_repositories_metering_info_spec.rb b/elasticsearch-api/spec/unit/actions/nodes/get_repositories_metering_info_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/nodes/get_repositories_metering_info_spec.rb rename to elasticsearch-api/spec/unit/actions/nodes/get_repositories_metering_info_spec.rb index b5d78f08e0..56bfdbe3c9 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/get_repositories_metering_info_spec.rb +++ b/elasticsearch-api/spec/unit/actions/nodes/get_repositories_metering_info_spec.rb @@ -24,7 +24,9 @@ '_nodes/foo/_repositories_metering', {}, nil, - {} + {}, + { defined_params: {node_id: 'foo' }, + endpoint: 'nodes.get_repositories_metering_info' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb b/elasticsearch-api/spec/unit/actions/nodes/hot_threads_spec.rb similarity index 78% rename from elasticsearch-api/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb rename to elasticsearch-api/spec/unit/actions/nodes/hot_threads_spec.rb index 811b37136c..af5124bdcc 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +++ b/elasticsearch-api/spec/unit/actions/nodes/hot_threads_spec.rb @@ -25,7 +25,8 @@ url, {}, nil, - {} + {}, + { endpoint: 'nodes.hot_threads' } ] end @@ -43,6 +44,17 @@ '_nodes/foo/hot_threads' end + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { node_id: 'foo' }, endpoint: 'nodes.hot_threads' } + ] + end + it 'performs the request' do expect(client_double.nodes.hot_threads(node_id: 'foo')).to be_a Elasticsearch::API::Response end @@ -54,6 +66,17 @@ '_nodes/foo%5Ebar/hot_threads' end + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { node_id: 'foo^bar' }, endpoint: 'nodes.hot_threads' } + ] + end + it 'performs the request' do expect(client_double.nodes.hot_threads(node_id: 'foo^bar')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/nodes/info_spec.rb b/elasticsearch-api/spec/unit/actions/nodes/info_spec.rb new file mode 100644 index 0000000000..8f69b9f5ca --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/nodes/info_spec.rb @@ -0,0 +1,141 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.nodes#info' do + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { endpoint: 'nodes.info' } + ] + end + + let(:url) do + '_nodes' + end + + it 'performs the request' do + expect(client_double.nodes.info).to be_a Elasticsearch::API::Response + end + + let(:params) do + {} + end + + context 'when the node id is specified' do + let(:url) do + '_nodes/foo' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { node_id: 'foo' }, endpoint: 'nodes.info' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.info(node_id: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple node ids are specified as a list' do + let(:url) do + '_nodes/A,B,C' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { node_id: ['A', 'B', 'C'] }, endpoint: 'nodes.info' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.info(node_id: ['A', 'B', 'C'])).to be_a Elasticsearch::API::Response + end + end + + context 'when multiple node ids are specified as a String' do + let(:url) do + '_nodes/A,B,C' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { node_id: 'A,B,C' }, endpoint: 'nodes.info' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.info(node_id: 'A,B,C')).to be_a Elasticsearch::API::Response + 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 be_a Elasticsearch::API::Response + end + end + + context 'when metrics are specified' do + let(:url) do + '_nodes/http,network' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { metric: ['http', 'network'] }, endpoint: 'nodes.info' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.info(metric: ['http', 'network'])).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/reload_secure_settings_spec.rb b/elasticsearch-api/spec/unit/actions/nodes/reload_secure_settings_spec.rb similarity index 77% rename from elasticsearch-api/spec/elasticsearch/api/actions/nodes/reload_secure_settings_spec.rb rename to elasticsearch-api/spec/unit/actions/nodes/reload_secure_settings_spec.rb index 31b5bf4449..8eef6c461b 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/nodes/reload_secure_settings_spec.rb +++ b/elasticsearch-api/spec/unit/actions/nodes/reload_secure_settings_spec.rb @@ -25,7 +25,8 @@ url, params, body, - {} + {}, + { endpoint: 'nodes.reload_secure_settings' } ] end @@ -43,6 +44,17 @@ '_nodes/foo/reload_secure_settings' end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { node_id: 'foo' }, endpoint: 'nodes.reload_secure_settings' } + ] + end + it 'performs the request' do expect(client_double.nodes.reload_secure_settings(node_id: 'foo')).to be_a Elasticsearch::API::Response end @@ -55,6 +67,17 @@ '_nodes/foo,bar/reload_secure_settings' end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { node_id: 'foo,bar' }, endpoint: 'nodes.reload_secure_settings' } + ] + end + it 'performs the request' do expect(client_double.nodes.reload_secure_settings(node_id: 'foo,bar', body: { foo: 'bar' })).to be_a Elasticsearch::API::Response end @@ -66,6 +89,17 @@ '_nodes/foo,bar/reload_secure_settings' end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { node_id: ['foo', 'bar'] }, endpoint: 'nodes.reload_secure_settings' } + ] + end + it 'performs the request' do expect(client_double.nodes.reload_secure_settings(node_id: ['foo', 'bar'], body: { foo: 'bar' })).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/nodes/stats_spec.rb b/elasticsearch-api/spec/unit/actions/nodes/stats_spec.rb new file mode 100644 index 0000000000..3cd5053ddd --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/nodes/stats_spec.rb @@ -0,0 +1,110 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.nodes#stats' do + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { endpoint: 'nodes.stats' } + ] + end + + let(:url) do + '_nodes/stats' + end + + it 'performs the request' do + expect(client_double.nodes.stats).to be_a Elasticsearch::API::Response + end + + let(:params) do + {} + end + + context 'when the node id is specified' do + + let(:url) do + '_nodes/foo/stats' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { node_id: 'foo' }, endpoint: 'nodes.stats' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.stats(node_id: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when metrics are specified' do + + let(:url) do + '_nodes/stats/http,fs' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { metric: [:http, :fs] }, endpoint: 'nodes.stats' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.stats(metric: [:http, :fs])).to be_a Elasticsearch::API::Response + end + end + + context 'when index metric is specified' do + + let(:url) do + '_nodes/stats/indices/filter_cache' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { metric: :indices, index_metric: :filter_cache }, endpoint: 'nodes.stats' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.stats(metric: :indices, index_metric: :filter_cache)).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/nodes/usage_spec.rb b/elasticsearch-api/spec/unit/actions/nodes/usage_spec.rb new file mode 100644 index 0000000000..25824cd7c5 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/nodes/usage_spec.rb @@ -0,0 +1,106 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.nodes#usage' do + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { endpoint: 'nodes.usage' } + ] + end + + let(:url) do + '_nodes/usage' + end + + it 'performs the request' do + expect(client_double.nodes.usage).to be_a Elasticsearch::API::Response + end + + let(:params) do + {} + end + + context 'when the node id is specified' do + let(:url) do + '_nodes/foo/usage' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { node_id: 'foo' }, endpoint: 'nodes.usage' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.usage(node_id: 'foo')).to be_a Elasticsearch::API::Response + end + end + + context 'when the metric is specified' do + let(:url) do + '_nodes/usage/metric' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { metric: 'metric' }, endpoint: 'nodes.usage' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.usage(metric: 'metric')).to be_a Elasticsearch::API::Response + end + end + + context 'when both are specified' do + let(:url) do + '_nodes/foo/usage/metric' + end + + let(:expected_args) do + [ + 'GET', + url, + params, + nil, + {}, + { defined_params: { node_id: 'foo', metric: 'metric' }, endpoint: 'nodes.usage' } + ] + end + + it 'performs the request' do + expect(client_double.nodes.usage(metric: 'metric', node_id: 'foo')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/open_point_in_time_spec.rb b/elasticsearch-api/spec/unit/actions/open_point_in_time_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/open_point_in_time_spec.rb rename to elasticsearch-api/spec/unit/actions/open_point_in_time_spec.rb index 4a80f3a191..3636a9c490 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/open_point_in_time_spec.rb +++ b/elasticsearch-api/spec/unit/actions/open_point_in_time_spec.rb @@ -24,7 +24,8 @@ 'foo/_pit', {}, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'open_point_in_time' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/ping_spec.rb b/elasticsearch-api/spec/unit/actions/ping_spec.rb similarity index 97% rename from elasticsearch-api/spec/elasticsearch/api/actions/ping_spec.rb rename to elasticsearch-api/spec/unit/actions/ping_spec.rb index f347105dd3..28b2a917d3 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/ping_spec.rb +++ b/elasticsearch-api/spec/unit/actions/ping_spec.rb @@ -25,7 +25,8 @@ '', {}, nil, - {} + {}, + { endpoint: 'ping' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/put_script_spec.rb b/elasticsearch-api/spec/unit/actions/put_script_spec.rb similarity index 90% rename from elasticsearch-api/spec/elasticsearch/api/actions/put_script_spec.rb rename to elasticsearch-api/spec/unit/actions/put_script_spec.rb index cba29c0d86..b6d1ad6c99 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/put_script_spec.rb +++ b/elasticsearch-api/spec/unit/actions/put_script_spec.rb @@ -29,7 +29,8 @@ url, {}, { script: 'bar', lang: 'groovy' }, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'put_script' } ] end @@ -45,7 +46,8 @@ url, {}, { script: 'bar' }, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'put_script' } ] end diff --git a/elasticsearch-api/spec/unit/actions/query_rules/delete_ruleset_spec.rb b/elasticsearch-api/spec/unit/actions/query_rules/delete_ruleset_spec.rb new file mode 100644 index 0000000000..5453aa006e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/query_rules/delete_ruleset_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.query_rules#delete_ruleset' do + + let(:expected_args) do + [ + 'DELETE', + '_query_rules/foo', + {}, + nil, + {}, + { defined_params: { ruleset_id: 'foo' }, endpoint: 'query_rules.delete_ruleset' } + ] + end + + it 'performs the request' do + expect(client_double.query_rules.delete_ruleset(ruleset_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/query_rules/delete_spec.rb b/elasticsearch-api/spec/unit/actions/query_rules/delete_spec.rb new file mode 100644 index 0000000000..f456942c0b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/query_rules/delete_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.query_rules#delete_rule' do + let(:expected_args) do + [ + 'DELETE', + '_query_rules/foo/_rule/bar', + {}, + nil, + {}, + { defined_params: { rule_id: 'bar', ruleset_id: 'foo' }, endpoint: 'query_rules.delete_rule' } + ] + end + + it 'performs the request' do + expect(client_double.query_rules.delete_rule(ruleset_id: 'foo', rule_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/query_rules/get_ruleset_spec.rb b/elasticsearch-api/spec/unit/actions/query_rules/get_ruleset_spec.rb new file mode 100644 index 0000000000..df8cfc9a8d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/query_rules/get_ruleset_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.query_rules#get_ruleset' do + let(:expected_args) do + [ + 'GET', + '_query_rules/foo', + {}, + nil, + {}, + { defined_params: { ruleset_id: 'foo' }, endpoint: 'query_rules.get_ruleset' } + ] + end + + it 'performs the request' do + expect(client_double.query_rules.get_ruleset(ruleset_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/query_rules/get_spec.rb b/elasticsearch-api/spec/unit/actions/query_rules/get_spec.rb new file mode 100644 index 0000000000..27c0a01410 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/query_rules/get_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.query_rules#get_rule' do + let(:expected_args) do + [ + 'GET', + '_query_rules/foo/_rule/bar', + {}, + nil, + {}, + { defined_params: { rule_id: 'bar', ruleset_id: 'foo' }, endpoint: 'query_rules.get_rule' } + ] + end + + it 'performs the request' do + expect(client_double.query_rules.get_rule(ruleset_id: 'foo', rule_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/query_rules/put_ruleset_spec.rb b/elasticsearch-api/spec/unit/actions/query_rules/put_ruleset_spec.rb new file mode 100644 index 0000000000..5252801f73 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/query_rules/put_ruleset_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.query_rules#put_ruleset' do + let(:expected_args) do + [ + 'PUT', + '_query_rules/foo', + {}, + {}, + {}, + { defined_params: { ruleset_id: 'foo' }, endpoint: 'query_rules.put_ruleset' } + ] + end + + it 'performs the request' do + expect(client_double.query_rules.put_ruleset(body: {}, ruleset_id: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/query_rules/put_spec.rb b/elasticsearch-api/spec/unit/actions/query_rules/put_spec.rb new file mode 100644 index 0000000000..1b040b8f89 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/query_rules/put_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.query_rule#put_rule' do + let(:expected_args) do + [ + 'PUT', + '_query_rules/foo/_rule/bar', + {}, + {}, + {}, + { defined_params: { rule_id: 'bar', ruleset_id: 'foo' }, endpoint: 'query_rules.put_rule' } + ] + end + + it 'performs the request' do + expect(client_double.query_rules.put_rule(body: {}, ruleset_id: 'foo', rule_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/query_rules/test_spec.rb b/elasticsearch-api/spec/unit/actions/query_rules/test_spec.rb new file mode 100644 index 0000000000..294013680f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/query_rules/test_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.query_rules#test' do + let(:expected_args) do + [ + 'POST', + '_query_rules/foo/_test', + {}, + {}, + {}, + { defined_params: { ruleset_id: 'foo' }, endpoint: 'query_rules.test' } + ] + end + + it 'performs the request' do + expect(client_double.query_rules.test(ruleset_id: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/rank_eval_spec.rb b/elasticsearch-api/spec/unit/actions/rank_eval_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/rank_eval_spec.rb rename to elasticsearch-api/spec/unit/actions/rank_eval_spec.rb index ba14ff428a..5446908f6d 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/rank_eval_spec.rb +++ b/elasticsearch-api/spec/unit/actions/rank_eval_spec.rb @@ -25,7 +25,8 @@ url, params, body, - {} + {}, + { defined_params: { index: 'my_index' }, endpoint: 'rank_eval' } ] end @@ -75,6 +76,17 @@ } end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { endpoint: 'rank_eval' } + ] + end + it 'performs the request' do expect(client_double.rank_eval(body: {}, ignore_unavailable: true, diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/reindex_spec.rb b/elasticsearch-api/spec/unit/actions/reindex_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/reindex_spec.rb rename to elasticsearch-api/spec/unit/actions/reindex_spec.rb index 66b1e6ca70..49c5431c61 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/reindex_spec.rb +++ b/elasticsearch-api/spec/unit/actions/reindex_spec.rb @@ -25,7 +25,8 @@ '_reindex', {}, {}, - {} + {}, + { endpoint: 'reindex' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/render_search_template_spec.rb b/elasticsearch-api/spec/unit/actions/render_search_template_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/render_search_template_spec.rb rename to elasticsearch-api/spec/unit/actions/render_search_template_spec.rb index 087c761c3f..7c9fe2ef0f 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/render_search_template_spec.rb +++ b/elasticsearch-api/spec/unit/actions/render_search_template_spec.rb @@ -25,7 +25,8 @@ '_render/template', {}, { foo: 'bar' }, - {} + {}, + { endpoint: 'render_search_template' } ] end @@ -41,7 +42,8 @@ '_render/template/foo', {}, { foo: 'bar' }, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'render_search_template' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/scroll_spec.rb b/elasticsearch-api/spec/unit/actions/scroll_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/scroll_spec.rb rename to elasticsearch-api/spec/unit/actions/scroll_spec.rb index e649b5fa98..d7b2b3aee4 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/scroll_spec.rb +++ b/elasticsearch-api/spec/unit/actions/scroll_spec.rb @@ -22,10 +22,11 @@ let(:expected_args) do [ 'GET', - '_search/scroll/cXVlcn...', + '_search/scroll', {}, nil, - {} + {}, + { endpoint: 'scroll' } ] end @@ -41,7 +42,8 @@ '_search/scroll', {}, { scroll_id: 'cXVlcn...' }, - {} + {}, + { endpoint: 'scroll' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/delete_behavioral_analytics_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/delete_behavioral_analytics_spec.rb similarity index 90% rename from elasticsearch-api/spec/elasticsearch/api/actions/search_application/delete_behavioral_analytics_spec.rb rename to elasticsearch-api/spec/unit/actions/search_application/delete_behavioral_analytics_spec.rb index d959402c1e..2d16db3844 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/delete_behavioral_analytics_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_application/delete_behavioral_analytics_spec.rb @@ -24,7 +24,9 @@ '_application/analytics/foo', {}, nil, - {} + {}, + { defined_params: { name: 'foo' }, + endpoint: 'search_application.delete_behavioral_analytics' } ] end diff --git a/elasticsearch-api/spec/unit/actions/search_application/delete_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/delete_spec.rb new file mode 100644 index 0000000000..ebb7653aa5 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/search_application/delete_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.search_application#delete' do + let(:expected_args) do + [ + 'DELETE', + '_application/search_application/foo', + {}, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'search_application.delete' } + ] + end + + it 'performs the request' do + expect(client_double.search_application.delete(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/get_behavioral_analytics_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/get_behavioral_analytics_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/search_application/get_behavioral_analytics_spec.rb rename to elasticsearch-api/spec/unit/actions/search_application/get_behavioral_analytics_spec.rb index 57bfa3a64e..62a47ec1a7 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/get_behavioral_analytics_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_application/get_behavioral_analytics_spec.rb @@ -24,7 +24,8 @@ '_application/analytics', {}, nil, - {} + {}, + { endpoint: 'search_application.get_behavioral_analytics' } ] end diff --git a/elasticsearch-api/spec/unit/actions/search_application/get_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/get_spec.rb new file mode 100644 index 0000000000..85989091f5 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/search_application/get_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.search_application#get' do + let(:expected_args) do + [ + 'GET', + '_application/search_application/foo', + {}, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'search_application.get' } + ] + end + + it 'performs the request' do + expect(client_double.search_application.get(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/search_application/list_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/list_spec.rb new file mode 100644 index 0000000000..b7acd856aa --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/search_application/list_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.search_application#list' do + let(:expected_args) do + [ + 'GET', + '_application/search_application', + {}, + nil, + {}, + { endpoint: 'search_application.list' } + ] + end + + it 'performs the request' do + expect(client_double.search_application.list).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/post_behavioral_analytics_event_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/post_behavioral_analytics_event_spec.rb similarity index 88% rename from elasticsearch-api/spec/elasticsearch/api/actions/search_application/post_behavioral_analytics_event_spec.rb rename to elasticsearch-api/spec/unit/actions/search_application/post_behavioral_analytics_event_spec.rb index a037c22674..335c6d3707 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/post_behavioral_analytics_event_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_application/post_behavioral_analytics_event_spec.rb @@ -24,7 +24,9 @@ '_application/analytics/foo/event/search', {}, {}, - {} + {}, + { defined_params: { collection_name: 'foo', event_type: 'search' }, + endpoint: 'search_application.post_behavioral_analytics_event' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/put_behavioral_analytics_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/put_behavioral_analytics_spec.rb similarity index 90% rename from elasticsearch-api/spec/elasticsearch/api/actions/search_application/put_behavioral_analytics_spec.rb rename to elasticsearch-api/spec/unit/actions/search_application/put_behavioral_analytics_spec.rb index a3d712c241..013bff584f 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/put_behavioral_analytics_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_application/put_behavioral_analytics_spec.rb @@ -24,7 +24,9 @@ '_application/analytics/foo', {}, nil, - {} + {}, + { defined_params: { name: 'foo' }, + endpoint: 'search_application.put_behavioral_analytics' } ] end diff --git a/elasticsearch-api/spec/unit/actions/search_application/put_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/put_spec.rb new file mode 100644 index 0000000000..3b2037f11f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/search_application/put_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.search_application#put' do + let(:expected_args) do + [ + 'PUT', + '_application/search_application/foo', + {}, + {}, + {}, + { defined_params: { name: 'foo' }, endpoint: 'search_application.put' } + ] + end + + it 'performs the request' do + expect(client_double.search_application.put(name: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/render_query_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/render_query_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/search_application/render_query_spec.rb rename to elasticsearch-api/spec/unit/actions/search_application/render_query_spec.rb index e1dcb69b23..1fb4baad7b 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_application/render_query_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_application/render_query_spec.rb @@ -24,7 +24,9 @@ '_application/search_application/foo/_render_query', {}, nil, - {} + {}, + { defined_params: { name: 'foo' }, + endpoint: 'search_application.render_query' } ] end diff --git a/elasticsearch-api/spec/unit/actions/search_application/search_spec.rb b/elasticsearch-api/spec/unit/actions/search_application/search_spec.rb new file mode 100644 index 0000000000..6763d78e63 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/search_application/search_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.search_application#delete_behavioral_analytics' do + let(:expected_args) do + [ + 'GET', + '_application/search_application/foo/_search', + {}, + nil, + {}, + { defined_params: { name: 'foo' }, endpoint: 'search_application.search' } + ] + end + + it 'performs the request' do + expect(client_double.search_application.search(name: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_mvt_spec.rb b/elasticsearch-api/spec/unit/actions/search_mvt_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/search_mvt_spec.rb rename to elasticsearch-api/spec/unit/actions/search_mvt_spec.rb index ed4455d020..e0c1d93574 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_mvt_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_mvt_spec.rb @@ -24,7 +24,9 @@ url, params, body, - {} + {}, + { defined_params: { field: 'field', index: 'foo', x: 57.2127, y: 6.2348, zoom: 10 }, + endpoint: 'search_mvt' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_shards_spec.rb b/elasticsearch-api/spec/unit/actions/search_shards_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/search_shards_spec.rb rename to elasticsearch-api/spec/unit/actions/search_shards_spec.rb index ca43518ba2..1caaf037d2 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_shards_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_shards_spec.rb @@ -25,7 +25,8 @@ '_search_shards', {}, nil, - {} + {}, + { endpoint: 'search_shards' } ] end diff --git a/elasticsearch-api/spec/unit/actions/search_spec.rb b/elasticsearch-api/spec/unit/actions/search_spec.rb new file mode 100644 index 0000000000..02e10edabe --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/search_spec.rb @@ -0,0 +1,119 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#search' do + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { endpoint: 'search' } + ] + 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 + + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { index: 'foo' }, endpoint: '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 + + let(:expected_args) do + [ + method, + url, + params, + body, + {}, + { defined_params: { index: ['foo', 'bar'] }, endpoint: 'search' } + ] + end + + it 'performs the request' do + expect(client_double.search(index: ['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 +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/search_template_spec.rb b/elasticsearch-api/spec/unit/actions/search_template_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/search_template_spec.rb rename to elasticsearch-api/spec/unit/actions/search_template_spec.rb index cb061c5569..60d235aba1 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/search_template_spec.rb +++ b/elasticsearch-api/spec/unit/actions/search_template_spec.rb @@ -24,7 +24,8 @@ 'foo/_search/template', { }, { foo: 'bar' }, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'search_template' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/cache_stats_spec.rb b/elasticsearch-api/spec/unit/actions/searchable_snapshots/cache_stats_spec.rb similarity index 83% rename from elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/cache_stats_spec.rb rename to elasticsearch-api/spec/unit/actions/searchable_snapshots/cache_stats_spec.rb index bd5ab27f8e..19d3c17245 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/cache_stats_spec.rb +++ b/elasticsearch-api/spec/unit/actions/searchable_snapshots/cache_stats_spec.rb @@ -24,7 +24,8 @@ url, {}, nil, - {} + {}, + { endpoint: 'searchable_snapshots.cache_stats' } ] end @@ -37,6 +38,17 @@ context 'when using index' do let(:url){ '_searchable_snapshots/foo/cache/stats' } + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { node_id: 'foo' }, endpoint: 'searchable_snapshots.cache_stats' } + ] + end + it 'performs the request' do expect(client_double.searchable_snapshots.cache_stats(node_id: 'foo')).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/searchable_snapshots/clear_cache_spec.rb b/elasticsearch-api/spec/unit/actions/searchable_snapshots/clear_cache_spec.rb new file mode 100644 index 0000000000..e156ba16ca --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/searchable_snapshots/clear_cache_spec.rb @@ -0,0 +1,57 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#searchable_snapshots.clear_cache' do + let(:expected_args) do + [ + 'POST', + url, + {}, + nil, + {}, + { endpoint: 'searchable_snapshots.clear_cache' } + ] + end + + let(:url){ '_searchable_snapshots/cache/clear' } + + it 'performs the request' do + expect(client_double.searchable_snapshots.clear_cache).to be_a Elasticsearch::API::Response + end + + context 'when using index' do + let(:url){ 'foo/_searchable_snapshots/cache/clear' } + + let(:expected_args) do + [ + 'POST', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo' }, + endpoint: 'searchable_snapshots.clear_cache' } + ] + end + + it 'performs the request' do + expect(client_double.searchable_snapshots.clear_cache(index: 'foo')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/mount_spec.rb b/elasticsearch-api/spec/unit/actions/searchable_snapshots/mount_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/mount_spec.rb rename to elasticsearch-api/spec/unit/actions/searchable_snapshots/mount_spec.rb index d18a955f06..f34d2d4075 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/searchable_snapshots/mount_spec.rb +++ b/elasticsearch-api/spec/unit/actions/searchable_snapshots/mount_spec.rb @@ -24,7 +24,9 @@ '_snapshot/foo/bar/_mount', {}, {}, - {} + {}, + { defined_params: { repository: 'foo', snapshot: 'bar' }, + endpoint: 'searchable_snapshots.mount' } ] end diff --git a/elasticsearch-api/spec/unit/actions/searchable_snapshots/stats_spec.rb b/elasticsearch-api/spec/unit/actions/searchable_snapshots/stats_spec.rb new file mode 100644 index 0000000000..50da731855 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/searchable_snapshots/stats_spec.rb @@ -0,0 +1,57 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#searchable_snapshots.stats' do + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'searchable_snapshots.stats' } + ] + end + + + let(:url) { '_searchable_snapshots/stats' } + + it 'performs the request' do + expect(client_double.searchable_snapshots.stats).to be_a Elasticsearch::API::Response + end + + context 'using index' do + let(:url) { 'foo/_searchable_snapshots/stats' } + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { index: 'foo' }, endpoint: 'searchable_snapshots.stats' } + ] + end + + it 'performs the request' do + expect(client_double.searchable_snapshots.stats(index: 'foo')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/activate_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/activate_user_profile_spec.rb new file mode 100644 index 0000000000..030bbeef79 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/activate_user_profile_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security#activate_user_profile' do + let(:expected_args) do + [ + 'POST', + '_security/profile/_activate', + {}, + {}, + {}, + { endpoint: 'security.activate_user_profile' } + ] + end + + it 'performs the request' do + expect(client_double.security.activate_user_profile(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/bulk_delete_role_spec.rb b/elasticsearch-api/spec/unit/actions/security/bulk_delete_role_spec.rb new file mode 100644 index 0000000000..c48ead67d1 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/bulk_delete_role_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security.bulk_delete_role' do + let(:expected_args) do + [ + 'DELETE', + '_security/role', + {}, + {}, + {}, + { endpoint: 'security.bulk_delete_role' } + ] + end + + it 'performs the request' do + expect(client_double.security.bulk_delete_role(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/bulk_put_role_spec.rb b/elasticsearch-api/spec/unit/actions/security/bulk_put_role_spec.rb new file mode 100644 index 0000000000..66b16ed6de --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/bulk_put_role_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security.bulk_put_role' do + let(:expected_args) do + [ + 'POST', + '_security/role', + {}, + {}, + {}, + { endpoint: 'security.bulk_put_role' } + ] + end + + it 'performs the request' do + expect(client_double.security.bulk_put_role(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/clear_cached_service_tokens_spec.rb b/elasticsearch-api/spec/unit/actions/security/clear_cached_service_tokens_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/clear_cached_service_tokens_spec.rb rename to elasticsearch-api/spec/unit/actions/security/clear_cached_service_tokens_spec.rb index 879b09b3e7..d0a2d85cad 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/clear_cached_service_tokens_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/clear_cached_service_tokens_spec.rb @@ -24,7 +24,9 @@ '_security/service/foo/bar/credential/token/service_token/_clear_cache', {}, nil, - {} + {}, + { defined_params: { name: 'service_token', namespace: 'foo', service: 'bar' }, + endpoint: 'security.clear_cached_service_tokens' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/create_api_key_spec.rb b/elasticsearch-api/spec/unit/actions/security/create_api_key_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/create_api_key_spec.rb rename to elasticsearch-api/spec/unit/actions/security/create_api_key_spec.rb index 45dc2a192c..d6b9b18320 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/create_api_key_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/create_api_key_spec.rb @@ -25,7 +25,8 @@ '_security/api_key', {}, body, - {} + {}, + { endpoint: 'security.create_api_key' } ] end @@ -68,7 +69,8 @@ '_security/api_key', { refresh: 'wait_for' }, body, - {} + {}, + { endpoint: 'security.create_api_key' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/create_cross_cluster_api_key_spec.rb b/elasticsearch-api/spec/unit/actions/security/create_cross_cluster_api_key_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/create_cross_cluster_api_key_spec.rb rename to elasticsearch-api/spec/unit/actions/security/create_cross_cluster_api_key_spec.rb index f942097c49..5a4de5500c 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/create_cross_cluster_api_key_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/create_cross_cluster_api_key_spec.rb @@ -25,7 +25,8 @@ '_security/cross_cluster/api_key', {}, {}, - {} + {}, + { endpoint: 'security.create_cross_cluster_api_key' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/create_service_token_spec.rb b/elasticsearch-api/spec/unit/actions/security/create_service_token_spec.rb similarity index 83% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/create_service_token_spec.rb rename to elasticsearch-api/spec/unit/actions/security/create_service_token_spec.rb index bee231bee7..46e6b66002 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/create_service_token_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/create_service_token_spec.rb @@ -26,7 +26,9 @@ expected_path, {}, nil, - {} + {}, + { defined_params: { namespace: 'foo', service: 'bar' }, + endpoint: 'security.create_service_token' } ] end @@ -34,6 +36,18 @@ let(:expected_request_method) { 'PUT' } let(:token_name) { 'test-token' } let(:expected_path) { "#{super()}/#{token_name}" } + let(:expected_args) do + [ + expected_request_method, + expected_path, + {}, + nil, + {}, + { defined_params: { name: 'test-token', namespace: 'foo', service: 'bar' }, + endpoint: 'security.create_service_token' } + ] + end + it 'performs the request' do expect( client_double.security.create_service_token( diff --git a/elasticsearch-api/spec/unit/actions/security/delegate_pki_spec.rb b/elasticsearch-api/spec/unit/actions/security/delegate_pki_spec.rb new file mode 100644 index 0000000000..d21418f212 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/delegate_pki_spec.rb @@ -0,0 +1,39 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security#delegate_pki' do + let(:expected_args) do + [ + 'POST', + '_security/delegate_pki', + params, + {}, + {}, + { endpoint: 'security.delegate_pki' } + ] + end + + let(:params) do + {} + end + + it 'performs the request' do + expect(client_double.security.delegate_pki(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/delete_service_token_spec.rb b/elasticsearch-api/spec/unit/actions/security/delete_service_token_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/delete_service_token_spec.rb rename to elasticsearch-api/spec/unit/actions/security/delete_service_token_spec.rb index ae1408cef5..1366db2358 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/delete_service_token_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/delete_service_token_spec.rb @@ -24,7 +24,9 @@ '_security/service/foo/bar/credential/token/service_token', {}, nil, - {} + {}, + { defined_params: { name: 'service_token', namespace: 'foo', service: 'bar' }, + endpoint: 'security.delete_service_token' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/disable_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/disable_user_profile_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/disable_user_profile_spec.rb rename to elasticsearch-api/spec/unit/actions/security/disable_user_profile_spec.rb index 3a22747b1b..67aa731cbf 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/disable_user_profile_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/disable_user_profile_spec.rb @@ -24,7 +24,8 @@ '_security/profile/foo/_disable', {}, nil, - {} + {}, + { endpoint: 'security.disable_user_profile', defined_params: { uid: 'foo' } } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/enable_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/enable_user_profile_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/enable_user_profile_spec.rb rename to elasticsearch-api/spec/unit/actions/security/enable_user_profile_spec.rb index bc87ed2197..e5bf0dafab 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/enable_user_profile_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/enable_user_profile_spec.rb @@ -24,7 +24,8 @@ '_security/profile/foo/_enable', {}, nil, - {} + {}, + { endpoint: 'security.enable_user_profile', defined_params: { uid: 'foo' } } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/enroll_kibana_spec.rb b/elasticsearch-api/spec/unit/actions/security/enroll_kibana_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/enroll_kibana_spec.rb rename to elasticsearch-api/spec/unit/actions/security/enroll_kibana_spec.rb index c76085a1cf..6e281668c3 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/enroll_kibana_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/enroll_kibana_spec.rb @@ -24,7 +24,8 @@ '_security/enroll/kibana', {}, nil, - {} + {}, + { endpoint: 'security.enroll_kibana' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/get_api_key_spec.rb b/elasticsearch-api/spec/unit/actions/security/get_api_key_spec.rb similarity index 78% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/get_api_key_spec.rb rename to elasticsearch-api/spec/unit/actions/security/get_api_key_spec.rb index e5066f43fc..508cd23dde 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/get_api_key_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/get_api_key_spec.rb @@ -18,14 +18,14 @@ require 'spec_helper' describe 'client#security#get_api_key' do - let(:expected_args) do [ - 'GET', - '_security/api_key', - params, - nil, - {} + 'GET', + '_security/api_key', + params, + nil, + {}, + { endpoint: 'security.get_api_key' } ] end @@ -38,7 +38,6 @@ end context 'when params are specified' do - let(:params) do { id: '1', username: 'user', @@ -48,9 +47,9 @@ it 'performs the request' do expect(client_double.security.get_api_key(id: '1', - username: 'user', - name: 'my-api-key', - realm_name: '_es_api_key')).to be_a Elasticsearch::API::Response + username: 'user', + name: 'my-api-key', + realm_name: '_es_api_key')).to be_a Elasticsearch::API::Response end end end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/get_builtin_privileges_spec.rb b/elasticsearch-api/spec/unit/actions/security/get_builtin_privileges_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/get_builtin_privileges_spec.rb rename to elasticsearch-api/spec/unit/actions/security/get_builtin_privileges_spec.rb index 955881b062..8e1e77b0e8 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/get_builtin_privileges_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/get_builtin_privileges_spec.rb @@ -25,7 +25,8 @@ '_security/privilege/_builtin', {}, nil, - {} + {}, + { endpoint: 'security.get_builtin_privileges' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/get_service_accounts_spec.rb b/elasticsearch-api/spec/unit/actions/security/get_service_accounts_spec.rb similarity index 76% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/get_service_accounts_spec.rb rename to elasticsearch-api/spec/unit/actions/security/get_service_accounts_spec.rb index 5b7cd8015b..81a0df1ef2 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/get_service_accounts_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/get_service_accounts_spec.rb @@ -24,7 +24,8 @@ url, {}, nil, - {} + {}, + { endpoint: 'security.get_service_accounts' } ] end @@ -39,6 +40,18 @@ context 'when using namespace' do let(:url) { '_security/service/foo' } + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { namespace: 'foo' }, + endpoint: 'security.get_service_accounts' } + ] + end + it 'performs the request' do expect( client_double.security.get_service_accounts(namespace: 'foo') @@ -49,6 +62,18 @@ context 'when using namespace and service' do let(:url) { '_security/service/foo/bar' } + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { service: 'bar', namespace: 'foo' }, + endpoint: 'security.get_service_accounts' } + ] + end + it 'performs the request' do expect( client_double.security.get_service_accounts(namespace: 'foo', service: 'bar') diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/get_service_credentials_spec.rb b/elasticsearch-api/spec/unit/actions/security/get_service_credentials_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/get_service_credentials_spec.rb rename to elasticsearch-api/spec/unit/actions/security/get_service_credentials_spec.rb index 7bb6099294..b49e925a73 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/get_service_credentials_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/get_service_credentials_spec.rb @@ -24,7 +24,9 @@ '_security/service/foo/bar/credential', {}, nil, - {} + {}, + { defined_params: { namespace: 'foo', service: 'bar' }, + endpoint: 'security.get_service_credentials' } ] end diff --git a/elasticsearch-api/spec/unit/actions/security/get_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/get_user_profile_spec.rb new file mode 100644 index 0000000000..4d528ae1fa --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/get_user_profile_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security#get_user_profile' do + let(:expected_args) do + [ + 'GET', + '_security/profile/foo', + {}, + nil, + {}, + { endpoint: 'security.get_user_profile', defined_params: { uid: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.security.get_user_profile(uid: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/has_privilege_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/has_privilege_user_profile_spec.rb new file mode 100644 index 0000000000..a124ca0142 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/has_privilege_user_profile_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security#has_privileges_user_profile' do + let(:expected_args) do + [ + 'POST', + '_security/profile/_has_privileges', + {}, + {}, + {}, + { endpoint: 'security.has_privileges_user_profile' } + ] + end + + it 'performs the request' do + expect(client_double.security.has_privileges_user_profile(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/invalidate_api_key_spec.rb b/elasticsearch-api/spec/unit/actions/security/invalidate_api_key_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/invalidate_api_key_spec.rb rename to elasticsearch-api/spec/unit/actions/security/invalidate_api_key_spec.rb index 229a66a4ac..4e9819ab7d 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/invalidate_api_key_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/invalidate_api_key_spec.rb @@ -24,7 +24,8 @@ '_security/api_key', {}, body, - {} + {}, + { endpoint: 'security.invalidate_api_key' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/query_api_keys_spec.rb b/elasticsearch-api/spec/unit/actions/security/query_api_keys_spec.rb similarity index 96% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/query_api_keys_spec.rb rename to elasticsearch-api/spec/unit/actions/security/query_api_keys_spec.rb index ecb7537efa..e58c4aaa54 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/query_api_keys_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/query_api_keys_spec.rb @@ -24,7 +24,8 @@ '_security/_query/api_key', {}, body, - {} + {}, + { endpoint: 'security.query_api_keys' } ] end diff --git a/elasticsearch-api/spec/unit/actions/security/query_role_spec.rb b/elasticsearch-api/spec/unit/actions/security/query_role_spec.rb new file mode 100644 index 0000000000..8563135310 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/query_role_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security#query_user' do + let(:expected_args) do + [ + 'GET', + '_security/_query/role', + {}, + nil, + {}, + { endpoint: 'security.query_role' } + ] + end + + it 'performs the request' do + expect(client_double.security.query_role).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/query_user_spec.rb b/elasticsearch-api/spec/unit/actions/security/query_user_spec.rb new file mode 100644 index 0000000000..d8b6aec98b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/query_user_spec.rb @@ -0,0 +1,49 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security#query_user' do + let(:expected_args) do + [ + method, + '_security/_query/user', + {}, + body, + {}, + { endpoint: 'security.query_user' } + ] + end + + let(:body) { nil } + let(:method) { 'GET' } + + it 'performs the request' do + expect(client_double.security.query_user).to be_a Elasticsearch::API::Response + end + + context 'when body is specified' do + let(:body) do + { size: 1, query: 'test' } + end + let(:method) { 'POST' } + + it 'performs the request' do + expect(client_double.security.query_user(body: body)).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_authenticate_spec.rb b/elasticsearch-api/spec/unit/actions/security/saml_authenticate_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/saml_authenticate_spec.rb rename to elasticsearch-api/spec/unit/actions/security/saml_authenticate_spec.rb index 7bf79e26da..cc7159e2f1 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_authenticate_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/saml_authenticate_spec.rb @@ -24,7 +24,8 @@ '_security/saml/authenticate', {}, {}, - {} + {}, + { endpoint: 'security.saml_authenticate' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_complete_logout_spec.rb b/elasticsearch-api/spec/unit/actions/security/saml_complete_logout_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/saml_complete_logout_spec.rb rename to elasticsearch-api/spec/unit/actions/security/saml_complete_logout_spec.rb index 8aca481e45..66a8f0b282 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_complete_logout_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/saml_complete_logout_spec.rb @@ -24,7 +24,8 @@ '_security/saml/complete_logout', {}, {}, - {} + {}, + { endpoint: 'security.saml_complete_logout' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_invalidate_spec.rb b/elasticsearch-api/spec/unit/actions/security/saml_invalidate_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/saml_invalidate_spec.rb rename to elasticsearch-api/spec/unit/actions/security/saml_invalidate_spec.rb index 78875389a1..6ce3cf8f2a 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_invalidate_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/saml_invalidate_spec.rb @@ -24,7 +24,8 @@ '_security/saml/invalidate', {}, {}, - {} + {}, + { endpoint: 'security.saml_invalidate' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_logout_spec.rb b/elasticsearch-api/spec/unit/actions/security/saml_logout_spec.rb similarity index 96% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/saml_logout_spec.rb rename to elasticsearch-api/spec/unit/actions/security/saml_logout_spec.rb index 44c8f95051..542004b532 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_logout_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/saml_logout_spec.rb @@ -24,7 +24,8 @@ '_security/saml/logout', {}, {}, - {} + {}, + { endpoint: 'security.saml_logout' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_prepare_authentication_spec.rb b/elasticsearch-api/spec/unit/actions/security/saml_prepare_authentication_spec.rb similarity index 96% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/saml_prepare_authentication_spec.rb rename to elasticsearch-api/spec/unit/actions/security/saml_prepare_authentication_spec.rb index dd6c86d079..c3e535dce6 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_prepare_authentication_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/saml_prepare_authentication_spec.rb @@ -24,7 +24,8 @@ '_security/saml/logout', {}, {}, - {} + {}, + { endpoint: 'security.saml_logout' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_service_provider_metadata_spec.rb b/elasticsearch-api/spec/unit/actions/security/saml_service_provider_metadata_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/saml_service_provider_metadata_spec.rb rename to elasticsearch-api/spec/unit/actions/security/saml_service_provider_metadata_spec.rb index ce404c3380..365cdf5430 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/saml_service_provider_metadata_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/saml_service_provider_metadata_spec.rb @@ -24,7 +24,9 @@ "_security/saml/metadata/#{realm_name}", {}, nil, - {} + {}, + { defined_params: { realm_name: 'foo' }, + endpoint: 'security.saml_service_provider_metadata' } ] end diff --git a/elasticsearch-api/spec/unit/actions/security/suggest_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/suggest_user_profile_spec.rb new file mode 100644 index 0000000000..dcf0ba20b1 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/suggest_user_profile_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security#suggest_user_profiles' do + let(:expected_args) do + [ + 'POST', + '_security/profile/_suggest', + {}, + {}, + {}, + { endpoint: 'security.suggest_user_profiles' } + ] + end + + it 'performs the request' do + expect(client_double.security.suggest_user_profiles(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/update_api_key_spec.rb b/elasticsearch-api/spec/unit/actions/security/update_api_key_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/update_api_key_spec.rb rename to elasticsearch-api/spec/unit/actions/security/update_api_key_spec.rb index be21f2e76b..786eb57136 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/update_api_key_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/update_api_key_spec.rb @@ -24,7 +24,8 @@ '_security/api_key/foo', {}, nil, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'security.update_api_key' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/security/update_cross_cluster_api_key_spec.rb b/elasticsearch-api/spec/unit/actions/security/update_cross_cluster_api_key_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/security/update_cross_cluster_api_key_spec.rb rename to elasticsearch-api/spec/unit/actions/security/update_cross_cluster_api_key_spec.rb index 206310cec8..a25c5fdc55 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/security/update_cross_cluster_api_key_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/update_cross_cluster_api_key_spec.rb @@ -25,7 +25,9 @@ '_security/cross_cluster/api_key/the_id', {}, {}, - {} + {}, + { defined_params: { id: 'the_id' }, + endpoint: 'security.update_cross_cluster_api_key' } ] end diff --git a/elasticsearch-api/spec/unit/actions/security/update_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/update_user_profile_spec.rb new file mode 100644 index 0000000000..1682a97fb5 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/update_user_profile_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#security#update_user_profile_data' do + let(:expected_args) do + [ + 'PUT', + '_security/profile/foo/_data', + {}, + {}, + {}, + { endpoint: 'security.update_user_profile_data', defined_params: { uid: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.security.update_user_profile_data(uid: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/simulate/ingest_spec.rb b/elasticsearch-api/spec/unit/actions/simulate/ingest_spec.rb new file mode 100644 index 0000000000..f285fdeb45 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/simulate/ingest_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.simulate#ingest' do + let(:expected_args) do + [ + 'POST', + '_ingest/foo/_simulate', + {}, + {}, + {}, + { defined_params: {index: 'foo'}, endpoint: 'simulate.ingest' } + ] + end + + it 'performs the request' do + expect(client_double.simulate.ingest(body: {}, index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/snapshot/clone_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/clone_spec.rb new file mode 100644 index 0000000000..f56de899de --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/snapshot/clone_spec.rb @@ -0,0 +1,70 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.snapshot#clone' do + let(:expected_args) do + [ + 'PUT', + '_snapshot/foo/bar/_clone/snapshot', + {}, + {}, + {}, + { defined_params: + { repository: 'foo', snapshot: 'bar', target_snapshot: 'snapshot' }, + endpoint: 'snapshot.clone' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :body argument' do + expect { + client.snapshot.clone(snapshot: 'bar') + }.to raise_exception(ArgumentError) + end + + it 'requires the :repository argument' do + expect { + client.snapshot.clone(snapshot: 'foo', body: {}) + }.to raise_exception(ArgumentError) + end + + it 'requires the :snapshot argument' do + expect { + client.snapshot.clone(repository: 'foo', body: {}) + }.to raise_exception(ArgumentError) + end + + it 'requires the :target_snapshot argument' do + expect { + client.snapshot.clone(repository: 'foo', body: {}, snapshot: 'bar') + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.snapshot.clone( + repository: 'foo', + snapshot: 'bar', + body: {}, + target_snapshot: 'snapshot' + )).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/create_repository_spec.rb similarity index 93% rename from elasticsearch-api/spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb rename to elasticsearch-api/spec/unit/actions/snapshot/create_repository_spec.rb index 40d0bc0ffc..05eb80e837 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/create_repository_spec.rb +++ b/elasticsearch-api/spec/unit/actions/snapshot/create_repository_spec.rb @@ -25,7 +25,9 @@ '_snapshot/foo', {}, {}, - {} + {}, + { defined_params: { repository: 'foo' }, + endpoint: 'snapshot.create_repository' } ] end diff --git a/elasticsearch-api/spec/unit/actions/snapshot/create_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/create_spec.rb new file mode 100644 index 0000000000..7c0a3f7688 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/snapshot/create_spec.rb @@ -0,0 +1,53 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.snapshot#create' do + + let(:expected_args) do + [ + 'PUT', + '_snapshot/foo/bar', + {}, + {}, + {}, + { defined_params: { repository: 'foo', snapshot: 'bar' }, + endpoint: 'snapshot.create' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :repository argument' do + expect { + client.snapshot.create(snapshot: 'bar', body: {}) + }.to raise_exception(ArgumentError) + end + + it 'requires the :snapshot argument' do + expect { + client.snapshot.create(repository: 'foo', body: {}) + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.snapshot.create(repository: 'foo', snapshot: 'bar', body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/delete_repository_spec.rb similarity index 80% rename from elasticsearch-api/spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb rename to elasticsearch-api/spec/unit/actions/snapshot/delete_repository_spec.rb index 5e58be5f3d..9956f0b7ea 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/delete_repository_spec.rb +++ b/elasticsearch-api/spec/unit/actions/snapshot/delete_repository_spec.rb @@ -25,7 +25,9 @@ url, {}, nil, - {} + {}, + { defined_params: { repository: 'foo' }, + endpoint: 'snapshot.delete_repository' } ] end @@ -43,6 +45,18 @@ '_snapshot/foo,bar' end + let(:expected_args) do + [ + 'DELETE', + url, + {}, + nil, + {}, + { defined_params: { repository: ['foo','bar'] }, + endpoint: 'snapshot.delete_repository' } + ] + end + it 'performs the request' do expect(client_double.snapshot.delete_repository(repository: ['foo','bar'])).to be_a Elasticsearch::API::Response end diff --git a/elasticsearch-api/spec/unit/actions/snapshot/delete_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/delete_spec.rb new file mode 100644 index 0000000000..10eb98e74a --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/snapshot/delete_spec.rb @@ -0,0 +1,53 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.snapshot#delete' do + + let(:expected_args) do + [ + 'DELETE', + '_snapshot/foo/bar', + {}, + nil, + {}, + { defined_params: { repository: 'foo', snapshot: 'bar' }, + endpoint: 'snapshot.delete' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :snapshot argument' do + expect { + client.snapshot.delete(repository: 'foo') + }.to raise_exception(ArgumentError) + end + + it 'requires the :repository argument' do + expect { + client.snapshot.delete(snapshot: 'bar') + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.snapshot.delete(repository: 'foo', snapshot: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/get_repository_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/get_repository_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/snapshot/get_repository_spec.rb rename to elasticsearch-api/spec/unit/actions/snapshot/get_repository_spec.rb index f9591818af..fe56e64c73 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/get_repository_spec.rb +++ b/elasticsearch-api/spec/unit/actions/snapshot/get_repository_spec.rb @@ -25,7 +25,8 @@ '_snapshot/foo', {}, nil, - {} + {}, + { defined_params: { repository: 'foo' }, endpoint: 'snapshot.get_repository' } ] end diff --git a/elasticsearch-api/spec/unit/actions/snapshot/get_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/get_spec.rb new file mode 100644 index 0000000000..7c70263ea3 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/snapshot/get_spec.rb @@ -0,0 +1,53 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.snapshot#get' do + + let(:expected_args) do + [ + 'GET', + '_snapshot/foo/bar', + {}, + nil, + {}, + { defined_params: { repository: 'foo', snapshot: 'bar' }, + endpoint: 'snapshot.get' } + ] + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :snapshot argument' do + expect { + client.snapshot.get(repository: 'foo') + }.to raise_exception(ArgumentError) + end + + it 'requires the :repository argument' do + expect { + client.snapshot.get(snapshot: 'bar') + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.snapshot.get(repository: 'foo', snapshot: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/repository_analize_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/repository_analize_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/snapshot/repository_analize_spec.rb rename to elasticsearch-api/spec/unit/actions/snapshot/repository_analize_spec.rb index dc17d73dca..d2378fa1b3 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/repository_analize_spec.rb +++ b/elasticsearch-api/spec/unit/actions/snapshot/repository_analize_spec.rb @@ -24,7 +24,9 @@ url, {}, nil, - {} + {}, + { defined_params: { repository: 'foo' }, + endpoint: 'snapshot.repository_analyze' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/restore_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/restore_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/snapshot/restore_spec.rb rename to elasticsearch-api/spec/unit/actions/snapshot/restore_spec.rb index feaccf4035..fd0824dbfb 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/restore_spec.rb +++ b/elasticsearch-api/spec/unit/actions/snapshot/restore_spec.rb @@ -24,7 +24,9 @@ '_snapshot/foo/bar/_restore', {}, nil, - {} + {}, + { defined_params: { repository: 'foo', snapshot: 'bar' }, + endpoint: 'snapshot.restore' } ] end diff --git a/elasticsearch-api/spec/unit/actions/snapshot/status_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/status_spec.rb new file mode 100644 index 0000000000..c20245db8b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/snapshot/status_spec.rb @@ -0,0 +1,61 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.snapshot#status' do + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'snapshot.status' } + ] + end + + let(:url) do + '_snapshot/_status' + end + + it 'performs the request' do + expect(client_double.snapshot.status).to be_a Elasticsearch::API::Response + end + + context 'when a repository and snapshot are specified' do + let(:url) do + '_snapshot/foo/bar/_status' + end + + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { defined_params: { repository: 'foo', snapshot: 'bar' }, endpoint: 'snapshot.status' } + ] + end + + it 'performs the request' do + expect(client_double.snapshot.status(repository: 'foo', snapshot: 'bar')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/verify_repository_spec.rb b/elasticsearch-api/spec/unit/actions/snapshot/verify_repository_spec.rb similarity index 91% rename from elasticsearch-api/spec/elasticsearch/api/actions/snapshot/verify_repository_spec.rb rename to elasticsearch-api/spec/unit/actions/snapshot/verify_repository_spec.rb index fe0a026d52..fe72233ed5 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/snapshot/verify_repository_spec.rb +++ b/elasticsearch-api/spec/unit/actions/snapshot/verify_repository_spec.rb @@ -24,7 +24,9 @@ '_snapshot/foo/_verify', {}, nil, - {} + {}, + { defined_params: { repository: 'foo' }, + endpoint: 'snapshot.verify_repository' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/sql/delete_async_spec.rb b/elasticsearch-api/spec/unit/actions/sql/delete_async_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/sql/delete_async_spec.rb rename to elasticsearch-api/spec/unit/actions/sql/delete_async_spec.rb index 5a5d328d42..d901f791d3 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/sql/delete_async_spec.rb +++ b/elasticsearch-api/spec/unit/actions/sql/delete_async_spec.rb @@ -24,7 +24,8 @@ '_sql/async/delete/foo', {}, nil, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'sql.delete_async' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/sql/get_async_spec.rb b/elasticsearch-api/spec/unit/actions/sql/get_async_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/sql/get_async_spec.rb rename to elasticsearch-api/spec/unit/actions/sql/get_async_spec.rb index 0b4aaf611a..a510d863c7 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/sql/get_async_spec.rb +++ b/elasticsearch-api/spec/unit/actions/sql/get_async_spec.rb @@ -24,7 +24,8 @@ '_sql/async/foo', {}, nil, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'sql.get_async' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/sql/get_async_stats_spec.rb b/elasticsearch-api/spec/unit/actions/sql/get_async_stats_spec.rb similarity index 94% rename from elasticsearch-api/spec/elasticsearch/api/actions/sql/get_async_stats_spec.rb rename to elasticsearch-api/spec/unit/actions/sql/get_async_stats_spec.rb index 32616ccb89..4f45410593 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/sql/get_async_stats_spec.rb +++ b/elasticsearch-api/spec/unit/actions/sql/get_async_stats_spec.rb @@ -24,7 +24,8 @@ '_sql/async/status/foo', {}, nil, - {} + {}, + { defined_params: { id: 'foo' }, endpoint: 'sql.get_async_status' } ] end diff --git a/elasticsearch-api/spec/unit/actions/ssl/certificates_spec.rb b/elasticsearch-api/spec/unit/actions/ssl/certificates_spec.rb new file mode 100644 index 0000000000..7ff7f7a7af --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/ssl/certificates_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#ssl.certificates' do + let(:expected_args) do + [ + 'GET', + '_ssl/certificates', + {}, + nil, + {}, + { endpoint: 'ssl.certificates' } + ] + end + + it 'performs the request' do + expect(client_double.ssl.certificates(index: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/tasks/cancel_spec.rb b/elasticsearch-api/spec/unit/actions/tasks/cancel_spec.rb new file mode 100644 index 0000000000..5e6b8536c9 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/tasks/cancel_spec.rb @@ -0,0 +1,61 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.tasks#cancel' do + let(:expected_args) do + [ + 'POST', + url, + {}, + nil, + {}, + { endpoint: 'tasks.cancel' } + ] + end + + let(:url) do + '_tasks/_cancel' + end + + it 'performs the request' do + expect(client_double.tasks.cancel).to be_a Elasticsearch::API::Response + end + + context 'when a task id is specified' do + + let(:url) do + '_tasks/foo/_cancel' + end + + let(:expected_args) do + [ + 'POST', + url, + {}, + nil, + {}, + { defined_params: { task_id: 'foo' }, endpoint: 'tasks.cancel' } + ] + end + + it 'performs the request' do + expect(client_double.tasks.cancel(task_id: 'foo')).to be_a Elasticsearch::API::Response + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/tasks/get_spec.rb b/elasticsearch-api/spec/unit/actions/tasks/get_spec.rb new file mode 100644 index 0000000000..6b9d60d010 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/tasks/get_spec.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.tasks#get' do + + let(:expected_args) do + [ + 'GET', + '_tasks/foo1', + {}, + nil, + {}, + { defined_params: { task_id: 'foo1' }, endpoint: 'tasks.get' } + ] + end + + it 'performs the request' do + expect(client_double.tasks.get(task_id: 'foo1')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/tasks/list_spec.rb b/elasticsearch-api/spec/unit/actions/tasks/list_spec.rb new file mode 100644 index 0000000000..7da4ce67ea --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/tasks/list_spec.rb @@ -0,0 +1,39 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.tasks#list' do + let(:expected_args) do + [ + 'GET', + url, + {}, + nil, + {}, + { endpoint: 'tasks.list' } + ] + end + + let(:url) do + '_tasks' + end + + it 'performs the request' do + expect(client_double.tasks.list).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/terms_enum_spec.rb b/elasticsearch-api/spec/unit/actions/terms_enum_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/actions/terms_enum_spec.rb rename to elasticsearch-api/spec/unit/actions/terms_enum_spec.rb index d09a52a42d..a183a53c31 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/terms_enum_spec.rb +++ b/elasticsearch-api/spec/unit/actions/terms_enum_spec.rb @@ -24,7 +24,8 @@ 'foo/_terms_enum', {}, body, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'terms_enum' } ] end diff --git a/elasticsearch-api/spec/unit/actions/termvectors_spec.rb b/elasticsearch-api/spec/unit/actions/termvectors_spec.rb new file mode 100644 index 0000000000..d7d607832f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/termvectors_spec.rb @@ -0,0 +1,82 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#termvectors' do + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { id: '123', index: 'foo' }, endpoint: 'termvectors' } + ] + end + + let(:url) do + 'foo/_termvectors/123' + end + + let(:params) do + {} + end + + let(:body) do + {} + end + + let(:client) do + Class.new { include Elasticsearch::API }.new + end + + it 'requires the :index argument' do + expect { + client.termvectors(id: '1') + }.to raise_exception(ArgumentError) + end + + it 'performs the request' do + expect(client_double.termvectors(index: 'foo', id: '123', body: {})).to be_a Elasticsearch::API::Response + end + + context 'when the older api name \'termvector\' is used' do + let(:url) do + 'foo/_termvectors/123' + end + + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { id: '123', index: 'foo' }, endpoint: '_termvector' } + ] + end + + it 'performs the request' do + message = '[DEPRECATION] `termvector` is deprecated. Please use the plural version, `termvectors` instead. +' + expect do + client_double.termvector(index: 'foo', id: '123', body: {}) + end.to output(message).to_stderr + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/text_structure/find_field_structure_spec.rb b/elasticsearch-api/spec/unit/actions/text_structure/find_field_structure_spec.rb new file mode 100644 index 0000000000..e9adf509e1 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/text_structure/find_field_structure_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.text_structure#test_grok_pattern' do + let(:expected_args) do + [ + 'GET', + '_text_structure/find_field_structure', + {}, + nil, + {}, + { endpoint: 'text_structure.find_field_structure' } + ] + end + + it 'performs the request' do + expect(client_double.text_structure.find_field_structure).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/text_structure/find_message_structure_spec.rb b/elasticsearch-api/spec/unit/actions/text_structure/find_message_structure_spec.rb new file mode 100644 index 0000000000..086d55d8be --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/text_structure/find_message_structure_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.text_structure#test_grok_pattern' do + let(:expected_args) do + [ + 'POST', + '_text_structure/find_message_structure', + {}, + {}, + {}, + { endpoint: 'text_structure.find_message_structure' } + ] + end + + it 'performs the request' do + expect(client_double.text_structure.find_message_structure(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/text_structure/find_structure_spec.rb b/elasticsearch-api/spec/unit/actions/text_structure/find_structure_spec.rb new file mode 100644 index 0000000000..cd94e76348 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/text_structure/find_structure_spec.rb @@ -0,0 +1,41 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.text_structure#test_grok_pattern' do + let(:expected_args) do + [ + 'POST', + '_text_structure/find_structure', + {}, + {}, + headers, + { endpoint: 'text_structure.find_structure' } + ] + end + + let(:headers) { + { + 'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9' + } + } + + it 'performs the request' do + expect(client_double.text_structure.find_structure(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/text_structure/test_grok_pattern_spec.rb b/elasticsearch-api/spec/unit/actions/text_structure/test_grok_pattern_spec.rb new file mode 100644 index 0000000000..a541750c6a --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/text_structure/test_grok_pattern_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.text_structure#test_grok_pattern' do + let(:expected_args) do + [ + 'POST', + '_text_structure/test_grok_pattern', + {}, + {}, + {}, + { endpoint: 'text_structure.test_grok_pattern' } + ] + end + + it 'performs the request' do + expect(client_double.text_structure.test_grok_pattern(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/transform/get_node_stats_spec.rb b/elasticsearch-api/spec/unit/actions/transform/get_node_stats_spec.rb new file mode 100644 index 0000000000..1eb0030709 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/transform/get_node_stats_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client.transform#get_node_stats' do + let(:expected_args) do + [ + 'GET', + '_transform/_node_stats', + {}, + nil, + {}, + { endpoint: 'transform.get_node_stats' } + ] + end + + it 'performs the request' do + expect(client_double.transform.get_node_stats).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/platinum/unit/transform/reset_transform_spec.rb b/elasticsearch-api/spec/unit/actions/transform/reset_transform_spec.rb similarity index 91% rename from elasticsearch-api/spec/platinum/unit/transform/reset_transform_spec.rb rename to elasticsearch-api/spec/unit/actions/transform/reset_transform_spec.rb index 8a6bc91062..11a5542f05 100644 --- a/elasticsearch-api/spec/platinum/unit/transform/reset_transform_spec.rb +++ b/elasticsearch-api/spec/unit/actions/transform/reset_transform_spec.rb @@ -24,7 +24,9 @@ '_transform/foo/_reset', {}, nil, - {} + {}, + { defined_params: { transform_id: 'foo' }, + endpoint: 'transform.reset_transform' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/transform/schedule_now_transform_spec.rb b/elasticsearch-api/spec/unit/actions/transform/schedule_now_transform_spec.rb similarity index 90% rename from elasticsearch-api/spec/elasticsearch/api/actions/transform/schedule_now_transform_spec.rb rename to elasticsearch-api/spec/unit/actions/transform/schedule_now_transform_spec.rb index a0d5830b92..2c2f2ecec0 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/transform/schedule_now_transform_spec.rb +++ b/elasticsearch-api/spec/unit/actions/transform/schedule_now_transform_spec.rb @@ -24,7 +24,9 @@ '_transform/id/_schedule_now', {}, nil, - {} + {}, + { defined_params: { transform_id: 'id' }, + endpoint: 'transform.schedule_now_transform' } ] end diff --git a/elasticsearch-api/spec/platinum/unit/transform/upgrade_transforms_spec.rb b/elasticsearch-api/spec/unit/actions/transform/upgrade_transforms_spec.rb similarity index 94% rename from elasticsearch-api/spec/platinum/unit/transform/upgrade_transforms_spec.rb rename to elasticsearch-api/spec/unit/actions/transform/upgrade_transforms_spec.rb index 4180a3c25b..cf792f2a2b 100644 --- a/elasticsearch-api/spec/platinum/unit/transform/upgrade_transforms_spec.rb +++ b/elasticsearch-api/spec/unit/actions/transform/upgrade_transforms_spec.rb @@ -24,7 +24,8 @@ '_transform/_upgrade', {}, nil, - {} + {}, + { endpoint: 'transform.upgrade_transforms' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/update_by_query_spec.rb b/elasticsearch-api/spec/unit/actions/update_by_query_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/update_by_query_spec.rb rename to elasticsearch-api/spec/unit/actions/update_by_query_spec.rb index 73d252b0e9..b67daa0b6c 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/update_by_query_spec.rb +++ b/elasticsearch-api/spec/unit/actions/update_by_query_spec.rb @@ -24,7 +24,8 @@ 'foo/_update_by_query', {}, nil, - {} + {}, + { defined_params: { index: 'foo' }, endpoint: 'update_by_query' } ] end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/update_document_spec.rb b/elasticsearch-api/spec/unit/actions/update_document_spec.rb similarity index 90% rename from elasticsearch-api/spec/elasticsearch/api/actions/update_document_spec.rb rename to elasticsearch-api/spec/unit/actions/update_document_spec.rb index 734addee26..5329b2806c 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/update_document_spec.rb +++ b/elasticsearch-api/spec/unit/actions/update_document_spec.rb @@ -24,7 +24,8 @@ url, params, body, - {} + {}, + { defined_params: { id: '1', index: 'foo' }, endpoint: 'update' } ] end @@ -83,6 +84,17 @@ {} end + let(:expected_args) do + [ + 'POST', + url, + params, + body, + {}, + { defined_params: { id: '1', index: 'foo^bar' }, endpoint: 'update' } + ] + end + it 'escapes the parts' do expect(client_double.update(index: 'foo^bar', id: '1', body: {})) end diff --git a/elasticsearch-api/spec/unit/actions/watcher/get_settings_spec.rb b/elasticsearch-api/spec/unit/actions/watcher/get_settings_spec.rb new file mode 100644 index 0000000000..4554361c54 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/watcher/get_settings_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#watcher.get_settings' do + let(:expected_args) do + [ + 'GET', + '_watcher/settings', + {}, + nil, + {}, + { endpoint: 'watcher.get_settings' } + ] + end + + it 'performs the request' do + expect(client_double.watcher.get_settings).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/watcher/update_settings_spec.rb b/elasticsearch-api/spec/unit/actions/watcher/update_settings_spec.rb similarity index 92% rename from elasticsearch-api/spec/elasticsearch/api/actions/watcher/update_settings_spec.rb rename to elasticsearch-api/spec/unit/actions/watcher/update_settings_spec.rb index b8e8a06364..56e0094429 100644 --- a/elasticsearch-api/spec/elasticsearch/api/actions/watcher/update_settings_spec.rb +++ b/elasticsearch-api/spec/unit/actions/watcher/update_settings_spec.rb @@ -17,14 +17,15 @@ require 'spec_helper' -describe 'client#watcher.get_settings' do +describe 'client#watcher.update_settings' do let(:expected_args) do [ 'PUT', '_watcher/settings', {}, {}, - {} + {}, + { endpoint: 'watcher.update_settings' } ] end diff --git a/elasticsearch-api/spec/unit/actions/xpack/usage_spec.rb b/elasticsearch-api/spec/unit/actions/xpack/usage_spec.rb new file mode 100644 index 0000000000..c0f73e87b0 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/xpack/usage_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe 'client#usage' do + let(:expected_args) do + [ + 'GET', + '_xpack/usage', + {}, + nil, + {}, + { endpoint: 'xpack.usage' } + ] + end + + it 'performs the request' do + expect(client_double.xpack.usage).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/api_response_spec.rb b/elasticsearch-api/spec/unit/api_response_spec.rb similarity index 95% rename from elasticsearch-api/spec/elasticsearch/api/api_response_spec.rb rename to elasticsearch-api/spec/unit/api_response_spec.rb index c976602bb8..06fdb602ad 100644 --- a/elasticsearch-api/spec/elasticsearch/api/api_response_spec.rb +++ b/elasticsearch-api/spec/unit/api_response_spec.rb @@ -62,4 +62,8 @@ it 'returns the body which' do expect(response.body).to eq response_body end + + it 'returns the body with to_s' do + expect(response.to_s).to eq response.body.to_s + end end diff --git a/elasticsearch-api/spec/elasticsearch/api/api_spec.rb b/elasticsearch-api/spec/unit/api_spec.rb similarity index 100% rename from elasticsearch-api/spec/elasticsearch/api/api_spec.rb rename to elasticsearch-api/spec/unit/api_spec.rb diff --git a/elasticsearch-api/spec/elasticsearch/api/client_spec.rb b/elasticsearch-api/spec/unit/client_spec.rb similarity index 100% rename from elasticsearch-api/spec/elasticsearch/api/client_spec.rb rename to elasticsearch-api/spec/unit/client_spec.rb diff --git a/elasticsearch-api/spec/unit/perform_request_spec.rb b/elasticsearch-api/spec/unit/perform_request_spec.rb new file mode 100644 index 0000000000..6d58d3785a --- /dev/null +++ b/elasticsearch-api/spec/unit/perform_request_spec.rb @@ -0,0 +1,91 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' +require 'elastic-transport' +require_relative File.expand_path('../../utils/thor/endpoint_spec', __dir__) +require_relative File.expand_path('../../utils/thor/generator/files_helper', __dir__) + +describe 'Perform request args' do + Elasticsearch::API::FilesHelper.files.each do |filepath| + spec = Elasticsearch::API::EndpointSpec.new(filepath) + next if spec.module_namespace.flatten.first == '_internal' || + spec.visibility != 'public' || + # TODO: Once the test suite is migrated to elasticsearch-specification, these should be removed + spec.module_namespace.flatten.first == 'rollup' || + [ + 'scroll', 'clear_scroll', 'connector.last_sync', 'inference.put_eis', 'knn_search', + 'indices.put_data_stream_options', 'indices.delete_data_stream_options', 'indices.get_data_stream_options' + ].include?(spec.endpoint_name) + + # These are the path parts defined by the user in the method argument + defined_path_parts = spec.path_params.inject({}) do |params, part| + params.merge(part => 'testing') + end + + # These are the required params, we must pass them to the method even when testing + required_params = spec.required_parts.inject({}) do |params, part| + params.merge(part.to_sym => 'testing') + end + + required_params.merge!(body: {}) if ['inference.put', 'inference.update', 'inference.chat_completion_unified'].include? spec.endpoint_name + + let(:client_double) do + Class.new { include Elasticsearch::API }.new.tap do |client| + expect(client).to receive(:perform_request) do |_, _, _, _, _, request_params| + # Check that the expected hash is passed to the perform_request method + expect(request_params).to eq(expected_perform_request_params) + end.and_return(response_double) + end + end + + let(:response_double) do + double('response', status: 200, body: {}, headers: {}) + end + + context("'#{spec.endpoint_name}'") do + # The expected hash passed to perform_request contains the endpoint name and any defined path parts + let(:expected_perform_request_params) do + if defined_path_parts.empty? + { endpoint: spec.endpoint_name } + else + { endpoint: spec.endpoint_name, defined_params: defined_path_parts } + end + end + + if spec.path_parts.empty? + it "passes the endpoint id to the request" do + if spec.module_namespace.empty? + client_double.send(spec.method_name, required_params) + else + client_double.send(spec.module_namespace[0]).send(spec.method_name, required_params) + end + end + else + it "passes params to the request with the endpoint id: #{spec.path_parts.keys}" do + if spec.module_namespace.empty? + client_double.send(spec.method_name, required_params.merge(defined_path_parts)) + else + client_double.send( + spec.module_namespace[0]).send(spec.method_name, required_params.merge(defined_path_parts) + ) + end + end + end + end + end +end diff --git a/elasticsearch-api/spec/platinum/unit/test_helper.rb b/elasticsearch-api/spec/unit/test_helper.rb similarity index 81% rename from elasticsearch-api/spec/platinum/unit/test_helper.rb rename to elasticsearch-api/spec/unit/test_helper.rb index 6a914a20f6..16e1cc0374 100644 --- a/elasticsearch-api/spec/platinum/unit/test_helper.rb +++ b/elasticsearch-api/spec/unit/test_helper.rb @@ -26,22 +26,6 @@ require 'elasticsearch' require 'elasticsearch/api' -Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new(print_failure_summary: true) - -module Minitest - class Test - def assert_nothing_raised(*args) - begin - line = __LINE__ - yield - rescue Exception => e - raise MiniTest::Assertion, "Exception raised:\n<#{e.class}>", e.backtrace - end - true - end - end -end - module Elasticsearch module Test class FakeClient diff --git a/elasticsearch-api/spec/unit/utils_spec.rb b/elasticsearch-api/spec/unit/utils_spec.rb new file mode 100644 index 0000000000..93680796cb --- /dev/null +++ b/elasticsearch-api/spec/unit/utils_spec.rb @@ -0,0 +1,250 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'spec_helper' + +describe Elasticsearch::API::Utils do + let(:utils) do + Class.new { include Elasticsearch::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%20bar') + 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 + 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(['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 + + it 'ignores special characters' do + expect(utils.listify(['foo', 'bar^bam'])).to eq('foo,bar%5Ebam') + end + + 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') + 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(['foo', 'bar'])).to eq('foo/bar') + end + + it 'ignores nil values' do + expect(utils.pathify(['foo', nil, 'bar'])).to eq('foo/bar') + end + + it 'ignores empty string values' do + expect(utils.pathify(['foo', '', 'bar'])).to eq('foo/bar') + end + end + + describe '#bulkify' do + context 'when the input is an array of hashes' do + let(:result) do + utils.bulkify [ + { index: { _index: 'myindexA', _id: '1', data: { title: 'Test' } } }, + { update: { _index: 'myindexB', _id: '2', data: { doc: { title: 'Update' } } } }, + { delete: { _index: 'myindexC', _id: '3' } } + ] + end + + let(:expected_string) do + <<-PAYLOAD.gsub(/^\s+/, '') + {"index":{"_index":"myindexA","_id":"1"}} + {"title":"Test"} + {"update":{"_index":"myindexB","_id":"2"}} + {"doc":{"title":"Update"}} + {"delete":{"_index":"myindexC","_id":"3"}} + PAYLOAD + end + + it 'serializes the hashes' do + expect(result).to eq(expected_string) + end + end + + context 'when the input is an array of strings' do + + let(:result) do + utils.bulkify(['{"foo":"bar"}','{"moo":"bam"}']) + end + + let(:expected_string) do + <<-PAYLOAD.gsub(/^\s+/, '') + {"foo":"bar"} + {"moo":"bam"} + PAYLOAD + end + + it 'serializes the array of strings' do + expect(result).to eq(expected_string) + end + end + + context 'when the input is an array of header/data pairs' do + + let(:result) do + utils.bulkify([{ foo: 'bar' }, { moo: 'bam' },{ foo: 'baz' }]) + end + + let(:expected_string) do + <<-PAYLOAD.gsub(/^\s+/, '') + {"foo":"bar"} + {"moo":"bam"} + {"foo":"baz"} + PAYLOAD + end + + it 'serializes the array of strings' do + expect(result).to eq(expected_string) + end + end + + context 'when the payload has the :data option' do + + let(:input) do + { index: { foo: 'bar', data: { moo: 'bam' } } } + end + + let(:result) do + utils.bulkify([input]) + end + + let(:expected_string) do + <<-PAYLOAD.gsub(/^\s+/, '') + {"index":{"foo":"bar"}} + {"moo":"bam"} + PAYLOAD + end + + it 'does not mutate the input' do + expect(input[:index][:data]).to eq(moo: 'bam') + end + + it 'serializes the array of strings' do + expect(result).to eq(expected_string) + end + end + + context 'when the payload has nested :data options' do + let(:data) do + { data: { a: 'b', data: { c: 'd' } } } + end + + let(:result) do + utils.bulkify([{ index: { foo: 'bar'} } , data]) + end + + let(:lines) do + result.split("\n") + end + + let(:header) do + MultiJson.load(lines.first) + end + + let(:data_string) do + MultiJson.load(lines.last) + end + + it 'does not mutate the input' do + expect(data[:data]).to eq(a: 'b', data: { c: 'd' }) + end + + it 'serializes the array of strings' do + expect(header['index']['foo']).to eq('bar') + expect(data_string['data']['a']).to eq('b') + expect(data_string['data']['data']['c']).to eq('d') + end + end + end + + context '#__validate_and_extract_params' do + it 'listify Arrays' do + expect(utils.process_params({ foo: ['a', 'b'] })).to eq(foo: 'a,b') + end + + it 'does not escape the parameters' do + expect(utils.process_params({ foo: ['a.*', 'b.*'] })).to eq(foo: 'a.*,b.*') + end + + context 'when the params are valid' do + it 'extracts the valid params from the hash' do + expect(utils.process_params({ foo: 'qux' })).to eq(foo: 'qux') + 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' })).to eq(['foo', 'blah']) + end + + it 'extracts parts with string value from a Hash' do + expect(utils.extract_parts({ foo: 'qux', moo: 'blah' })).to eq(['qux', 'blah']) + end + end + + context '#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.new "Not Found" }).to be(false) + expect(utils.rescue_from_not_found { raise StandardError.new "NotFound" }).to be(false) + end + + it 'raises the exception if the class name and message do not include \'NotFound\'' do + expect { + utils.rescue_from_not_found { raise StandardError.new "Any other exception" } + }.to raise_exception(StandardError) + end + end +end diff --git a/elasticsearch-api/spec/yaml-test-runner/run.rb b/elasticsearch-api/spec/yaml-test-runner/run.rb new file mode 100644 index 0000000000..203b790bdf --- /dev/null +++ b/elasticsearch-api/spec/yaml-test-runner/run.rb @@ -0,0 +1,88 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'logger' +require 'openssl' +require 'elasticsearch' +require 'elasticsearch/tests/test_runner' +require 'elasticsearch/tests/downloader' + +PROJECT_PATH = File.join(File.dirname(__FILE__), '../..') +CERTS_PATH = "#{PROJECT_PATH}/../.buildkite/certs/".freeze +host = ENV['TEST_ES_SERVER'] || 'https://localhost:9200' +raise URI::InvalidURIError unless host =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ + +password = ENV['ELASTIC_PASSWORD'] || 'changeme' +uri = URI.parse(host) + +def serverless? + ENV['TEST_SUITE'] == 'serverless' +end + +if uri.is_a?(URI::HTTPS) + raw_certificate = File.read("#{CERTS_PATH}/testnode.crt") + certificate = OpenSSL::X509::Certificate.new(raw_certificate) + raw_key = File.read("#{CERTS_PATH}/testnode.key") + key = OpenSSL::PKey::RSA.new(raw_key) + ca_file = File.expand_path("#{CERTS_PATH}/ca.crt") + host = "https://elastic:#{password}@#{uri.host}:#{uri.port}".freeze unless serverless? + transport_options = { + ssl: { + client_cert: certificate, + client_key: key, + ca_file: ca_file, + verify: false + } + } +elsif uri.is_a?(URI::HTTP) + host = "http://elastic:#{password}@#{uri.host}:#{uri.port}".freeze + transport_options = {} +end + +options = { + host: host, + transport_options: transport_options, +} +options.merge!({ api_key: ENV['ES_API_KEY'] }) if ENV['ES_API_KEY'] + +if serverless? + options.merge!( + { + retry_on_status: [409, 400, 503], + retry_on_failure: 10, + delay_on_retry: 5_000, + request_timeout: 120 + } + ) +end +CLIENT = Elasticsearch::Client.new(options) + +tests_path = File.expand_path('./tmp', __dir__) +ruby_version = defined?(JRUBY_VERSION) ? "jruby-#{JRUBY_VERSION}" : "ruby-#{RUBY_VERSION}" + +log_filename = "es-#{Elasticsearch::VERSION}-#{ENV['TEST_SUITE']}-transport-#{ENV['TRANSPORT_VERSION']}-#{ruby_version}.log" +logfile = File.expand_path "../../tmp/#{log_filename}", __dir__ +logger = Logger.new(File.open(logfile, 'w')) +logger.level = ENV['DEBUG'] ? Logger::DEBUG : Logger::WARN + +# If we're running in a release branch, download the corresponding branch for tests +current_branch = `git rev-parse --abbrev-ref HEAD`.strip +branch = current_branch.match(/[0-9]\.[0-9]+/)&.[](0) || ENV['ES_YAML_TESTS_BRANCH'] || nil +Elasticsearch::Tests::Downloader::run(tests_path, branch) + +runner = Elasticsearch::Tests::TestRunner.new(CLIENT, tests_path, logger) +runner.run(ENV['SINGLE_TEST'] || []) diff --git a/elasticsearch-api/utils/Gemfile b/elasticsearch-api/utils/Gemfile index d9fb5ce455..d7a0fe4d5a 100644 --- a/elasticsearch-api/utils/Gemfile +++ b/elasticsearch-api/utils/Gemfile @@ -17,10 +17,12 @@ source 'https://rubygems.org' -gem 'byebug' unless defined?(JRUBY_VERSION) gem 'coderay' + gem 'json' gem 'multi_json' gem 'pry' -gem 'rubocop' gem 'thor' + +gem 'rubocop', '>= 1.51' unless defined?(JRUBY_VERSION) +gem 'debug' unless defined?(JRUBY_VERSION) diff --git a/elasticsearch-api/utils/README.md b/elasticsearch-api/utils/README.md index 8bd6d967f2..c69113941c 100644 --- a/elasticsearch-api/utils/README.md +++ b/elasticsearch-api/utils/README.md @@ -8,7 +8,7 @@ This directory hosts The Generator, a tool that generates the classes for each A To generate the code, you need to have the Elasticsearch REST API spec files in `tmp/rest-api-spec` in the root of the project. You can run a rake task from the root of the project to download the specs corresponding to the current running cluster: ```bash -$ rake elasticsearch:download_artifacts +$ rake es:download_artifacts ``` Once the JSON files have been downloaded, you need to run (from this folder): @@ -24,7 +24,7 @@ $ thor code:generate $ IGNORE_VERSION=true thor code:generate ``` -- You can use the environment variable `BUILD_HASH` to update the build hash for the generated code from the `tmp/rest-api-spec/build_hash` file. This file is updated every time you use the `elasticsearch:download_artifacts` Rake task is used in the root of the project to download the latest Elasticsearch specs and tests: +- You can use the environment variable `BUILD_HASH` to update the build hash for the generated code from the `tmp/rest-api-spec/build_hash` file. This file is updated every time you use the `es:download_artifacts` Rake task is used in the root of the project to download the latest Elasticsearch specs and tests: ```bash $ BUILD_HASH=true thor code:generate ``` diff --git a/elasticsearch-api/utils/thor/.rubocop.yml b/elasticsearch-api/utils/thor/.rubocop.yml index ea30afd29b..98a88a262f 100644 --- a/elasticsearch-api/utils/thor/.rubocop.yml +++ b/elasticsearch-api/utils/thor/.rubocop.yml @@ -1,2 +1,4 @@ Layout/EndAlignment: AutoCorrect: true +Layout/EmptyComment: + Enabled: false diff --git a/elasticsearch-api/utils/thor/endpoint_spec.rb b/elasticsearch-api/utils/thor/endpoint_spec.rb new file mode 100644 index 0000000000..6b7aca4bdf --- /dev/null +++ b/elasticsearch-api/utils/thor/endpoint_spec.rb @@ -0,0 +1,201 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# encoding: UTF-8 + +require_relative 'endpoint_specifics' + +module Elasticsearch + module API + class EndpointSpec + include EndpointSpecifics + + def initialize(filepath) + @path = Pathname(filepath) + json = MultiJson.load(File.read(@path)) + @spec = json.values.first + @endpoint_name = json.keys.first + + full_namespace = parse_full_namespace + @namespace_depth = full_namespace.size.positive? ? full_namespace.size - 1 : 0 + @module_namespace = full_namespace[0, @namespace_depth] + @method_name = full_namespace.last + + @path_parts = parse_endpoint_parts(@spec) + @params = @spec['params'] || {} + @paths = @spec['url']['paths'].map { |b| b['path'] } if @spec['url'] + @path_params = path_variables.flatten.uniq.collect(&:to_sym) + @http_method = parse_http_method(@spec) + @deprecation_note = @spec['url']['paths'].last&.[]('deprecated') + @http_path = parse_http_path(@paths) + @required_parts = parse_required_parts(@spec) + end + + attr_reader :module_namespace, + :method_name, + :endpoint_name, + :path, + :path_parts, + :params, + :deprecation_note, + :namespace_depth, + :http_path, + :required_parts, + :http_method, + :path_params, + :perform_request_opts + + def body + @spec['body'] + end + + def documentation + @spec['documentation'] + end + + def stability + @spec['stability'] + end + + def visibility + @spec['visibility'] + end + + def skippable? + module_namespace.flatten.first == '_internal' || visibility != 'public' + end + + # Function that adds the listified h param code + def specific_params + super(@module_namespace.first, @method_name) + end + + private + + def parse_full_namespace + names = @endpoint_name.split('.') + # Return an array to expand 'ccr', 'ilm', 'ml' and 'slm' + names.map do |name| + name + .gsub(/^ml$/, 'machine_learning') + .gsub(/^ilm$/, 'index_lifecycle_management') + .gsub(/^ccr/, 'cross_cluster_replication') + .gsub(/^slm/, 'snapshot_lifecycle_management') + end + end + + def parse_endpoint_parts(spec) + parts = spec['url']['paths'].select do |a| + a.keys.include?('parts') + end.map do |path| + path&.[]('parts') + end + (parts.inject(&:merge) || []) + end + + def parse_http_method(spec) + return '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @endpoint_name == 'index' + return '_name ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @method_name == 'create_service_token' + return post_and_get if @endpoint_name == 'count' + + default_method = spec['url']['paths'].map { |a| a['methods'] }.flatten.first + if spec['body'] && default_method == 'GET' + # When default method is GET and body is required, we should always use POST + if spec['body']['required'] + 'Elasticsearch::API::HTTP_POST' + else + post_and_get + end + else + "Elasticsearch::API::HTTP_#{default_method}" + end + end + + def parse_http_path(paths) + return "\"#{parse_path(paths.first)}\"" if paths.size == 1 + + result = '' + anchor_string = [] + paths.sort { |a, b| b.length <=> a.length }.each_with_index do |path, i| + var_string = extract_path_variables(path).map { |var| "_#{var}" }.join(' && ') + next if anchor_string.include? var_string + + anchor_string << var_string + result += if i.zero? + "if #{var_string}\n" + elsif (i == paths.size - 1) || var_string.empty? + "else\n" + else + "elsif #{var_string}\n" + end + result += "\"#{parse_path(path)}\"\n" + end + result += 'end' + result + end + + def parse_path(path) + path.gsub(/^\//, '') + .gsub(/\/$/, '') + .gsub('{', "\#{Utils.__listify(_") + .gsub('}', ')}') + end + + def path_variables + @paths.map do |path| + extract_path_variables(path) + end + end + + def parse_path_variables + @paths.map do |path| + extract_path_variables(path) + end + end + + # extract values that are in the {var} format: + def extract_path_variables(path) + path.scan(/{(\w+)}/).flatten + end + + # Find parts that are definitely required and should raise an error if + # they're not present + # + def parse_required_parts(spec) + required = [] + return required if @endpoint_name == 'tasks.get' + + required << 'body' if (spec['body'] && spec['body']['required']) + # Get required variables from paths: + req_variables = parse_path_variables.inject(:&) # find intersection + required << req_variables unless req_variables.empty? + required.flatten + end + + def post_and_get + # the METHOD is defined after doing arguments.delete(:body), so we need to check for `body` + <<~SRC + if body + Elasticsearch::API::HTTP_POST + else + Elasticsearch::API::HTTP_GET + end + SRC + end + end + end +end diff --git a/elasticsearch-api/utils/thor/generator/endpoint_specifics.rb b/elasticsearch-api/utils/thor/endpoint_specifics.rb similarity index 87% rename from elasticsearch-api/utils/thor/generator/endpoint_specifics.rb rename to elasticsearch-api/utils/thor/endpoint_specifics.rb index 013358087e..d521b5160b 100644 --- a/elasticsearch-api/utils/thor/generator/endpoint_specifics.rb +++ b/elasticsearch-api/utils/thor/endpoint_specifics.rb @@ -39,6 +39,7 @@ module EndpointSpecifics indices.delete indices.delete_template indices.flush_synced + query_rules.delete_ruleset security.get_role security.get_user snapshot.delete @@ -55,10 +56,10 @@ module EndpointSpecifics recovery shards thread_pool].freeze # Function that adds the listified h param code - def specific_params(namespace) + def specific_params(namespace, method_name) params = [] - if H_PARAMS.include?(@method_name) && namespace == 'cat' - if @method_name == 'nodes' + if H_PARAMS.include?(method_name) && namespace == 'cat' + if method_name == 'nodes' params << 'params[:h] = Utils.__listify(params[:h], escape: false) if params[:h]' else params << 'params[:h] = Utils.__listify(params[:h]) if params[:h]' @@ -84,7 +85,7 @@ def module_name_helper(name) def ping_perform_request <<~SRC begin - perform_request(method, path, params, body, headers).status == 200 ? true : false + perform_request(method, path, params, body, headers, request_opts).status == 200 ? true : false rescue Exception => e if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not\s*Found|404|ConnectionFailed/i false @@ -99,16 +100,14 @@ def msearch_body_helper <<~SRC case when body.is_a?(Array) && body.any? { |d| d.has_key? :search } - payload = body. - inject([]) do |sum, item| + payload = body.inject([]) do |sum, item| meta = item data = meta.delete(:search) sum << meta sum << data sum - end. - map { |item| Elasticsearch::API.serializer.dump(item) } + end.map { |item| Elasticsearch::API.serializer.dump(item) } payload << "" unless payload.empty? payload = payload.join("\\n") when body.is_a?(Array) @@ -136,11 +135,11 @@ def msearch_template_body_helper def bulk_body_helper <<~SRC - if body.is_a? Array - payload = Elasticsearch::API::Utils.__bulkify(body) - else - payload = body - end + payload = if body.is_a? Array + Elasticsearch::API::Utils.bulkify(body) + else + body + end SRC end @@ -151,7 +150,7 @@ def find_structure_body_helper def bulk_doc_helper(info) <<~SRC # @option arguments [String|Array] :body #{info}. Array of Strings, Header/Data pairs, - # or the conveniency "combined" format can be passed, refer to Elasticsearch::API::Utils.__bulkify documentation. + # or the conveniency "combined" format can be passed, refer to Elasticsearch::API::Utils.bulkify documentation. SRC end end diff --git a/elasticsearch-api/utils/thor/generate_source.rb b/elasticsearch-api/utils/thor/generate_source.rb index e9c40eb5f2..acdf8bb41d 100644 --- a/elasticsearch-api/utils/thor/generate_source.rb +++ b/elasticsearch-api/utils/thor/generate_source.rb @@ -22,8 +22,10 @@ require 'multi_json' require 'coderay' require 'pry' +require_relative 'generator/build_hash_helper' +require_relative 'generator/docs_helper' require_relative 'generator/files_helper' -require_relative 'generator/endpoint_specifics' +require_relative './endpoint_spec' module Elasticsearch module API @@ -41,20 +43,17 @@ class SourceGenerator < Thor namespace 'code' include Thor::Actions include EndpointSpecifics + include DocsHelper desc 'generate', 'Generate source code and tests from the REST API JSON specification' method_option :verbose, type: :boolean, default: false, desc: 'Output more information' method_option :tests, type: :boolean, default: false, desc: 'Generate test files' def generate - @build_hash = if ENV['BUILD_HASH'] - File.read(File.expand_path('../../../tmp/rest-api-spec/build_hash',__dir__)) - else - original_build_hash - end - + @build_hash = BuildHashHelper.build_hash self.class.source_root File.expand_path(__dir__) generate_source + # -- Tree output print_tree if options[:verbose] end @@ -62,234 +61,28 @@ def generate private def generate_source - @output = FilesHelper.output_dir - cleanup_directory! + output = FilesHelper.output_dir + cleanup_directory!(output) FilesHelper.files.each do |filepath| - @path = Pathname(filepath) - @json = MultiJson.load(File.read(@path)) - @spec = @json.values.first - say_status 'json', @path, :yellow - - @spec['url'] ||= {} - - @endpoint_name = @json.keys.first - @full_namespace = __full_namespace - @namespace_depth = @full_namespace.size > 0 ? @full_namespace.size - 1 : 0 - @module_namespace = @full_namespace[0, @namespace_depth] - + @spec = EndpointSpec.new(filepath) + say_status 'json', @spec.path, :yellow # Don't generate code for internal APIs: - next if @module_namespace.flatten.first == '_internal' - - @method_name = @full_namespace.last - @parts = __endpoint_parts - @params = @spec['params'] || {} - @specific_params = specific_params(@module_namespace.first) # See EndpointSpecifics - @http_method = __http_method - @paths = @spec['url']['paths'].map { |b| b['path'] } - # Using Ruby's safe operator on array: - @deprecation_note = @spec['url']['paths'].last&.[]('deprecated') - @http_path = __http_path - @required_parts = __required_parts - - @path_to_file = @output.join(@module_namespace.join('/')).join("#{@method_name}.rb") - dir = @output.join(@module_namespace.join('/')) + next if @spec.skippable? + path_to_file = output.join(@spec.module_namespace.join('/')).join("#{@spec.method_name}.rb") + dir = output.join(@spec.module_namespace.join('/')) empty_directory(dir, verbose: false) # Write the file with the ERB template: - template('templates/method.erb', @path_to_file, force: true) - - print_source_code(@path_to_file) if options[:verbose] + template('templates/method.erb', path_to_file, force: true) + # Optionals: + print_source_code(path_to_file) if options[:verbose] generate_tests if options[:tests] - - puts end - run_rubocop - add_hash - end - - def add_hash - Dir.glob("#{FilesHelper.output_dir}/**/*.rb").each do |file| - content = File.read(file) - new_content = content.gsub(/(^#\sunder\sthe\sLicense.\n#)/) do |_| - match = Regexp.last_match - "#{match[1]}\n#{build_hash_comment}" - end - File.open(file, 'w') { |f| f.puts new_content } - end - end - - def build_hash_comment - [ - "Auto generated from build hash #{@build_hash}", - '@see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec', - '' - ].map { |b| "# #{b}" }.join("\n").strip - end - - def original_build_hash - content = File.read("#{FilesHelper.output_dir}/info.rb") - return unless (match = content.match(/Auto generated from build hash ([a-f0-9]+)/)) - - match[1] - end - - def __full_namespace - names = @endpoint_name.split('.') - # Return an array to expand 'ccr', 'ilm', 'ml' and 'slm' - names.map do |name| - name - .gsub(/^ml$/, 'machine_learning') - .gsub(/^ilm$/, 'index_lifecycle_management') - .gsub(/^ccr/, 'cross_cluster_replication') - .gsub(/^slm/, 'snapshot_lifecycle_management') - end - end - - # Create the hierarchy of directories based on API namespaces - # - def __create_directories(key, value) - return if value['documentation'] - - empty_directory @output.join(key) - create_directory_hierarchy * value.to_a.first - end - - # Extract parts from each path - # - def __endpoint_parts - parts = @spec['url']['paths'].select do |a| - a.keys.include?('parts') - end.map do |path| - path&.[]('parts') - end - (parts.inject(&:merge) || []) - end - - def __http_method - return '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @endpoint_name == 'index' - return '_name ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @method_name == 'create_service_token' - return post_and_get if @endpoint_name == 'count' - - default_method = @spec['url']['paths'].map { |a| a['methods'] }.flatten.first - if @spec['body'] && default_method == 'GET' - # When default method is GET and body is required, we should always use POST - if @spec['body']['required'] - 'Elasticsearch::API::HTTP_POST' - else - post_and_get - end - else - "Elasticsearch::API::HTTP_#{default_method}" - end - end - - def post_and_get - # the METHOD is defined after doing arguments.delete(:body), so we need to check for `body` - <<~SRC - if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - SRC - end - - def __http_path - return "\"#{__parse_path(@paths.first)}\"" if @paths.size == 1 - - result = '' - anchor_string = [] - @paths.sort { |a, b| b.length <=> a.length }.each_with_index do |path, i| - var_string = __extract_path_variables(path).map { |var| "_#{var}" }.join(' && ') - next if anchor_string.include? var_string - - anchor_string << var_string - result += if i.zero? - "if #{var_string}\n" - elsif (i == @paths.size - 1) || var_string.empty? - "else\n" - else - "elsif #{var_string}\n" - end - result += "\"#{__parse_path(path)}\"\n" - end - result += 'end' - result - end - - def __parse_path(path) - path.gsub(/^\//, '') - .gsub(/\/$/, '') - .gsub('{', "\#{Utils.__listify(_") - .gsub('}', ')}') - end - - def __path_variables - @paths.map do |path| - __extract_path_variables(path) - end - end - - # extract values that are in the {var} format: - def __extract_path_variables(path) - path.scan(/{(\w+)}/).flatten - end - - # Find parts that are definitely required and should raise an error if - # they're not present - # - def __required_parts - required = [] - return required if @endpoint_name == 'tasks.get' - - required << 'body' if (@spec['body'] && @spec['body']['required']) - # Get required variables from paths: - req_variables = __path_variables.inject(:&) # find intersection - required << req_variables unless req_variables.empty? - required.flatten - end - - def docs_helper(name, info) - info['type'] = 'String' if info['type'] == 'enum' # Rename 'enums' to 'strings' - info['type'] = 'Integer' if info['type'] == 'int' # Rename 'int' to 'Integer' - tipo = info['type'] ? info['type'].capitalize : 'String' - description = info['description'] ? info['description'].strip : '[TODO]' - options = info['options'] ? "(options: #{info['options'].join(', ').strip})" : nil - required = info['required'] ? '(*Required*)' : '' - deprecated = info['deprecated'] ? '*Deprecated*' : '' - optionals = [required, deprecated, options].join(' ').strip - - "# @option arguments [#{tipo}] :#{name} #{description} #{optionals}\n" - end - - def stability_doc_helper(stability) - return if stability == 'stable' - - if stability == 'experimental' - <<~MSG - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - MSG - elsif stability == 'beta' - <<~MSG - # This functionality is in Beta and is subject to change. The design and - # code is less mature than official GA features and is being provided - # as-is with no warranties. Beta features are not subject to the support - # SLA of official GA features. - MSG - else - <<~MSG - # This functionality is subject to potential breaking changes within a - # minor version, meaning that your referencing code may break when this - # library is upgraded. - MSG - end + BuildHashHelper.add_hash(@build_hash) end def generate_tests @@ -319,15 +112,15 @@ def print_tree say_status('tree', lines.first + "\n" + lines[1, lines.size].map { |l| ' ' * 14 + l }.join("\n")) end - def cleanup_directory! - Dir["#{@output}/**/*.rb"].each do |file| + def cleanup_directory!(output) + Dir["#{output}/**/*.rb"].each do |file| # file = File.join(@output, f) File.delete(file) unless (['.', '..'].include? file) || Pathname(file).directory? end end def run_rubocop - system("rubocop -c ./thor/.rubocop.yml --format autogenconf -x #{FilesHelper::output_dir}") + system("rubocop -c ./thor/.rubocop.yml --format autogenconf -a #{FilesHelper::output_dir}") end end end diff --git a/elasticsearch-api/utils/thor/generator/build_hash_helper.rb b/elasticsearch-api/utils/thor/generator/build_hash_helper.rb new file mode 100644 index 0000000000..bd5d78b59f --- /dev/null +++ b/elasticsearch-api/utils/thor/generator/build_hash_helper.rb @@ -0,0 +1,64 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 Elasticsearch + module API + # Helper for the Elasticsearch build hash in source code docs + module BuildHashHelper + class << self + def build_hash + if ENV['BUILD_HASH'] + File.read(File.expand_path('../../../tmp/rest-api-spec/build_hash',__dir__)) + else + original_build_hash + end + end + + def add_hash(build_hash) + Dir.glob("#{FilesHelper.output_dir}/**/*.rb").each do |file| + content = File.read(file) + new_content = content.gsub(/(^#\sunder\sthe\sLicense.\n#)/) do |_| + match = Regexp.last_match + "#{match[1]}\n#{build_hash_comment(build_hash)}" + end + File.open(file, 'w') { |f| f.puts new_content } + end + end + + def build_hash_comment(build_hash) + [ + "Auto generated from build hash #{build_hash}", + '@see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec', + '' + ].map { |b| "# #{b}" }.join("\n").strip + end + + private + + def original_build_hash + content = File.read("#{FilesHelper.output_dir}/info.rb") + + return unless (match = content.match(/Auto generated from build hash ([a-f0-9]+)/)) + + match[1] + rescue + return 'Unavailable' + end + end + end + end +end diff --git a/elasticsearch-api/utils/thor/generator/docs_helper.rb b/elasticsearch-api/utils/thor/generator/docs_helper.rb new file mode 100644 index 0000000000..fc41b885da --- /dev/null +++ b/elasticsearch-api/utils/thor/generator/docs_helper.rb @@ -0,0 +1,62 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 Elasticsearch + module API + # Helper with file related methods for code generation + module DocsHelper + def docs(name, info) + info['type'] = 'String' if info['type'] == 'enum' # Rename 'enums' to 'strings' + info['type'] = 'Integer' if info['type'] == 'int' # Rename 'int' to 'Integer' + tipo = info['type'] ? info['type'].capitalize : 'String' + description = info['description'] ? info['description'].strip : '[TODO]' + options = info['options'] ? "(options: #{info['options'].join(', ').strip})" : nil + required = info['required'] ? '(*Required*)' : '' + deprecated = info['deprecated'] ? '*Deprecated*' : '' + optionals = [required, deprecated, options].join(' ').strip + + "# @option arguments [#{tipo}] :#{name} #{description} #{optionals}\n" + end + + def stability_doc_helper(stability) + return if stability == 'stable' + + if stability == 'experimental' + <<~MSG + # This functionality is Experimental and may be changed or removed + # completely in a future release. Elastic will take a best effort approach + # to fix any issues, but experimental features are not subject to the + # support SLA of official GA features. + MSG + elsif stability == 'beta' + <<~MSG + # This functionality is in Beta and is subject to change. The design and + # code is less mature than official GA features and is being provided + # as-is with no warranties. Beta features are not subject to the support + # SLA of official GA features. + MSG + else + <<~MSG + # This functionality is subject to potential breaking changes within a + # minor version, meaning that your referencing code may break when this + # library is upgraded. + MSG + end + end + end + end +end diff --git a/elasticsearch-api/utils/thor/generator/files_helper.rb b/elasticsearch-api/utils/thor/generator/files_helper.rb index 026a1246a6..be43abc960 100644 --- a/elasticsearch-api/utils/thor/generator/files_helper.rb +++ b/elasticsearch-api/utils/thor/generator/files_helper.rb @@ -22,37 +22,40 @@ module Elasticsearch module API # Helper with file related methods for code generation module FilesHelper + PROJECT_PATH = File.join(File.dirname(__FILE__), '..') SRC_PATH = File.join(PROJECT_PATH, '..', '..', '..', 'tmp/rest-api-spec/api/') OUTPUT_DIR = '../../elasticsearch-api/lib/elasticsearch/api/actions'.freeze TESTS_DIRECTORY = "#{PROJECT_PATH}/../../../tmp/rest-api-spec/test/free".freeze - # Only get JSON files and remove hidden files - def self.files - json_files = Dir.entries(SRC_PATH) + class << self + # Only get JSON files and remove hidden files + def files + json_files = Dir.entries(SRC_PATH) - json_files.reject do |file| - File.extname(file) != '.json' || - File.basename(file) == '_common.json' - end.map { |file| "#{SRC_PATH}#{file}" } - end + json_files.reject do |file| + File.extname(file) != '.json' || + File.basename(file) == '_common.json' + end.map { |file| "#{SRC_PATH}#{file}" } + end - # Path to directory to copy generated files - def self.output_dir - Pathname(OUTPUT_DIR) - end + # Path to directory to copy generated files + def output_dir + Pathname(OUTPUT_DIR) + end - def self.documentation_url(documentation_url) - branch = `git rev-parse --abbrev-ref HEAD` - return documentation_url.gsub(/\/(master|main)\//, "/current/") if branch == "main\n" + def documentation_url(documentation_url) + branch = `git rev-parse --abbrev-ref HEAD` + return documentation_url.gsub(/\/(master|main)\//, "/current/") if branch == "main\n" - regex = /([0-9]{1,2}\.[0-9x]{1,2})/ - version = Elasticsearch::API::VERSION.match(regex)[0] - # TODO - How do we fix this so it doesn't depend on which branch we're running from - if ENV['IGNORE_VERSION'] - documentation_url.gsub(/\/(master|main)\//, "/current/") - else - documentation_url.gsub(/\/(current|master|main)\//, "/#{version}/") + regex = /([0-9]{1,2}\.[0-9x]{1,2})/ + version = Elasticsearch::API::VERSION.match(regex)[0] + # TODO - How do we fix this so it doesn't depend on which branch we're running from + if ENV['IGNORE_VERSION'] + documentation_url.gsub(/\/(master|main)\//, "/current/") + else + documentation_url.gsub(/\/(current|master|main)\//, "/#{version}/") + end end end diff --git a/elasticsearch-api/utils/thor/templates/_body.erb b/elasticsearch-api/utils/thor/templates/_body.erb index 9ff997195e..458bebeae1 100644 --- a/elasticsearch-api/utils/thor/templates/_body.erb +++ b/elasticsearch-api/utils/thor/templates/_body.erb @@ -17,7 +17,7 @@ # under the License. %> <%- -case @endpoint_name +case @spec.endpoint_name when 'mtermvectors' -%> body = if(ids = arguments.delete(:ids)) @@ -28,7 +28,7 @@ when 'mtermvectors' <%- when 'cluster.reroute', 'cluster.put_settings' %> body = arguments.delete(:body) || {} <%- when 'ml.find_file_structure' %> - body = Utils.__bulkify(arguments.delete(:body)) + body = Utils.bulkify(arguments.delete(:body)) <%- else -%> - <%= ' '*(@namespace_depth+3) %>body = <%= @spec['body'].nil? ? 'nil' : 'arguments.delete(:body)' %> + body = <%= @spec.body.nil? ? 'nil' : 'arguments.delete(:body)' %> <%- end -%> diff --git a/elasticsearch-api/utils/thor/templates/_documentation_top.erb b/elasticsearch-api/utils/thor/templates/_documentation_top.erb index 5e1a856cc4..eb0e6822c2 100644 --- a/elasticsearch-api/utils/thor/templates/_documentation_top.erb +++ b/elasticsearch-api/utils/thor/templates/_documentation_top.erb @@ -16,42 +16,41 @@ # specific language governing permissions and limitations # under the License. %> -<%- if @spec['documentation']['description'] -%> - <%= ' '*(@namespace_depth+3) %># <%= @spec['documentation']['description'].gsub("\n", "\n#{' '*(@namespace_depth+3)}# ") -%> +<%- if @spec.documentation['description'] -%> + # <%= @spec.documentation['description'].gsub("\n", "\n # ") -%> <%- else %> - <%= ' '*(@namespace_depth+3) %># TODO: Description + # TODO: Description <%- end %> -<%= stability_doc_helper(@spec['stability']) -%> -<%= ' '*(@namespace_depth+3) %># -<%- unless @parts.nil? || @parts.empty? %><%# URL parts -%> - <%- @parts.each do |name, info| -%> - <%= docs_helper(name, info) -%> +<%= stability_doc_helper(@spec.stability) -%> +# +<%- unless @spec.path_parts.nil? || @spec.path_parts.empty? %><%# URL parts -%> + <%- @spec.path_parts.each do |name, info| -%> + <%= docs(name, info) -%> <%- end -%> <%- end -%><%# Body -%> <%# URL parameters -%> -<%- @params.each do |name, info| -%> - <%= docs_helper(name, info) unless (!@parts.empty? && @parts.keys.include?(name)) -%> +<%- @spec.params.each do |name, info| -%> + <%= docs(name, info) unless (!@spec.path_parts.empty? && @spec.path_parts.keys.include?(name)) -%> <%- end -%> # @option arguments [Hash] :headers Custom HTTP headers -<%- if @spec['body'] -%> - <%- if @method_name == 'bulk' -%> - <%= bulk_doc_helper(@spec['body']['description']) -%> +<%- if @spec.body -%> + <%- if @spec.method_name == 'bulk' -%> + <%= bulk_doc_helper(@spec.body['description']) -%> <%- else -%> - <%= ' '*(@namespace_depth+1) + - '# @option arguments [Hash] :body ' + (@spec['body']['description'] ? - @spec['body']['description'].strip : 'TODO: Description') + - (@spec['body']['required'] ? ' (*Required*)' : '') + "\n" + <%= '# @option arguments [Hash] :body ' + (@spec.body['description'] ? + @spec.body['description'].strip : 'TODO: Description') + + (@spec.body['required'] ? ' (*Required*)' : '') + "\n" -%> <%- end -%> <%- end -%> -<% if @deprecation_note -%> +<% if @spec.deprecation_note -%> # # *Deprecation notice*: - # <%= @deprecation_note['description'] %> - # Deprecated since version <%= @deprecation_note['version'] %> + # <%= @spec.deprecation_note['description'] %> + # Deprecated since version <%= @spec.deprecation_note['version'] %> # <% end -%> -<%= ' '*(@namespace_depth+3) -%># +# <%# Documentation link -%> -<%= ' '*(@namespace_depth+3) %># @see <%= @spec['documentation']['url'] ? Elasticsearch::API::FilesHelper.documentation_url(@spec['documentation']['url']) : "[TODO]" %> -<%= ' '*(@namespace_depth+3) %># +# @see <%= @spec.documentation['url'] ? Elasticsearch::API::FilesHelper.documentation_url(@spec.documentation['url']) : "[TODO]" %> +# diff --git a/elasticsearch-api/utils/thor/templates/_method_setup.erb b/elasticsearch-api/utils/thor/templates/_method_setup.erb index 96c174fbe8..0e4f14658e 100644 --- a/elasticsearch-api/utils/thor/templates/_method_setup.erb +++ b/elasticsearch-api/utils/thor/templates/_method_setup.erb @@ -16,22 +16,22 @@ # specific language governing permissions and limitations # under the License. %> -<%- @parts.each do |name, _| %> - <%- unless @method_name == 'get_field_mapping' && name == 'fields' %> - <%= ' '*(@namespace_depth+3) + "_#{name}" %> = arguments.delete(:<%=name %>) +<%- @spec.path_parts.each do |name, _| %> + <%- unless @spec.method_name == 'get_field_mapping' && name == 'fields' %> + <%= "_#{name}" %> = arguments.delete(:<%=name %>) <%- end -%> <%- end -%> -<%= ' '*(@namespace_depth+4) %>method = <%= @http_method %> -<%- if @method_name == 'termvectors' %> - endpoint = arguments.delete(:endpoint) || '_termvectors' +method = <%= @spec.http_method %> +<%- if @spec.method_name == 'termvectors' %> + arguments.delete(:endpoint) <%- end -%> -<%= ' '*(@namespace_depth+4) %>path = <%= @http_path %> -<%- if !@params.empty? || needs_ignore_404?(@endpoint_name) || needs_complex_ignore_404?(@endpoint_name)-%> - <%= ' '*(@namespace_depth+4) %>params = Utils.process_params(arguments) +path = <%= @spec.http_path %> +<%- if !@spec.params.empty? || needs_ignore_404?(@spec.endpoint_name) || needs_complex_ignore_404?(@spec.endpoint_name)-%> + params = Utils.process_params(arguments) <%- else -%> - <%= ' '*(@namespace_depth+4) %>params = {} + params = {} <%- end -%> -<%- @specific_params.each do |param| -%> +<%- @spec.specific_params.each do |param| -%> <%= param %> <%- end -%> diff --git a/elasticsearch-api/utils/thor/templates/_perform_request.erb b/elasticsearch-api/utils/thor/templates/_perform_request.erb index 0d874ce388..cfd50a9d99 100644 --- a/elasticsearch-api/utils/thor/templates/_perform_request.erb +++ b/elasticsearch-api/utils/thor/templates/_perform_request.erb @@ -16,35 +16,35 @@ # specific language governing permissions and limitations # under the License. %> -<%- if ['bulk', 'msearch', 'msearch_template', 'find_structure'].include? @method_name -%> - <%= self.send("#{@method_name}_body_helper".to_s) %> +<%- if ['bulk', 'msearch', 'msearch_template', 'find_structure'].include? @spec.method_name -%> + <%= self.send("#{@spec.method_name}_body_helper".to_s) %> headers.merge!("Content-Type" => "application/x-ndjson") Elasticsearch::API::Response.new( - perform_request(method, path, params, payload, headers) + perform_request(method, path, params, payload, headers, request_opts) ) -<%- elsif @method_name == 'ping' -%> +<%- elsif @spec.method_name == 'ping' -%> <%= ping_perform_request %> <%- else -%> - <%- if needs_ignore_404?(@endpoint_name) %> + <%- if needs_ignore_404?(@spec.endpoint_name) %> Utils.__rescue_from_not_found do - perform_request(method, path, params, body, headers).status == 200 ? true : false + perform_request(method, path, params, body, headers, request_opts).status == 200 ? true : false end - <%- elsif needs_complex_ignore_404?(@endpoint_name) -%> + <%- elsif needs_complex_ignore_404?(@spec.endpoint_name) -%> if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found { Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) } else Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end <%- else -%> Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) <%- end -%> <%- end -%> -<%= ' '*(@namespace_depth+3) %>end +end diff --git a/elasticsearch-api/utils/thor/templates/method.erb b/elasticsearch-api/utils/thor/templates/method.erb index ee56e4f303..5a2a121d24 100644 --- a/elasticsearch-api/utils/thor/templates/method.erb +++ b/elasticsearch-api/utils/thor/templates/method.erb @@ -16,29 +16,38 @@ # under the License. # module Elasticsearch -<%= ' '*(@namespace_depth) %>module API -<%- @module_namespace.each_with_index do |name, i| -%> +module API +<%- @spec.module_namespace.each_with_index do |name, i| -%> <%= ' '*i %>module <%= module_name_helper(name) %> <%- end -%> -<%= ' '*(@namespace_depth+2) %>module Actions +module Actions <%= ERB.new(File.new("./thor/templates/_documentation_top.erb").read, trim_mode: '-').result(binding) -%> <%# Method definition -%> -<%= ' '*(@namespace_depth+3) -%>def <%= @method_name %>(arguments = {}) -<%- if @endpoint_name == 'create' -%> - <%= ' '*(@namespace_depth+3) %>if arguments[:id] - <%= ' '*(@namespace_depth+3) %> index arguments.update op_type: 'create' - <%= ' '*(@namespace_depth+3) %>else - <%= ' '*(@namespace_depth+3) %> index arguments - <%= ' '*(@namespace_depth+3) %>end - <%= ' '*(@namespace_depth+2) %>end +def <%= @spec.method_name %>(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || "<%= @spec.endpoint_name %>" } +<%- unless @spec.path_params.empty? %> + defined_params =<%= @spec.path_params %>.inject({}) do |set_variables, variable| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + set_variables + end + request_opts[:defined_params] = defined_params unless defined_params.empty? +<%- end %> +<%- %> +<%- if @spec.endpoint_name == 'create' -%> +if arguments[:id] + index arguments.update op_type: 'create' +else + index arguments +end +end <%- else -%> - <%- if @method_name == 'get_field_mapping' %> + <%- if @spec.method_name == 'get_field_mapping' %> arguments = arguments.clone _fields = arguments.delete(:field) || arguments.delete(:fields) raise ArgumentError, "Required argument 'field' missing" unless _fields <%- else -%> - <%- @required_parts.each do |required| %><%# Arguments -%> - <%= ' '*(@namespace_depth+3) + "raise ArgumentError, \"Required argument '#{required}' missing\" unless arguments[:#{required}]" + "\n" -%> + <%- @spec.required_parts.each do |required| %><%# Arguments -%> + <%= "raise ArgumentError, \"Required argument '#{required}' missing\" unless arguments[:#{required}]" + "\n" -%> <%- end -%> arguments = arguments.clone <%- end -%> @@ -50,21 +59,21 @@ module Elasticsearch <%- # Perform request -%> <%= ERB.new(File.new("./thor/templates/_perform_request.erb").read, trim_mode: '-').result(binding) %> <%- end -%> -<%- if @method_name.match?(/^exists\S*/) -%> - alias_method :<%= @method_name %>?, :<%= @method_name %> +<%- if @spec.method_name.match?(/^exists\S*/) -%> + alias_method :<%= @spec.method_name %>?, :<%= @spec.method_name %> <%- end -%> -<%- if @method_name == 'termvectors' %> - +<%- if @spec.method_name == 'termvectors' %> # Deprecated: Use the plural version, {#termvectors} # def termvector(arguments={}) - termvectors(arguments.merge endpoint: '_termvector') + warn "[DEPRECATION] `termvector` is deprecated. Please use the plural version, `termvectors` instead." + termvectors(arguments.merge(endpoint: '_termvector')) end <%- end -%> +<%- @spec.namespace_depth.downto(1) do |i| -%> + <%= ' '*(i-1) %>end +<%- end if @spec.namespace_depth > 0 -%> -<%- @namespace_depth.downto(1) do |i| -%> -<%= ' '*(i-1) %>end -<%- end if @namespace_depth > 0 -%> end end end diff --git a/elasticsearch/Gemfile b/elasticsearch/Gemfile index 425340324f..21c38fe230 100644 --- a/elasticsearch/Gemfile +++ b/elasticsearch/Gemfile @@ -25,3 +25,9 @@ gemspec if File.exist? File.expand_path('../elasticsearch-api/elasticsearch-api.gemspec', __dir__) gem 'elasticsearch-api', path: File.expand_path('../elasticsearch-api', __dir__), require: false end + +if ENV['TRANSPORT_VERSION'] == 'main' + gem 'elastic-transport', git: 'https://github.com/elastic/elastic-transport-ruby.git', branch: 'main' +end + +gem 'opentelemetry-sdk', require: false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0') diff --git a/elasticsearch/elasticsearch.gemspec b/elasticsearch/elasticsearch.gemspec index 56a200a035..563638b546 100644 --- a/elasticsearch/elasticsearch.gemspec +++ b/elasticsearch/elasticsearch.gemspec @@ -15,15 +15,15 @@ # specific language governing permissions and limitations # under the License. -lib = File.expand_path('../lib', __FILE__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'elasticsearch/version' Gem::Specification.new do |s| s.name = 'elasticsearch' s.version = Elasticsearch::VERSION - s.authors = ['Karel Minarik', 'Emily Stolfo', 'Fernando Briano'] - s.email = ['clients-team@elastic.co'] + s.authors = ['Elastic Client Library Maintainers'] + s.email = ['client-libs@elastic.co'] s.summary = 'Ruby integrations for Elasticsearch' s.homepage = 'https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html' s.license = 'Apache-2.0' @@ -33,23 +33,26 @@ Gem::Specification.new do |s| 'source_code_uri' => 'https://github.com/elastic/elasticsearch-ruby/tree/main', 'bug_tracker_uri' => 'https://github.com/elastic/elasticsearch-ruby/issues' } - s.files = `git ls-files`.split($/) + s.files = `git ls-files`.split($/).reject do |file| + file.match(/^spec\/|^Gemfile|^Rakefile/) + end + s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } s.executables << 'elastic_ruby_console' - s.test_files = s.files.grep(%r{^(test|spec|features)/}) s.require_paths = ['lib'] s.bindir = 'bin' s.extra_rdoc_files = ['README.md', 'LICENSE.txt'] s.rdoc_options = ['--charset=UTF-8'] - s.required_ruby_version = '>= 2.5' - - s.add_dependency 'elastic-transport', '~> 8' - s.add_dependency 'elasticsearch-api', '8.10.0' + s.required_ruby_version = '>= 2.6' # For compatibility with JRuby 9.3 + s.add_dependency 'elasticsearch-api', '9.0.0' + s.add_dependency 'elastic-transport', '~> 8.3' + s.add_development_dependency 'base64' s.add_development_dependency 'bundler' - s.add_development_dependency 'byebug' unless defined?(JRUBY_VERSION) || defined?(Rubinius) + s.add_development_dependency 'debug' unless defined?(JRUBY_VERSION) + s.add_development_dependency 'ostruct' s.add_development_dependency 'pry' s.add_development_dependency 'rake' s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius) diff --git a/elasticsearch/lib/elasticsearch.rb b/elasticsearch/lib/elasticsearch.rb index 229f198394..3e55285ad9 100644 --- a/elasticsearch/lib/elasticsearch.rb +++ b/elasticsearch/lib/elasticsearch.rb @@ -37,8 +37,9 @@ class Client # # @param [Hash] arguments - initializer arguments # @option arguments [String] :cloud_id - The Cloud ID to connect to Elastic Cloud - # @option arguments [String, Hash] :api_key Use API Key Authentication, either the base64 encoding of `id` and `api_key` - # joined by a colon as a String, or a hash with the `id` and `api_key` values. + # @option arguments [String, Hash] :api_key Use API Key Authentication, either the base64 encoding of `id` and + # `api_key` joined by a colon as a String, or a hash with the `id` and + # `api_key` values. # @option arguments [String] :opaque_id_prefix set a prefix for X-Opaque-Id when initializing the client. # This will be prepended to the id you set before each request # if you're using X-Opaque-Id @@ -51,6 +52,7 @@ def initialize(arguments = {}, &block) api_key(arguments) if arguments[:api_key] setup_cloud(arguments) if arguments[:cloud_id] set_user_agent!(arguments) unless sent_user_agent?(arguments) + set_content_type!(arguments) @transport = Elastic::Transport::Client.new(arguments, &block) end @@ -59,16 +61,16 @@ def method_missing(name, *args, &block) super elsif name == :perform_request # The signature for perform_request is: - # method, path, params, body, headers + # method, path, params, body, headers, opts if (opaque_id = args[2]&.delete(:opaque_id)) headers = args[4] || {} opaque_id = @opaque_id_prefix ? "#{@opaque_id_prefix}#{opaque_id}" : opaque_id args[4] = headers.merge('X-Opaque-Id' => opaque_id) end - unless @verified - verify_elasticsearch(*args, &block) - else + if @verified @transport.perform_request(*args, &block) + else + verify_elasticsearch(*args, &block) end else @transport.send(name, *args, &block) @@ -101,13 +103,15 @@ def verify_elasticsearch(*args, &block) raise e end raise Elasticsearch::UnsupportedProductError unless response.headers['x-elastic-product'] == 'Elasticsearch' + @verified = true response end def setup_cloud_host(cloud_id, user, password, port) name = cloud_id.split(':')[0] - cloud_url, elasticsearch_instance = Base64.decode64(cloud_id.gsub("#{name}:", '')).split('$') + base64_decoded = cloud_id.gsub("#{name}:", '').unpack1('m') + cloud_url, elasticsearch_instance = base64_decoded.split('$') if cloud_url.include?(':') url, port = cloud_url.split(':') @@ -149,7 +153,8 @@ def setup_cloud(arguments) # Credentials is the base64 encoding of id and api_key joined by a colon # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html def encode(api_key) - Base64.strict_encode64([api_key[:id], api_key[:api_key]].join(':')) + credentials = [api_key[:id], api_key[:api_key]].join(':') + [credentials].pack('m0') end def elasticsearch_validation_request @@ -158,6 +163,7 @@ def elasticsearch_validation_request def sent_user_agent?(arguments) return unless (headers = arguments&.[](:transport_options)&.[](:headers)) + !!headers.keys.detect { |h| h =~ /user-?_?agent/ } end @@ -170,9 +176,21 @@ def set_user_agent!(arguments) if RbConfig::CONFIG && RbConfig::CONFIG['host_os'] user_agent << "#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase} #{RbConfig::CONFIG['target_cpu']}" end + set_header({ user_agent: user_agent.join('; ') }, arguments) + end + + def set_content_type!(arguments) + headers = { + 'content-type' => 'application/vnd.elasticsearch+json; compatible-with=9', + 'accept' => 'application/vnd.elasticsearch+json; compatible-with=9' + } + set_header(headers, arguments) + end + + def set_header(header, arguments) arguments[:transport_options] ||= {} arguments[:transport_options][:headers] ||= {} - arguments[:transport_options][:headers].merge!({ user_agent: user_agent.join('; ')}) + arguments[:transport_options][:headers].merge!(header) end end diff --git a/elasticsearch/lib/elasticsearch/helpers/bulk_helper.rb b/elasticsearch/lib/elasticsearch/helpers/bulk_helper.rb index 80c906c38f..e5982eccb7 100644 --- a/elasticsearch/lib/elasticsearch/helpers/bulk_helper.rb +++ b/elasticsearch/lib/elasticsearch/helpers/bulk_helper.rb @@ -48,7 +48,9 @@ def initialize(client, index, params = {}) def ingest(docs, params = {}, body = {}, &block) ingest_docs = docs.map { |doc| { index: { _index: @index, data: doc} } } if (slice = params.delete(:slice)) - ingest_docs.each_slice(slice) { |items| ingest(items, params, &block) } + ingest_docs.each_slice(slice) do |items| + ingest(items.map { |item| item[:index][:data] }, params, &block) + end else bulk_request(ingest_docs, params, &block) end diff --git a/elasticsearch/lib/elasticsearch/helpers/esql_helper.rb b/elasticsearch/lib/elasticsearch/helpers/esql_helper.rb new file mode 100644 index 0000000000..e8d3d8cbf8 --- /dev/null +++ b/elasticsearch/lib/elasticsearch/helpers/esql_helper.rb @@ -0,0 +1,72 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 Elasticsearch + module Helpers + # Elasticsearch Client Helper for the ES|QL API + # + # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-query-api.html + # + module ESQLHelper + # Query helper for ES|QL + # + # By default, the `esql.query` API returns a Hash response with the following keys: + # + # * `columns` with the value being an Array of `{ name: type }` Hashes for each column. + # + # * `values` with the value being an Array of Arrays with the values for each row. + # + # This helper function returns an Array of hashes with the columns as keys and the respective + # values: `{ column['name'] => value }`. + # + # @param client [Elasticsearch::Client] an instance of the Client to use for the query. + # @param query [Hash, String] The query to be passed to the ES|QL query API. + # @param params [Hash] options to pass to the ES|QL query API. + # @param parser [Hash] Hash of column name keys and Proc values to transform the value of + # a given column. + # @example Using the ES|QL helper + # require 'elasticsearch/helpers/esql_helper' + # query = <<~ESQL + # FROM sample_data + # | EVAL duration_ms = ROUND(event.duration / 1000000.0, 1) + # ESQL + # response = Elasticsearch::Helpers::ESQLHelper.query(client, query) + # + # @example Using the ES|QL helper with a parser + # response = Elasticsearch::Helpers::ESQLHelper.query( + # client, + # query, + # parser: { '@timestamp' => Proc.new { |t| DateTime.parse(t) } } + # ) + # + # @see https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/Helpers.html#_esql_helper + # + def self.query(client, query, params = {}, parser: {}) + response = client.esql.query({ body: { query: query }, format: 'json' }.merge(params)) + + columns = response['columns'] + response['values'].map do |value| + (value.length - 1).downto(0).map do |index| + key = columns[index]['name'] + value[index] = parser[key].call(value[index]) if value[index] && parser[key] + { key => value[index] } + end.reduce({}, :merge) + end + end + end + end +end diff --git a/elasticsearch/lib/elasticsearch/helpers/scroll_helper.rb b/elasticsearch/lib/elasticsearch/helpers/scroll_helper.rb index 747750cfa6..ead41314ac 100644 --- a/elasticsearch/lib/elasticsearch/helpers/scroll_helper.rb +++ b/elasticsearch/lib/elasticsearch/helpers/scroll_helper.rb @@ -43,12 +43,8 @@ def initialize(client, index, body, scroll = '1m') # @yieldparam document [Hash] yields a document found in the search hits. # def each(&block) - @docs = [] - @scroll_id = nil - refresh_docs - for doc in @docs do - refresh_docs - yield doc + until (docs = results).empty? + docs.each(&block) end clear end @@ -70,17 +66,11 @@ def results # def clear @client.clear_scroll(body: { scroll_id: @scroll_id }) if @scroll_id - @docs = [] + @scroll_id = nil end private - def refresh_docs - @docs ||= [] - @docs << results - @docs.flatten! - end - def initial_search response = @client.search(index: @index, scroll: @scroll, body: @body) @scroll_id = response['_scroll_id'] @@ -88,7 +78,7 @@ def initial_search end def scroll_request - @client.scroll(body: {scroll: @scroll, scroll_id: @scroll_id})['hits']['hits'] + @client.scroll(body: { scroll: @scroll, scroll_id: @scroll_id })['hits']['hits'] end end end diff --git a/elasticsearch/lib/elasticsearch/version.rb b/elasticsearch/lib/elasticsearch/version.rb index d4df1c59f8..33758a0941 100644 --- a/elasticsearch/lib/elasticsearch/version.rb +++ b/elasticsearch/lib/elasticsearch/version.rb @@ -16,5 +16,5 @@ # under the License. module Elasticsearch - VERSION = '8.10.0'.freeze + VERSION = '9.0.0'.freeze end diff --git a/elasticsearch/spec/integration/characters_escaping_spec.rb b/elasticsearch/spec/integration/characters_escaping_spec.rb index 7241bf1f24..4cd080f142 100644 --- a/elasticsearch/spec/integration/characters_escaping_spec.rb +++ b/elasticsearch/spec/integration/characters_escaping_spec.rb @@ -14,43 +14,39 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}" -raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ require 'spec_helper' +require 'uri' -context 'Elasticsearch client' do - let(:client) do - Elasticsearch::Client.new(host: ELASTICSEARCH_URL, user: 'elastic', password: 'changeme') - end +context 'Elasticsearch CLIENT' do let(:index) { 'tvs' } after do - client.indices.delete(index: index) + CLIENT.indices.delete(index: index) end context 'escaping spaces in ids' do it 'escapes spaces for id when using index' do - response = client.index(index: index, id: 'a test 1', body: { name: 'A test 1' }, refresh: true) + response = CLIENT.index(index: index, id: 'a test 1', body: { name: 'A test 1' }, refresh: true) expect(response.body['_id']).to eq 'a test 1' - response = client.search(index: index) + response = CLIENT.search(index: index) expect(response.body['hits']['hits'].first['_id']).to eq 'a test 1' # Raises exception, _id is unrecognized expect do - client.index(index: index, _id: 'a test 2', body: { name: 'A test 2' }) + CLIENT.index(index: index, _id: 'a test 2', body: { name: 'A test 2' }) end.to raise_exception Elastic::Transport::Transport::Errors::BadRequest # Raises exception, id is a query parameter expect do - client.index(index: index, body: { name: 'A test 3', _id: 'a test 3' }) + CLIENT.index(index: index, body: { name: 'A test 3', _id: 'a test 3' }) end.to raise_exception Elastic::Transport::Transport::Errors::BadRequest end it 'escapes spaces for id when using create' do # Works with create - response = client.create(index: index, id: 'a test 4', body: { name: 'A test 4' }) + response = CLIENT.create(index: index, id: 'a test 4', body: { name: 'A test 4' }) expect(response.body['_id']).to eq 'a test 4' end @@ -58,9 +54,9 @@ body = [ { create: { _index: index, _id: 'a test 5', data: { name: 'A test 5' } } } ] - expect(client.bulk(body: body, refresh: true).status).to eq 200 + expect(CLIENT.bulk(body: body, refresh: true).status).to eq 200 - response = client.search(index: index) + response = CLIENT.search(index: index) expect( response.body['hits']['hits'].select { |a| a['_id'] == 'a test 5' }.size ).to eq 1 @@ -69,13 +65,13 @@ context 'it doesnae escape plus signs in id' do it 'escapes spaces for id when using index' do - response = client.index(index: index, id: 'a+test+1', body: { name: 'A test 1' }) + response = CLIENT.index(index: index, id: 'a+test+1', body: { name: 'A test 1' }) expect(response.body['_id']).to eq 'a+test+1' end it 'escapes spaces for id when using create' do # Works with create - response = client.create(index: index, id: 'a+test+2', body: { name: 'A test 2' }) + response = CLIENT.create(index: index, id: 'a+test+2', body: { name: 'A test 2' }) expect(response.body['_id']).to eq 'a+test+2' end @@ -83,9 +79,9 @@ body = [ { create: { _index: index, _id: 'a+test+3', data: { name: 'A test 3' } } } ] - expect(client.bulk(body: body, refresh: true).status).to eq 200 + expect(CLIENT.bulk(body: body, refresh: true).status).to eq 200 - response = client.search(index: index) + response = CLIENT.search(index: index) expect( response.body['hits']['hits'].select { |a| a['_id'] == 'a+test+3' }.size ).to eq 1 diff --git a/elasticsearch/spec/integration/client_integration_spec.rb b/elasticsearch/spec/integration/client_integration_spec.rb index d8ff72a288..967ae0616d 100644 --- a/elasticsearch/spec/integration/client_integration_spec.rb +++ b/elasticsearch/spec/integration/client_integration_spec.rb @@ -19,43 +19,35 @@ require 'spec_helper' require 'logger' +require 'uri' context 'Elasticsearch client' do let(:logger) { Logger.new($stderr) } - let(:client) do - Elasticsearch::Client.new( - host: ELASTICSEARCH_URL, - logger: logger, - user: 'elastic', - password: 'changeme' - ) - end - context 'Integrates with elasticsearch API' do it 'should perform the API methods' do expect do # Index a document - client.index(index: 'test-index', id: '1', body: { title: 'Test' }) + CLIENT.index(index: 'test-index', id: '1', body: { title: 'Test' }) # Refresh the index - client.indices.refresh(index: 'test-index') + CLIENT.indices.refresh(index: 'test-index') # Search - response = client.search(index: 'test-index', body: { query: { match: { title: 'test' } } }) + response = CLIENT.search(index: 'test-index', body: { query: { match: { title: 'test' } } }) expect(response['hits']['total']['value']).to eq 1 expect(response['hits']['hits'][0]['_source']['title']).to eq 'Test' # Delete the index - client.indices.delete(index: 'test-index') + CLIENT.indices.delete(index: 'test-index') end.not_to raise_error end end context 'Reports the right meta header' do - it 'Reports es service name and gem versio' do - headers = client.transport.connections.first.connection.headers + it 'Reports es service name and gem version' do + headers = CLIENT.transport.connections.first.connection.headers version = Class.new.extend(Elastic::Transport::MetaHeader).send(:client_meta_version, Elasticsearch::VERSION) expect(headers['x-elastic-client-meta']).to match /^es=#{version}/ end diff --git a/elasticsearch/spec/integration/helpers/bulk_helper_spec.rb b/elasticsearch/spec/integration/helpers/bulk_helper_spec.rb index 26a8ec465c..1633a12ce2 100644 --- a/elasticsearch/spec/integration/helpers/bulk_helper_spec.rb +++ b/elasticsearch/spec/integration/helpers/bulk_helper_spec.rb @@ -14,42 +14,34 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}" -raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ - +require_relative File.expand_path('../../spec_helper', __dir__) require 'elasticsearch/helpers/bulk_helper' -require 'spec_helper' require 'tempfile' context 'Elasticsearch client helpers' do context 'Bulk helper' do - let(:client) do - Elasticsearch::Client.new( - host: ELASTICSEARCH_URL, - user: 'elastic', - password: 'changeme' - ) - end let(:index) { 'bulk_animals' } + let(:index_slice) { 'bulk_animals_slice' } let(:params) { { refresh: 'wait_for' } } - let(:bulk_helper) { Elasticsearch::Helpers::BulkHelper.new(client, index, params) } + let(:bulk_helper) { Elasticsearch::Helpers::BulkHelper.new(CLIENT, index, params) } let(:docs) do [ - { scientific_name: 'Lama guanicoe', name:'Guanaco' }, - { scientific_name: 'Tayassu pecari', name:'White-lipped peccary' }, - { scientific_name: 'Snycerus caffer', name:'Buffalo, african' }, - { scientific_name: 'Coluber constrictor', name:'Snake, racer' }, - { scientific_name: 'Thalasseus maximus', name:'Royal tern' }, - { scientific_name: 'Centrocercus urophasianus', name:'Hen, sage' }, - { scientific_name: 'Sitta canadensis', name:'Nuthatch, red-breasted' }, - { scientific_name: 'Aegypius tracheliotus', name:'Vulture, lappet-faced' }, - { scientific_name: 'Bucephala clangula', name:'Common goldeneye' }, - { scientific_name: 'Felis pardalis', name:'Ocelot' } + { scientific_name: 'Lama guanicoe', name: 'Guanaco' }, + { scientific_name: 'Tayassu pecari', name: 'White-lipped peccary' }, + { scientific_name: 'Snycerus caffer', name: 'Buffalo, african' }, + { scientific_name: 'Coluber constrictor', name: 'Snake, racer' }, + { scientific_name: 'Thalasseus maximus', name: 'Royal tern' }, + { scientific_name: 'Centrocercus urophasianus', name: 'Hen, sage' }, + { scientific_name: 'Sitta canadensis', name: 'Nuthatch, red-breasted' }, + { scientific_name: 'Aegypius tracheliotus', name: 'Vulture, lappet-faced' }, + { scientific_name: 'Bucephala clangula', name: 'Common goldeneye' }, + { scientific_name: 'Felis pardalis', name: 'Ocelot' } ] end after do - client.indices.delete(index: index, ignore: 404) + CLIENT.indices.delete(index: index, ignore: 404) + CLIENT.indices.delete(index: index_slice, ignore: 404) end it 'Ingests documents' do @@ -66,9 +58,9 @@ ] bulk_helper.ingest(docs) # Get the ingested documents, add id and modify them to update them: - animals = client.search(index: index)['hits']['hits'] + animals = CLIENT.search(index: index)['hits']['hits'] # Add id to each doc - docs = animals.map { |animal| animal['_source'].merge({'id' => animal['_id'] }) } + docs = animals.map { |animal| animal['_source'].merge({ 'id' => animal['_id'] }) } docs.map { |doc| doc['scientific_name'].upcase! } response = bulk_helper.update(docs) expect(response.status).to eq(200) @@ -81,15 +73,18 @@ response = bulk_helper.delete(ids) expect(response.status).to eq 200 expect(response['items'].map { |item| item['delete']['result'] }.uniq.first).to eq('deleted') - expect(client.count(index: index)['count']).to eq(0) + expect(CLIENT.count(index: index)['count']).to eq(0) end it 'Ingests documents and yields response and docs' do slice = 2 - response = bulk_helper.ingest(docs, {slice: slice}) do |response, docs| + bulk_helper = Elasticsearch::Helpers::BulkHelper.new(CLIENT, index_slice, params) + bulk_helper.ingest(docs, { slice: slice }) do |response, docs| expect(response).to be_an_instance_of Elasticsearch::API::Response expect(docs.count).to eq slice end + response = CLIENT.search(index: index_slice, size: 200) + expect(response['hits']['hits'].map { |a| a['_source'].transform_keys(&:to_sym) }).to eq docs end context 'JSON File helper' do diff --git a/elasticsearch/spec/integration/helpers/esql_helper_spec.rb b/elasticsearch/spec/integration/helpers/esql_helper_spec.rb new file mode 100644 index 0000000000..ed8dde04ba --- /dev/null +++ b/elasticsearch/spec/integration/helpers/esql_helper_spec.rb @@ -0,0 +1,125 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 File.expand_path('../../spec_helper', __dir__) +require 'elasticsearch/helpers/esql_helper' +require 'ipaddr' + +context 'Elasticsearch client helpers' do + let(:index) { 'esql_helper_test' } + let(:body) { { size: 12, query: { match_all: {} } } } + let(:esql_helper) { Elasticsearch::Helpers::ESQLHelper } + let(:query) do + <<~ESQL + FROM #{index} + | EVAL duration_ms = ROUND(event.duration / 1000000.0, 1) + ESQL + end + + before do + CLIENT.indices.create( + index: index, + body: { + mappings: { + properties: { 'client.ip' => { type: 'ip' }, message: { type: 'keyword' } } + } + } + ) + CLIENT.bulk( + index: index, + body: [ + { 'index': {} }, + { '@timestamp' => '2023-10-23T12:15:03.360Z', 'client.ip' => '172.21.2.162', message: 'Connected to 10.1.0.3', + 'event.duration' => 3_450_233 }, + { 'index': {} }, + { '@timestamp' => '2023-10-23T12:27:28.948Z', 'client.ip' => '172.21.2.113', message: 'Connected to 10.1.0.2', + 'event.duration' => 2_764_889 }, + { 'index': {} }, + { '@timestamp' => '2023-10-23T13:33:34.937Z', 'client.ip' => '172.21.0.5', message: 'Disconnected', + 'event.duration' => 1_232_382 }, + { 'index': {} }, + { '@timestamp' => '2023-10-23T13:51:54.732Z', 'client.ip' => '172.21.3.15', message: 'Connection error', + 'event.duration' => 725_448 }, + { 'index': {} }, + { '@timestamp' => '2023-10-23T13:52:55.015Z', 'client.ip' => '172.21.3.15', message: 'Connection error', + 'event.duration' => 8_268_153 }, + { 'index': {} }, + { '@timestamp' => '2023-10-23T13:53:55.832Z', 'client.ip' => '172.21.3.15', message: 'Connection error', + 'event.duration' => 5_033_755 }, + { 'index': {} }, + { '@timestamp' => '2023-10-23T13:55:01.543Z', 'client.ip' => '172.21.3.15', message: 'Connected to 10.1.0.1', + 'event.duration' => 1_756_467 } + ], + refresh: true + ) + end + + after do + CLIENT.indices.delete(index: index) + end + + it 'returns an ESQL response as a relational key/value object' do + response = esql_helper.query(CLIENT, query) + expect(response.count).to eq 7 + expect(response.first.keys).to eq ['duration_ms', 'message', 'event.duration', 'client.ip', '@timestamp'] + response.each do |r| + expect(r['@timestamp']).to be_a String + expect(r['client.ip']).to be_a String + expect(r['message']).to be_a String + expect(r['event.duration']).to be_a Integer + end + end + + it 'parses iterated objects when procs are passed in' do + parser = { + '@timestamp' => Proc.new { |t| DateTime.parse(t) }, + 'client.ip' => Proc.new { |i| IPAddr.new(i) }, + 'event.duration' => Proc.new { |d| d.to_s } + } + response = esql_helper.query(CLIENT, query, parser: parser) + response.each do |r| + expect(r['@timestamp']).to be_a DateTime + expect(r['client.ip']).to be_a IPAddr + expect(r['message']).to be_a String + expect(r['event.duration']).to be_a String + end + end + + it 'parser does not error when value is nil, leaves nil' do + CLIENT.index( + index: index, + body: { + '@timestamp' => nil, + 'client.ip' => nil, + message: 'Connected to 10.1.0.1', + 'event.duration' => 1756465 + }, + refresh: true + ) + parser = { + '@timestamp' => Proc.new { |t| DateTime.parse(t) }, + 'client.ip' => Proc.new { |i| IPAddr.new(i) }, + 'event.duration' => Proc.new { |d| d.to_s } + } + response = esql_helper.query(CLIENT, query, parser: parser) + response.each do |r| + expect [DateTime, NilClass].include?(r['@timestamp'].class) + expect [IPAddr, NilClass].include?(r['client.ip'].class) + expect(r['message']).to be_a String + expect(r['event.duration']).to be_a String + end + end +end diff --git a/elasticsearch/spec/integration/helpers/scroll_helper_spec.rb b/elasticsearch/spec/integration/helpers/scroll_helper_spec.rb index caa18d0f74..7407480f06 100644 --- a/elasticsearch/spec/integration/helpers/scroll_helper_spec.rb +++ b/elasticsearch/spec/integration/helpers/scroll_helper_spec.rb @@ -14,78 +14,70 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}" -raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ - -require 'spec_helper' +require_relative File.expand_path('../../spec_helper', __dir__) require 'elasticsearch/helpers/scroll_helper' context 'Elasticsearch client helpers' do - let(:client) do - Elasticsearch::Client.new( - host: ELASTICSEARCH_URL, - user: 'elastic', - password: 'changeme' - ) - end - let(:index) { 'books' } - let(:body) { { size: 12, query: { match_all: {} } } } - let(:scroll_helper) { Elasticsearch::Helpers::ScrollHelper.new(client, index, body) } - - before do - documents = [ - { index: { _index: index, data: {name: "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561} } }, - { index: { _index: index, data: {name: "Hyperion", "author": "Dan Simmons", "release_date": "1989-05-26", "page_count": 482} } }, - { index: { _index: index, data: {name: "Dune", "author": "Frank Herbert", "release_date": "1965-06-01", "page_count": 604} } }, - { index: { _index: index, data: {name: "Dune Messiah", "author": "Frank Herbert", "release_date": "1969-10-15", "page_count": 331} } }, - { index: { _index: index, data: {name: "Children of Dune", "author": "Frank Herbert", "release_date": "1976-04-21", "page_count": 408} } }, - { index: { _index: index, data: {name: "God Emperor of Dune", "author": "Frank Herbert", "release_date": "1981-05-28", "page_count": 454} } }, - { index: { _index: index, data: {name: "Consider Phlebas", "author": "Iain M. Banks", "release_date": "1987-04-23", "page_count": 471} } }, - { index: { _index: index, data: {name: "Pandora's Star", "author": "Peter F. Hamilton", "release_date": "2004-03-02", "page_count": 768} } }, - { index: { _index: index, data: {name: "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585} } }, - { index: { _index: index, data: {name: "A Fire Upon the Deep", "author": "Vernor Vinge", "release_date": "1992-06-01", "page_count": 613} } }, - { index: { _index: index, data: {name: "Ender's Game", "author": "Orson Scott Card", "release_date": "1985-06-01", "page_count": 324} } }, - { index: { _index: index, data: {name: "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328} } }, - { index: { _index: index, data: {name: "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227} } }, - { index: { _index: index, data: {name: "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268} } }, - { index: { _index: index, data: {name: "Foundation", "author": "Isaac Asimov", "release_date": "1951-06-01", "page_count": 224} } }, - { index: { _index: index, data: {name: "The Giver", "author": "Lois Lowry", "release_date": "1993-04-26", "page_count": 208} } }, - { index: { _index: index, data: {name: "Slaughterhouse-Five", "author": "Kurt Vonnegut", "release_date": "1969-06-01", "page_count": 275} } }, - { index: { _index: index, data: {name: "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "release_date": "1979-10-12", "page_count": 180} } }, - { index: { _index: index, data: {name: "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470} } }, - { index: { _index: index, data: {name: "Neuromancer", "author": "William Gibson", "release_date": "1984-07-01", "page_count": 271} } }, - { index: { _index: index, data: {name: "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311} } }, - { index: { _index: index, data: {name: "Starship Troopers", "author": "Robert A. Heinlein", "release_date": "1959-12-01", "page_count": 335} } }, - { index: { _index: index, data: {name: "The Left Hand of Darkness", "author": "Ursula K. Le Guin", "release_date": "1969-06-01", "page_count": 304} } }, - { index: { _index: index, data: {name: "The Moon is a Harsh Mistress", "author": "Robert A. Heinlein", "release_date": "1966-04-01", "page_count": 288 } } } - ] - client.bulk(body: documents, refresh: 'wait_for') - end + context 'ScrollHelper' do + let(:index) { 'books' } + let(:body) { { size: 12, query: { match_all: {} } } } + let(:scroll_helper) { Elasticsearch::Helpers::ScrollHelper.new(CLIENT, index, body) } - after do - client.indices.delete(index: index) - end + before do + documents = [ + { index: { _index: index, data: {name: "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561} } }, + { index: { _index: index, data: {name: "Hyperion", "author": "Dan Simmons", "release_date": "1989-05-26", "page_count": 482} } }, + { index: { _index: index, data: {name: "Dune", "author": "Frank Herbert", "release_date": "1965-06-01", "page_count": 604} } }, + { index: { _index: index, data: {name: "Dune Messiah", "author": "Frank Herbert", "release_date": "1969-10-15", "page_count": 331} } }, + { index: { _index: index, data: {name: "Children of Dune", "author": "Frank Herbert", "release_date": "1976-04-21", "page_count": 408} } }, + { index: { _index: index, data: {name: "God Emperor of Dune", "author": "Frank Herbert", "release_date": "1981-05-28", "page_count": 454} } }, + { index: { _index: index, data: {name: "Consider Phlebas", "author": "Iain M. Banks", "release_date": "1987-04-23", "page_count": 471} } }, + { index: { _index: index, data: {name: "Pandora's Star", "author": "Peter F. Hamilton", "release_date": "2004-03-02", "page_count": 768} } }, + { index: { _index: index, data: {name: "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585} } }, + { index: { _index: index, data: {name: "A Fire Upon the Deep", "author": "Vernor Vinge", "release_date": "1992-06-01", "page_count": 613} } }, + { index: { _index: index, data: {name: "Ender's Game", "author": "Orson Scott Card", "release_date": "1985-06-01", "page_count": 324} } }, + { index: { _index: index, data: {name: "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328} } }, + { index: { _index: index, data: {name: "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227} } }, + { index: { _index: index, data: {name: "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268} } }, + { index: { _index: index, data: {name: "Foundation", "author": "Isaac Asimov", "release_date": "1951-06-01", "page_count": 224} } }, + { index: { _index: index, data: {name: "The Giver", "author": "Lois Lowry", "release_date": "1993-04-26", "page_count": 208} } }, + { index: { _index: index, data: {name: "Slaughterhouse-Five", "author": "Kurt Vonnegut", "release_date": "1969-06-01", "page_count": 275} } }, + { index: { _index: index, data: {name: "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "release_date": "1979-10-12", "page_count": 180} } }, + { index: { _index: index, data: {name: "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470} } }, + { index: { _index: index, data: {name: "Neuromancer", "author": "William Gibson", "release_date": "1984-07-01", "page_count": 271} } }, + { index: { _index: index, data: {name: "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311} } }, + { index: { _index: index, data: {name: "Starship Troopers", "author": "Robert A. Heinlein", "release_date": "1959-12-01", "page_count": 335} } }, + { index: { _index: index, data: {name: "The Left Hand of Darkness", "author": "Ursula K. Le Guin", "release_date": "1969-06-01", "page_count": 304} } }, + { index: { _index: index, data: {name: "The Moon is a Harsh Mistress", "author": "Robert A. Heinlein", "release_date": "1966-04-01", "page_count": 288 } } } + ] + CLIENT.bulk(body: documents, refresh: 'wait_for') + end - it 'instantiates a scroll helper' do - expect(scroll_helper).to be_an_instance_of Elasticsearch::Helpers::ScrollHelper - end + after do + CLIENT.indices.delete(index: index) + end - it 'searches an index' do - my_documents = [] - while !(documents = scroll_helper.results).empty? - my_documents << documents + it 'instantiates a scroll helper' do + expect(scroll_helper).to be_an_instance_of Elasticsearch::Helpers::ScrollHelper end - expect(my_documents.flatten.size).to eq 24 - end + it 'searches an index' do + my_documents = [] + until (documents = scroll_helper.results).empty? + my_documents << documents + end - it 'uses enumerable' do - count = 0 - scroll_helper.each { |a| count += 1 } - expect(count).to eq 24 - expect(scroll_helper).to respond_to(:count) - expect(scroll_helper).to respond_to(:reject) - expect(scroll_helper).to respond_to(:uniq) - expect(scroll_helper.map { |a| a['_id'] }.uniq.count).to eq 24 + expect(my_documents.flatten.size).to eq 24 + end + + it 'uses enumerable' do + count = 0 + scroll_helper.each { count += 1 } + expect(count).to eq 24 + expect(scroll_helper).to respond_to(:count) + expect(scroll_helper).to respond_to(:reject) + expect(scroll_helper).to respond_to(:uniq) + expect(scroll_helper.map { |a| a['_id'] }.uniq.count).to eq 24 + end end end diff --git a/elasticsearch/spec/integration/opentelemetry_spec.rb b/elasticsearch/spec/integration/opentelemetry_spec.rb new file mode 100644 index 0000000000..1c0611feea --- /dev/null +++ b/elasticsearch/spec/integration/opentelemetry_spec.rb @@ -0,0 +1,47 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +if ENV['TEST_WITH_OTEL'] == 'true' + ELASTICSEARCH_URL = ENV['TEST_ES_SERVER'] || "http://localhost:#{(ENV['PORT'] || 9200)}" + raise URI::InvalidURIError unless ELASTICSEARCH_URL =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ + + require 'spec_helper' + + context 'OpenTelemetry' do + let(:exporter) { EXPORTER } + before { exporter.reset } + after { exporter.reset } + let(:span) { exporter.finished_spans[0] } + + after do + CLIENT.delete(index: 'myindex', id: 1); rescue + end + + context 'when a request is instrumented' do + it 'sets the span name to the endpoint id' do + CLIENT.search(body: { query: { match: { a: 1 } } }) + expect(span.name).to eq 'search' + end + + it 'sets the path parts' do + CLIENT.index(index: 'myindex', id: 1, body: { title: 'Test' }) + expect(span.attributes['db.elasticsearch.path_parts.index']).to eq 'myindex' + expect(span.attributes['db.elasticsearch.path_parts.id']).to eq 1 + end + end + end +end diff --git a/elasticsearch/spec/spec_helper.rb b/elasticsearch/spec/spec_helper.rb index 0750a40696..d7c4ecfbce 100644 --- a/elasticsearch/spec/spec_helper.rb +++ b/elasticsearch/spec/spec_helper.rb @@ -16,6 +16,7 @@ # under the License. require 'elasticsearch' +require 'openssl' require 'rspec' RSpec.configure do |config| @@ -29,3 +30,30 @@ def meta_version def jruby? defined?(JRUBY_VERSION) end + +if ENV['TEST_WITH_OTEL'] == 'true' + require 'opentelemetry-sdk' + EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new + span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) + + OpenTelemetry::SDK.configure do |c| + c.error_handler = ->(exception:, message:) { raise(exception || message) } + c.logger = Logger.new($stderr, level: ENV.fetch('OTEL_LOG_LEVEL', 'fatal').to_sym) + c.add_span_processor span_processor + end +end + +CERTS_PATH = File.expand_path('../../.buildkite/certs', __dir__) +host = ENV['TEST_ES_SERVER'] || 'http://localhost:9200' +raise URI::InvalidURIError unless host =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/ + +password = ENV['ELASTIC_PASSWORD'] || 'changeme' +HOST_URI = URI.parse(host) +raw_certificate = File.read("#{CERTS_PATH}/testnode.crt") +certificate = OpenSSL::X509::Certificate.new(raw_certificate) +raw_key = File.read("#{CERTS_PATH}/testnode.key") +key = OpenSSL::PKey::RSA.new(raw_key) +ca_file = File.expand_path("#{CERTS_PATH}/ca.crt") +TRANSPORT_OPTIONS = { ssl: { verify: false, client_cert: certificate, client_key: key, ca_file: ca_file } } +HOST = "https://elastic:#{password}@#{HOST_URI.host}:#{HOST_URI.port}" +CLIENT = Elasticsearch::Client.new(host: HOST, transport_options: TRANSPORT_OPTIONS) diff --git a/elasticsearch/spec/unit/api_key_spec.rb b/elasticsearch/spec/unit/api_key_spec.rb index cc43f65604..176d1b57b6 100644 --- a/elasticsearch/spec/unit/api_key_spec.rb +++ b/elasticsearch/spec/unit/api_key_spec.rb @@ -16,6 +16,7 @@ # under the License. require 'spec_helper' +require 'base64' describe Elasticsearch::Client do context 'when using API Key' do diff --git a/elasticsearch/spec/unit/headers_spec.rb b/elasticsearch/spec/unit/headers_spec.rb index 7d6fde7798..48a072b2fc 100644 --- a/elasticsearch/spec/unit/headers_spec.rb +++ b/elasticsearch/spec/unit/headers_spec.rb @@ -26,7 +26,7 @@ allow(client).to receive(:perform_request) { OpenStruct.new(body: '') } expect { client.search(headers: headers) }.not_to raise_error expect(client).to have_received(:perform_request) - .with('GET', '_search', {}, nil, headers) + .with('GET', '_search', {}, nil, headers, { endpoint: 'search' }) end end diff --git a/elasticsearch/spec/unit/opaque_id_spec.rb b/elasticsearch/spec/unit/opaque_id_spec.rb index 39c3f06104..09e1a5232d 100644 --- a/elasticsearch/spec/unit/opaque_id_spec.rb +++ b/elasticsearch/spec/unit/opaque_id_spec.rb @@ -29,7 +29,7 @@ it 'uses x-opaque-id on a request' do client.search(opaque_id: '12345') expect(transport).to have_received(:perform_request) - .with('GET', '_search', {}, nil, { 'X-Opaque-Id' => '12345' }) + .with('GET', '_search', {}, nil, { 'X-Opaque-Id' => '12345' }, {:endpoint=>"search"}) end end @@ -42,7 +42,7 @@ it 'uses x-opaque-id on a request' do expect { client.search(opaque_id: '12345') }.not_to raise_error expect(transport).to have_received(:perform_request) - .with('GET', '_search', {}, nil, { 'X-Opaque-Id' => 'elastic_cloud12345' }) + .with('GET', '_search', {}, nil, { 'X-Opaque-Id' => 'elastic_cloud12345' }, {:endpoint=>"search"}) end end end diff --git a/profile/benchmarking.rb b/profile/benchmarking.rb deleted file mode 100644 index 331259a509..0000000000 --- a/profile/benchmarking.rb +++ /dev/null @@ -1,85 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'benchmark' -require 'yaml' -require 'erb' -require 'json' -require_relative 'benchmarking/measurable' -require_relative 'benchmarking/simple' -require_relative 'benchmarking/complex' -require_relative 'benchmarking/results' - -module Elasticsearch - - # Module with all functionality for running client benchmark tests. - # - # @since 7.0.0 - module Benchmarking - - extend self - - # The default number of test repetitions. - # - # @return [ Integer ] The number of test repetitions. - # - # @since 7.0.0 - DEFAULT_TEST_REPETITIONS = 10.freeze - - # The number of default warmup repetitions of the test to do before - # recording times. - # - # @return [ Integer ] The default number of warmup repetitions. - # - # @since 7.0.0 - DEFAULT_WARMUP_REPETITIONS = 1.freeze - - # The default definition of a test run. - # - # @return [ Hash ] The default test run definition. - # - # @since 7.0.0 - DEFAULT_RUN = { 'description' => 'Default run', - 'repetitions' => { - 'measured' => DEFAULT_TEST_REPETITIONS, - 'warmup' => DEFAULT_WARMUP_REPETITIONS }, - 'name' => 'default', - 'metrics' => ['mean'] }.freeze - - # Parse a file of run definitions and yield each run. - # - # @params [ String ] file The YAML file containing the matrix of test run definitions. - # - # @yieldparam [ Hash ] A test run definition. - # - # @since 7.0.0 - def each_run(file) - if file - file = File.new(file) - matrix = YAML.load(ERB.new(file.read).result) - file.close - - matrix.each_with_index do |run, i| - DEFAULT_RUN.merge(run) - yield(run, i) - end - else - yield(DEFAULT_RUN) - end - end - end -end diff --git a/profile/benchmarking/benchmarking_tasks.rake b/profile/benchmarking/benchmarking_tasks.rake deleted file mode 100644 index aae5bef30e..0000000000 --- a/profile/benchmarking/benchmarking_tasks.rake +++ /dev/null @@ -1,201 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 "../benchmarking" - -namespace :benchmark do - - namespace :simple do - - desc "Run the \'ping\' benchmark test" - task :ping do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} PING #{'*' * 5} \n" - puts "#{task.run(:ping)}" - end - end - - desc "Run the \'create index\' benchmark test" - task :create_index do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} CREATE INDEX #{'*' * 5} \n" - puts "#{task.run(:create_index)}" - end - end - - desc "Run the \'index smal document\' benchmark test with patron adapter" - task :index_document_small_patron do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - begin - require 'patron' - rescue LoadError - puts "Patron not loaded, skipping test" - else - task = Elasticsearch::Benchmarking::Simple.new(run, :patron) - puts "#{'*' * 5} INDEX SMALL DOCUMENT, PATRON #{'*' * 5} \n" - puts "#{task.run(:index_document_small)}" - end - end - end - - desc "Run the \'index small document\' benchmark test" - task :index_document_small do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} INDEX SMALL DOCUMENT #{'*' * 5} \n" - puts "#{task.run(:index_document_small)}" - end - end - - desc "Run the \'index large document\' benchmark test" - task :index_document_large do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} INDEX LARGE DOCUMENT #{'*' * 5} \n" - puts "#{task.run(:index_document_large)}" - end - end - - desc "Run the \'get small document\' benchmark test" - task :get_document_small do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} GET SMALL DOCUMENT #{'*' * 5} \n" - puts "#{task.run(:get_document_small)}" - end - end - - desc "Run the \'get large document\' benchmark test" - task :get_document_large do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} GET LARGE DOCUMENT #{'*' * 5} \n" - puts "#{task.run(:get_document_large)}" - end - end - - desc "Run the \'search small document\' benchmark test" - task :search_document_small do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} SEARCH SMALL DOCUMENT #{'*' * 5} \n" - puts "#{task.run(:search_document_small)}" - end - end - - desc "Run the \'search small document\' benchmark test" - task :search_document_large do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} SEARCH LARGE DOCUMENT #{'*' * 5} \n" - puts "#{task.run(:search_document_large)}" - end - end - - desc "Run the \'update document\' benchmark test" - task :update_document do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Simple.new(run) - puts "#{'*' * 5} UPDATE DOCUMENT #{'*' * 5} \n" - puts "#{task.run(:update_document)}" - end - end - - desc "Run all simple benchmark tests" - task :all, [:matrix] do |t, args| - %w[ benchmark:simple:ping - benchmark:simple:create_index - benchmark:simple:index_document_small - benchmark:simple:index_document_large - benchmark:simple:get_document_small - benchmark:simple:get_document_large - benchmark:simple:search_document_small - benchmark:simple:search_document_large - benchmark:simple:update_document - ].each do |task_name| - begin - require 'elasticsearch' - Rake::Task[task_name].invoke(*args) - rescue => ex - puts "Error in task [#{task_name}], #{ex.inspect}" - next - end - end - end - - # namespace :noop do - # - # desc "Run the \'search small document\' benchmark test with the noop plugin" - # task :search_document_small do - # puts "SIMPLE REQUEST BENCHMARK:: SEARCH SMALL DOCUMENT WITH NOOP PLUGIN" - # Elasticsearch::Benchmarking::Simple.new.run(:search_document_small, noop: true) - # end - # end - end - - namespace :complex do - - task :download_dataset do - current_path = File.expand_path(File.dirname(__FILE__)) - data_path = [current_path, 'data'].join('/') - unless File.exists?([data_path, 'stackoverflow.json'].join('/')) - `gsutil cp gs://clients-team-files/stackoverflow.json "#{data_path}/"` - end - end - - desc "Run the \'index documents\' benchmark test" - task :index_documents => :download_dataset do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Complex.new(run) - puts "#{'*' * 5} INDEX DOCUMENTS #{'*' * 5} \n" - puts "#{task.run(:index_documents)}" - end - end - - desc "Run the \'search documents\' benchmark test" - task :search_documents do - require 'elasticsearch' - Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| - task = Elasticsearch::Benchmarking::Complex.new(run) - puts "#{'*' * 5} SEARCH DOCUMENTS #{'*' * 5} \n" - puts "#{task.run(:search_documents)}" - end - end - - desc "Run all complex benchmark test" - task :all do - %w[ benchmark:complex:index_documents - ].each do |task_name| - require 'elasticsearch' - Rake::Task[task_name].invoke - end - end - end -end diff --git a/profile/benchmarking/complex.rb b/profile/benchmarking/complex.rb deleted file mode 100644 index b910ddd5bf..0000000000 --- a/profile/benchmarking/complex.rb +++ /dev/null @@ -1,120 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module Benchmarking - - # Class encapsulating all settings and functionality for running benchmarking - # tests making complex requests. - # - # @since 7.0.0 - class Complex - include Measurable - - # Test sending a bulk request to index a large dataset. - # - # @example Test sending a bulk index request. - # task.create_documents(opts) - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results documents. - # - # @since 7.0.0 - def index_documents(opts = {}) - results = [] - slices = dataset_slices - - warmup_repetitions.times do - slices.each do |slice| - client.bulk(body: slice) - end - end - - duration = with_cleanup do - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - slices.each do |slice| - client.bulk(body: slice) - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: File.basename(DATASET_FILE), - dataset_size: ObjectSpace.memsize_of(dataset), - dataset_n_documents: dataset.length } - index_results!(results, options) - end - - # Test sending a request a search request. - # - # @example Test sending a search request. - # Benchmarking::Complex.search_documents(10) - # - # @param [ Integer ] repetitions The number of test repetitions. - # - # @since 7.0.0 - def search_documents(opts = {}) - results = [] - - duration = with_cleanup do - slices = dataset_slices - sample_slice = slices.collect do |slice| - client.bulk(body: slice) - slice - end[rand(slices.size)-1] - - sample_document = sample_slice[rand(sample_slice.size)-1][:index][:data] - search_criteria = sample_document.find { |k,v| v.is_a?(String) } - request = { body: { query: { match: { search_criteria[0] => search_criteria[1] } } } } - - warmup_repetitions.times do - client.search(request) - end - - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - client.search(request) - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: File.basename(DATASET_FILE), - dataset_size: ObjectSpace.memsize_of(dataset), - dataset_n_documents: dataset.length } - index_results!(results, options) - end - - # def mixed_bulk_small(repetitions) - # - # end - # - # def mixed_bulk_large(repetitions) - # - # end - end - end -end diff --git a/profile/benchmarking/data/largedoc.json b/profile/benchmarking/data/largedoc.json deleted file mode 100644 index 41fda56554..0000000000 --- a/profile/benchmarking/data/largedoc.json +++ /dev/null @@ -1 +0,0 @@ -{"text":"@wildfits you're not getting one.....","in_reply_to_status_id":22773233453,"retweet_count":null,"contributors":null,"created_at":"Thu Sep 02 19:38:18 +0000 2010","geo":null,"source":"web","coordinates":null,"in_reply_to_screen_name":"wildfits","truncated":false,"entities":{"user_mentions":[{"indices":[0,9],"screen_name":"wildfits","name":"Mairin Goetzinger","id":41832464}],"urls":[],"hashtags":[]},"retweeted":false,"place":null,"user":{"friends_count":179,"profile_sidebar_fill_color":"7a7a7a","location":"Minneapols, MN/Brookings SD","verified":false,"follow_request_sent":null,"favourites_count":0,"profile_sidebar_border_color":"a3a3a3","profile_image_url":"http://a1.twimg.com/profile_images/1110614677/Screen_shot_2010-08-25_at_10.12.40_AM_normal.png","geo_enabled":false,"created_at":"Sun Aug 17 00:23:13 +0000 2008","description":"graphic designer + foodie, with a love of music, movies, running, design, + the outdoors!","time_zone":"Mountain Time (US & Canada)","url":"http://jessiefarris.com/","screen_name":"jessiekf","notifications":null,"profile_background_color":"303030","listed_count":1,"lang":"en","profile_background_image_url":"http://a3.twimg.com/profile_background_images/133733613/Picture_4.png","statuses_count":1010,"following":null,"profile_text_color":"d9a980","protected":false,"show_all_inline_media":false,"profile_background_tile":true,"name":"Jessie Farris","contributors_enabled":false,"profile_link_color":"363636","followers_count":218,"id":15878015,"profile_use_background_image":true,"utc_offset":-25200},"favorited":false,"in_reply_to_user_id":41832464,"id":22824602300} \ No newline at end of file diff --git a/profile/benchmarking/data/smalldoc.json b/profile/benchmarking/data/smalldoc.json deleted file mode 100644 index c18279eb43..0000000000 --- a/profile/benchmarking/data/smalldoc.json +++ /dev/null @@ -1 +0,0 @@ -{"id": 49434,"cuisine": "mexican"} diff --git a/profile/benchmarking/measurable.rb b/profile/benchmarking/measurable.rb deleted file mode 100644 index 549e300ae8..0000000000 --- a/profile/benchmarking/measurable.rb +++ /dev/null @@ -1,287 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - - module Benchmarking - # Helper functions used by benchmarking tasks - module Measurable - - attr_reader :options - attr_reader :client_adapter - - # The default number of measured repetitions. - # - # @since 7.0.0 - DEFAULT_MEASURED_REPETITIONS = 5 - - # The default number of warmup repetitions. - # - # @since 7.0.0 - DEFAULT_WARMUP_REPETITIONS = 1 - - # The default number of action iterations. - # - # @since 7.0.0 - DEFAULT_ACTION_ITERATIONS = 1 - - # Create a benchmark test. - # - # @example Create a test. - # Benchmarking::Simple.new({ 'repetitions' => { 'warmup' => 1 }}, :patron) - # - # @param [ Hash ] options The options for the benchmarking task. - # @param [ Symbol ] adapter The adapter the client should be configured with. - # - # @since 7.0.0 - def initialize(options = {}, adapter = ::Faraday.default_adapter) - @options = options - @client_adapter = adapter - end - - # Run a benchmark test. - # - # @example Run a test. - # task.run(:ping) - # - # @param [ Symbol ] type The name of the test to run. - # - # @return [ Hash ] The test results document. - # - # @since 7.0.0 - def run(type, opts={}) - send(type, opts) - end - - # Get the nodes info on the elasticsearch server used for the benchmarking tests. - # - # @example Get the nodes info. - # task.nodes_info - # - # @return [ Hash ] The nodes info. - # - # @since 7.0.0 - def nodes_info - client.nodes.info(os: true) if client.ping - end - - # Get the version of the elasticsearch server used for the benchmarking tests. - # - # @example Get the server version. - # task.server_version - # - # @return [ String ] The server version. - # - # @since 7.0.0 - def server_version - client.perform_request('GET', '/').body['version']['number'] if client.ping - end - - # Get the description of the benchmarking task. - # - # @example Get the task description. - # task.description - # - # @return [ String ] The task description. - # - # @since 7.0.0 - def description - @options['description'] - end - - # Get number of measured repetitions. - # - # @example Get the number of measured repetitions. - # task.measured_repetitions - # - # @return [ Numeric ] The number of measured repetitions. - # - # @since 7.0.0 - def measured_repetitions - @options['repetitions']['measured'] || DEFAULT_MEASURED_REPETITIONS - end - - # Get number of warmup repetitions. - # - # @example Get the number of warmup repetitions. - # task.warmup_repetitions - # - # @return [ Numeric ] The number of warmup repetitions. - # - # @since 7.0.0 - def warmup_repetitions - @options['repetitions']['warmup'] || DEFAULT_WARMUP_REPETITIONS - end - - # Get number of iterations of the action. - # - # @example Get the number of iterations of the action. - # task.action_iterations - # - # @return [ Numeric ] The number of action iterations. - # - # @since 7.0.0 - def action_iterations - @options['repetitions']['action_iterations'] || DEFAULT_ACTION_ITERATIONS - end - - private - - attr_reader :adapter - - # The elasticsearch url to use for the tests. - # - # @return [ String ] The Elasticsearch URL to use in tests. - # - # @since 7.0.0 - ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] || "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}" - - # The username for the results cluster. - # - # @return [ String ] The username for the results cluster. - # - # @since 7.0.0 - ES_RESULT_CLUSTER_USERNAME = ENV['ES_RESULT_CLUSTER_USERNAME'].freeze - - # The password for the results cluster. - # - # @return [ String ] The password for the results cluster. - # - # @since 7.0.0 - ES_RESULT_CLUSTER_PASSWORD = ENV['ES_RESULT_CLUSTER_PASSWORD'].freeze - - # The results cluster url. - # - # @return [ String ] The results cluster url. - # - # @since 7.0.0 - ES_RESULT_CLUSTER_URL = ENV['ES_RESULT_CLUSTER_URL'].freeze - - # The current path. - # - # @return [ String ] The current path. - # - # @since 7.0.0 - CURRENT_PATH = File.expand_path(File.dirname(__FILE__)).freeze - - # The path to data files used in Benchmarking tests. - # - # @return [ String ] Path to Benchmarking test files. - # - # @since 7.0.0 - DATA_PATH = [CURRENT_PATH, 'data'].join('/').freeze - - # The file path and name for the small document. - # - # @return [ String ] The file path and name for the small document. - # - # @since 7.0.0 - SMALL_DOCUMENT = [DATA_PATH, 'smalldoc.json'].join('/').freeze - - # The file path and name for the large document. - # - # @return [ String ] The file path and name for the large document. - # - # @since 7.0.0 - LARGE_DOCUMENT = [DATA_PATH, 'largedoc.json'].join('/').freeze - - # The file path and name for the dataset. - # - # @return [ String ] The file path and name for the dataset. - # - # @since 7.0.0 - DATASET_FILE = [DATA_PATH, 'stackoverflow.json'].join('/').freeze - - # The name of the index to use for benchmark tests. - # - # @return [ String ] The index to use for benchmarking tests. - # - # @since 7.0.0 - INDEX = 'benchmarking-ruby'.freeze - - def load_json_from_file(file_name) - File.open(file_name, "r") do |f| - f.each_line.collect do |line| - JSON.parse(line) - end - end - end - - def with_cleanup - client.indices.delete(index: 'benchmarking-*') - client.indices.create(index: INDEX) unless client.indices.exists?(index: INDEX) - results = yield - client.indices.delete(index: 'benchmarking-*') - results - end - - def client - @client ||= Elasticsearch::Transport::Client.new(host: ELASTICSEARCH_URL, - adapter: adapter, - tracer: nil) - end - - def dataset_slices(slice_size=10000) - @dataset_slices ||= begin - dataset.collect do |d| - { index: { _index: INDEX, _type: '_doc', data: d } } - end.each_slice(slice_size) - end - end - - def dataset - @dataset ||= load_json_from_file(DATASET_FILE) - end - - def small_document - @small_document ||= load_json_from_file(SMALL_DOCUMENT)[0] - end - - def large_document - @large_document ||= load_json_from_file(LARGE_DOCUMENT)[0] - end - - def noop_plugin? - false - end - - def index_results!(results, options = {}) - res = Results.new(self, results, options) - if result_cluster_client.ping - res.index!(result_cluster_client) - puts "#{'*' * 5} Indexed results #{'*' * 5} \n" - else - puts "#{'*' * 5} Results cluster not available, did not index results #{'*' * 5} \n" - end - res.results_doc - rescue => ex - puts "Could not index results, due to #{ex.class}.\n" - puts "Error: #{ex}.\n" - puts "#{ex.backtrace[0..15]}" - end - - def result_cluster_client - @result_cluster_client ||= begin - opts = { host: ES_RESULT_CLUSTER_URL } - opts.merge!(user: ES_RESULT_CLUSTER_USERNAME) if ES_RESULT_CLUSTER_USERNAME - opts.merge!(password: ES_RESULT_CLUSTER_PASSWORD) if ES_RESULT_CLUSTER_PASSWORD - Elasticsearch::Client.new(opts) - end - end - end - end -end diff --git a/profile/benchmarking/results.rb b/profile/benchmarking/results.rb deleted file mode 100644 index ecddb68e8b..0000000000 --- a/profile/benchmarking/results.rb +++ /dev/null @@ -1,254 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 Elasticsearch - module Benchmarking - - # Class encapsulating formatting and indexing the results from a benchmarking run. - # - # @since 7.0.0 - class Results - - attr_reader :raw_results - - # String constant for unit of time elapsed. - # - # @since 7.0.0 - MILLISECONDS = 'milliseconds'.freeze - - # Create a Results object. - # - # @example Create a results object. - # Benchmarking::Results.new(task, [...], options) - # - # @param [ Elasticsearch::Benchmarking ] task The task that executed the benchmarking run. - # @param [ Array ] results An array of the results. - # @param [ Hash ] options The options. - # - # @since 7.0.0 - def initialize(task, results, options = {}) - @task = task - @raw_results = results.map { |r| r * 1000 } - @options = options - end - - # Index the results document into elasticsearch. - # - # @example Index the results. - # results.index!(client) - # - # @param [ Elasticsearch::Client ] client The client to use to index the results. - # - # @return [ Hash ] The results document. - # - # @since 7.0.0 - def index!(client) - create_index!(client) - client.index(index: index_name, body: results_doc) - results_doc - end - - # The document recording the benchmarking run results, to index into the results cluster. - # - # @example Get the results document. - # results.results_doc - # - # @return [ Hash ] The results document. - # - # @since 7.0.0 - def results_doc - @results_doc ||= begin - { '@timestamp' => Time.now.iso8601, - event: event_doc, - agent: agent_doc, - server: server_doc } - end - end - - private - - attr_reader :options - - DEFAULT_INDEX_NAME = 'benchmarking_results'.freeze - - DEFAULT_METRICS = ['median'].freeze - - CLIENT_NAME = 'elasticsearch-ruby-client'.freeze - - COMPLEXITIES = { Elasticsearch::Benchmarking::Simple => :simple, - Elasticsearch::Benchmarking::Complex => :complex }.freeze - - def action_iterations - options[:action_iterations] - end - - def index_name - options[:index_name] || DEFAULT_INDEX_NAME - end - - def create_index!(client) - unless client.indices.exists?(index: index_name) - client.indices.create(index: index_name) - end - end - - def event_doc - { description: description, - category: category, - action: action, - duration: duration, - statistics: statistics_doc, - repetitions: repetitions_doc }.tap do |doc| - doc.merge!(dataset: dataset, - dataset_details: dataset_details) if dataset - end - end - - def description - @task.description - end - - def category - COMPLEXITIES[@task.class] - end - - def action - @options[:operation] - end - - - def dataset - @options[:dataset] - end - - def dataset_details - { size: @options[:dataset_size], - num_documents: @options[:dataset_n_documents] } - end - - def duration - @options[:duration] * 1000 - end - - def statistics_doc - { unit: MILLISECONDS, - mean: mean, - median: median, - max: max, - min: min, - standard_deviation: standard_deviation - } - end - - def median - raw_results.sort![raw_results.size / 2 - 1] - end - - def mean - raw_results.inject { |sum, el| sum + el }.to_f / raw_results.size - end - - def max - raw_results.max - end - - def min - raw_results.min - end - - def standard_deviation - return 0 if raw_results.size < 2 - Math.sqrt(sample_variance) - end - - def sample_variance - m = mean - sum = raw_results.inject(0) { |sum, i| sum +(i-m)**2 } - sum/(raw_results.length - 1).to_f - end - - def repetitions_doc - { warmup: @task.warmup_repetitions, - measured: @task.measured_repetitions, - iterations: action_iterations } - end - - def agent_doc - { version: Elasticsearch::VERSION, - name: CLIENT_NAME, - git: git_doc, - language: language_doc, - os: client_os_doc, - adapter: adapter } - end - - def adapter - @task.client_adapter - end - - def git_doc - sha = `git rev-parse HEAD` - branch = /\* (.+)/.match(`git branch`)[1] - commit_message = `git log -1 --pretty=%B` - repository = 'elasticsearch-ruby' - - { branch: branch, - sha: sha.chomp, - commit_message: commit_message.gsub(/\n/, ''), - repository: repository.chomp } - end - - def language_doc - version = [ - RUBY_VERSION, - RUBY_PLATFORM, - RbConfig::CONFIG['build'] - ].compact.join(', ') - { runtime_version: version } - end - - def client_os_doc - { platform: platform, - type: type, - architecture: architecture } - end - - def type - (RbConfig::CONFIG && RbConfig::CONFIG['host_os']) ? - RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase : 'unknown' - end - - def architecture - RbConfig::CONFIG['target_cpu'] - end - - def platform - [ - @platform, - RUBY_VERSION, - RUBY_PLATFORM, - RbConfig::CONFIG['build'] - ].compact.join(', ') - end - - def server_doc - { version: @task.server_version, - nodes_info: @task.nodes_info } - end - end - end -end diff --git a/profile/benchmarking/simple.rb b/profile/benchmarking/simple.rb deleted file mode 100644 index 7701f9bc4a..0000000000 --- a/profile/benchmarking/simple.rb +++ /dev/null @@ -1,404 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'objspace' - -module Elasticsearch - module Benchmarking - - # Class encapsulating all settings and functionality for running benchmarking - # tasks making simple requests. - # - # @since 7.0.0 - class Simple - include Measurable - - # Test sending a ping request. - # - # @example Test sending a ping request. - # task.ping(opts) - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results document. - # - # @since 7.0.0 - def ping(opts = {}) - results = [] - action_iterations = 1_000 - - warmup_repetitions.times { client.ping } - - duration = Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - action_iterations.times do - client.ping - end - end - end - end - - options = { duration: duration, - operation: __method__, - action_iterations: action_iterations } - index_results!(results, options) - end - - # Test sending a create_index request. - # - # @example Test sending a create index request. - # task.create_index(opts) - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results document. - # - # @since 7.0.0 - def create_index(opts = {}) - results = [] - action_iterations = 10 - - warmup_repetitions.times do - client.indices.create(index: "benchmarking-#{Time.now.to_f}") - end - - duration = with_cleanup do - Benchmark.realtime do - results = measured_repetitions.times.collect do |i| - index_names = action_iterations.times.collect { |j| (measured_repetitions*i) + j } - Benchmark.realtime do - action_iterations.times do |j| - client.indices.create(index: "benchmarking-#{index_names[j]}") - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - action_iterations: action_iterations } - index_results!(results, options) - end - - # Test sending an index document request for a small document. - # - # @example Test sending an index document request. - # task.index_document_small - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results document. - # - # @since 7.0.0 - def index_document_small(opts={}) - results = [] - document = small_document - action_iterations = 10 - - warmup_repetitions.times do - client.create(index: INDEX, body: document) - end - - duration = with_cleanup do - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - action_iterations.times do - client.create(index: INDEX, body: document) - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: 'small_document', - dataset_size: ObjectSpace.memsize_of(small_document), - dataset_n_documents: 1, - action_iterations: action_iterations } - index_results!(results, options) - end - - # Test sending an index document request for a large document. - # - # @example Test sending an index document request. - # task.index_document_large - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results document. - # - # @since 7.0.0 - def index_document_large(opts={}) - results = [] - document = large_document - action_iterations = 1_000 - - warmup_repetitions.times do - client.create(index: INDEX, body: document) - end - - duration = with_cleanup do - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - action_iterations.times do - client.create(index: INDEX, body: document) - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: 'large_document', - dataset_size: ObjectSpace.memsize_of(large_document), - dataset_n_documents: 1, - action_iterations: action_iterations } - index_results!(results, options) - end - - # Test sending a get document request for a small document. - # - # @example Test sending a get document request. - # Benchmarking::Simple.get_document_small - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results document. - # - # @since 7.0.0 - def get_document_small(opts={}) - results = [] - action_iterations = 1_000 - - duration = with_cleanup do - id = client.create(index: INDEX, body: small_document)['_id'] - warmup_repetitions.times do - client.get(index: INDEX, id: id) - end - - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - action_iterations.times do - client.get(index: INDEX, id: id) - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: 'small_document', - dataset_size: ObjectSpace.memsize_of(small_document), - dataset_n_documents: 1, - action_iterations: action_iterations } - index_results!(results, options) - end - - # Test sending a get document request for a large document. - # - # @example Test sending a get document request. - # Benchmarking::Simple.get_document_large - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results document. - # - # @since 7.0.0 - def get_document_large(opts={}) - duration = 0 - results = [] - action_iterations = 1_000 - - duration = with_cleanup do - id = client.create(index: INDEX, body: large_document)['_id'] - warmup_repetitions.times do - client.get(index: INDEX, id: id) - end - - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - action_iterations.times do - client.get(index: INDEX, id: id) - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: 'large_document', - dataset_size: ObjectSpace.memsize_of(large_document), - dataset_n_documents: 1, - action_iterations: action_iterations } - index_results!(results, options) - end - - # Test sending a search request and retrieving a small document. - # - # @example Test sending a search request for a small document. - # task.search_document_small - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results documents. - # - # @since 7.0.0 - def search_document_small(opts={}) - duration = 0 - results = [] - action_iterations = 1_000 - - duration = with_cleanup do - client.create(index: INDEX, body: small_document) - search_criteria = { match: { cuisine: 'mexican' } } - request = { body: { query: search_criteria } } - if noop_plugin? - Elasticsearch::API.const_set('UNDERSCORE_SEARCH', '_noop_search') - else - request.merge!(index: INDEX) - end - - warmup_repetitions.times do - client.search(request) - end - - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - action_iterations.times do - client.search(request) - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: 'small_document', - dataset_size: ObjectSpace.memsize_of(small_document), - dataset_n_documents: 1, - action_iterations: action_iterations } - index_results!(results, options) - end - - # Test sending a search request and retrieving a large document. - # - # @example Test sending a search request for a large document. - # task.search_document_large - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results documents. - # - # @since 7.0.0 - def search_document_large(opts={}) - results = [] - action_iterations = 1_000 - - duration = with_cleanup do - client.create(index: INDEX, body: large_document) - search_criteria = { match: { 'user.lang': 'en' } } - request = { body: { query: search_criteria } } - if noop_plugin? - Elasticsearch::API.const_set('UNDERSCORE_SEARCH', '_noop_search') - else - request.merge!(index: INDEX) - end - warmup_repetitions.times do - client.search(request) - end - - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - action_iterations.times do - client.search(request) - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: 'large_document', - dataset_size: ObjectSpace.memsize_of(large_document), - dataset_n_documents: 1, - action_iterations: action_iterations } - index_results!(results, options) - end - - # Test sending a update request for a small document. - # - # @example Test sending an update request for a small document. - # Benchmarking::Simple.update_document - # - # @param [ Hash ] opts The test run options. - # - # @results [ Hash ] The results documents. - # - # @since 7.0.0 - def update_document(opts={}) - results = [] - action_iterations = 1_000 - - duration = with_cleanup do - document = small_document - id = client.create(index: INDEX, body: document)['_id'] - field = document.find { |k,v| k != 'id' && v.is_a?(String) }.first - - warmup_repetitions.times do |i| - client.update(index: INDEX, - id: id, - body: { doc: { field: "#{document[field]}-#{i}" } }) - end - - Benchmark.realtime do - results = measured_repetitions.times.collect do - Benchmark.realtime do - action_iterations.times do |i| - client.update(index: INDEX, - id: id, - body: { doc: { field: "#{document[field]}-#{i}" } }) - end - end - end - end - end - - options = { duration: duration, - operation: __method__, - dataset: 'small_document', - dataset_size: ObjectSpace.memsize_of(small_document), - dataset_n_documents: 1, - action_iterations: action_iterations } - index_results!(results, options) - end - end - end -end diff --git a/profile/matrix.yml b/profile/matrix.yml deleted file mode 100644 index d331ff58d6..0000000000 --- a/profile/matrix.yml +++ /dev/null @@ -1,16 +0,0 @@ -- description: Basic benchmark, 5 repetitions - repetitions: - warmup: 1 - measured: 5 - metrics: - - mean - - median - - max - - min - -- description: Ten Repetitions - repetitions: - warmup: 5 - measured: 10 - metrics: - - mean \ No newline at end of file diff --git a/rake_tasks/automation.rake b/rake_tasks/automation.rake new file mode 100644 index 0000000000..8076005a60 --- /dev/null +++ b/rake_tasks/automation.rake @@ -0,0 +1,145 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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 'fileutils' +require 'yaml' +require_relative '../elasticsearch/lib/elasticsearch/version' + +namespace :automation do + desc 'Build gem releases and snapshots' + task :build_gems do + output_dir = File.expand_path("#{__dir__}/../build") + dir = CURRENT_PATH.join(output_dir).to_s + FileUtils.mkdir_p(dir) unless File.exist?(dir) + version = Elasticsearch::VERSION + RELEASE_TOGETHER.each do |gem| + puts '-' * 80 + puts "Building #{gem} v#{version} to #{output_dir}" + sh "cd #{CURRENT_PATH.join(gem)} " \ + "&& gem build --silent -o #{gem}-#{version}.gem && " \ + "mv *.gem #{CURRENT_PATH.join(output_dir)}" + end + puts '-' * 80 + end + + desc 'Generate API code' + task :codegen do + path = File.expand_path('../elasticsearch-api/', __dir__) + branch = YAML.load_file(File.expand_path("#{__dir__}/../.buildkite/pipeline.yml"))['steps'].first['env']['ES_YAML_TESTS_BRANCH'] + unless File.exist?(File.expand_path('elastic-client-generator-ruby', __dir__)) + sh "git clone https://#{ENV['CLIENTS_GITHUB_TOKEN']}@github.com/elastic/elastic-client-generator-ruby.git " + end + + sh "export ES_RUBY_CLIENT_PATH=#{path} " \ + ' && cd elastic-client-generator-ruby/elasticsearch ' \ + ' && sudo bundle install ' \ + " && bundle exec rake update[#{branch}]" \ + ' && bundle exec rake gen_es' \ + ' && cd ../../ ' \ + ' && rm -rf elastic-client-generator-ruby ' + end + + desc <<-DESC + Update Rubygems versions in version.rb and *.gemspec files + + Example: + + $ rake automation:bump[42.0.0] + DESC + task :bump, :version do |_, args| + abort('[!] Required argument [version] missing') unless (version = args[:version]) + files = ['elasticsearch/elasticsearch.gemspec'] + RELEASE_TOGETHER.map { |gem| Dir["./#{gem}/**/**/version.rb"] } + version_regexp = Regexp.new(/VERSION = ("|'([0-9.]+(-SNAPSHOT)?)'|")/) + gemspec_regexp = Regexp.new(/'elasticsearch-api',\s+'([0-9x.]+)'/) + + files.flatten.each do |file| + content = File.read(file) + is_gemspec_file = file.match?('gemspec') + regexp = if is_gemspec_file + gemspec_regexp + else + version_regexp + end + + if (match = content.match(regexp)) + old_version = match[1] + if is_gemspec_file + content.gsub!("'elasticsearch-api', '#{old_version}'", "'elasticsearch-api', '#{version}'") + else + content.gsub!(old_version, "'#{version}'") + end + else + match = content.match(version_regexp) + old_version = match[1] + content.gsub!(old_version, "'#{version}'") + end + puts "[#{old_version}] -> [#{version}] in #{file.gsub('./', '')}" + File.open(file, 'w') { |f| f.puts content } + end + rescue StandardError => e + raise "[!!!] #{e.class} : #{e.message}" + end + + desc <<-DESC + Bump the version in test matrixes: + - .github/workflows + - .buildkite/pipeline.yml + + Example: + + $ rake automation:bump_matrix[42.0.0] + DESC + task :bumpmatrix, :version do |_, args| + abort('[!] Required argument [version] missing') unless (version = args[:version]) + gh_actions = Dir.glob(File.expand_path('../.github/workflows/*.yml', __dir__)) + + files = gh_actions + ['.buildkite/pipeline.yml'] + regexp = Regexp.new(/([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}?+(-SNAPSHOT)?)/) + files.each do |file| + content = File.read(file) + if file == '.buildkite/pipeline.yml' + require 'yaml' + yaml = YAML.safe_load(content) + yaml_tests_branch = yaml['steps'][0]['env']['ES_YAML_TESTS_BRANCH'] + + if yaml_tests_branch == 'main' + old = content.match(/STACK_VERSION: (.*)/)[1] + new = "STACK_VERSION: #{version}" + content.gsub!(new, old) + else + branch = version.match(/([0-9]+\.[0-9]+)\.[0-9]+.*/)[1] + content.gsub!(yaml_tests_branch, branch) + end + puts "[#{yaml_tests_branch}] -> [#{branch}] in #{file.gsub('./', '')}" + end + match = content.match(regexp) + next if match.nil? + + old_version = match[1] + next if old_version == args[:version] + + content.gsub!(old_version, args[:version]) + puts "[#{old_version}] -> [#{version}] in #{file.gsub('./', '')}" + File.open(file, 'w') { |f| f.puts content } + end + end + + desc 'Show current client version' + task :version do + puts Elasticsearch::VERSION + end +end diff --git a/rake_tasks/doc_generator.rake b/rake_tasks/doc_generator.rake index 810430253d..8ab5505a45 100644 --- a/rake_tasks/doc_generator.rake +++ b/rake_tasks/doc_generator.rake @@ -19,11 +19,11 @@ require 'json' require 'fileutils' require 'logger' -namespace :docs do - SRC_FILE = "#{__dir__}/docs/parsed_alternative_report.json".freeze - EXAMPLES_TO_PARSE = JSON.parse(File.read("#{__dir__}/docs/examples_to_parse.json")).freeze - TARGET_DIR = "#{__dir__}/../docs/examples/guide".freeze +SRC_FILE = "#{__dir__}/docs/parsed_alternative_report.json".freeze +EXAMPLES_TO_PARSE = JSON.parse(File.read("#{__dir__}/docs/examples_to_parse.json")).freeze +TARGET_DIR = "#{__dir__}/../docs/examples/guide".freeze +namespace :docs do desc 'Generate doc examples' task :generate do # Remove existing documents to avoid having outdated files @@ -43,10 +43,11 @@ namespace :docs do generate_docs(entry) end puts "Finished generating #{entries.length} files in #{Time.now.to_i - start_time} seconds" + delete_first_log_line end desc 'Update report' - task :update do + task :update, [:branch] do |_, args| require 'elastic-transport' github_token = File.read(File.expand_path("~/.elastic/github.token")) transport_options = { @@ -60,9 +61,16 @@ namespace :docs do transport_options:transport_options ) path = '/repos/elastic/clients-flight-recorder/contents/recordings/docs/parsed-alternative-report.json' + path = "#{path}?ref=#{args[:branch]}" if args[:branch] params = {} response = client.perform_request('GET', path, params) File.write(File.expand_path('./docs/parsed_alternative_report.json', __dir__), response.body) + puts "Downloaded report for #{args[:branch] ? args[:branch] : 'main' } branch" + end + + desc 'Add files from 200-ok log' + task :add_files do + `cat log/200-ok.log | xargs git add` end def json_data @@ -121,7 +129,7 @@ namespace :docs do template.gsub(/\s+$/, '') end - def self.show_parameters(params) + def show_parameters(params) param_string = [] params.each do |k, v| value = (is_number?(v) || is_boolean?(v)) ? v : "'#{v}'" @@ -130,18 +138,19 @@ namespace :docs do param_string.join(",\n\s\s") end - def self.show_body(body) + def show_body(body) 'body: ' + JSON.pretty_generate(body) .gsub(/\"([a-z_]+)\":/,'\\1: ') # Use Ruby 2 hash syntax + .gsub(/"([a-z_.]+\.[a-z_]+)+":/, '"\\1" =>') .gsub('aggs', 'aggregations') # Replace 'aggs' with 'aggregations' for consistency end - def self.is_number?(value) + def is_number?(value) Float(value) || Integer(value) rescue false end - def self.is_boolean?(value) + def is_boolean?(value) (['false', 'true'].include? value) || value.is_a?(TrueClass) || value.is_a?(FalseClass) @@ -157,6 +166,13 @@ namespace :docs do SRC end end + + def delete_first_log_line + logfile = File.expand_path(__dir__ + '/../log/200-ok.log') + content = IO.readlines(logfile, chomp: true) + puts content.shift + File.write(logfile, content.first) + end end # @@ -190,7 +206,8 @@ module TestDocs end def self.log_successful_code(filename) - logger = Logger.new('log/200-ok.log') + FileUtils.mkdir_p('./log') unless File.directory?('./log') + logger = Logger.new('./log/200-ok.log') logger.formatter = -> (_, _, _, msg) { "#{msg} " } logger.info(filename) end @@ -203,6 +220,9 @@ module TestDocs def self.response_successful(response) [true, false].include?(response) || - (response.is_a?(Elasticsearch::API::Response) && response.status == 200) + ( + response.is_a?(Elasticsearch::API::Response) && + [200, 201].include?(response.status) + ) end end diff --git a/rake_tasks/docker_tasks.rake b/rake_tasks/docker_tasks.rake index b26af2b60b..478ecd7d42 100644 --- a/rake_tasks/docker_tasks.rake +++ b/rake_tasks/docker_tasks.rake @@ -16,40 +16,39 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -require 'mkmf' -namespace :docker do +require 'mkmf' # For find_executable + +namespace :es do desc <<~DOC Start Elasticsearch in a Docker container. Default: - rake docker:start[version] + rake es:start[version] E.g.: - rake docker:start[7.x-SNAPSHOT] + rake es:start[9.x-SNAPSHOT] To start the container with Platinum, pass it in as a parameter: - rake docker:start[7.x-SNAPSHOT,platinum] + rake es:start[9.x-SNAPSHOT,platinum] DOC task :start, [:version, :suite] do |_, params| abort 'Docker not installed' unless find_executable 'docker' - abort 'You need to set a version, e.g. rake docker:start[7.x-SNAPSHOT]' unless params[:version] + abort 'You need to set a version, e.g. rake docker:start[9.x-SNAPSHOT]' unless params[:version] test_suite = params[:suite] || 'free' system("STACK_VERSION=#{params[:version]} TEST_SUITE=#{test_suite} ./.buildkite/run-elasticsearch.sh") end -end -namespace :es do desc <<~DOC Start Elasticsearch docker container (shortcut), reads STACK_VERSION from buildkite pipeline DOC task :up do - version = File.read('./.buildkite/pipeline.yml'). - split("\n"). - select { |a| a.include? 'STACK_VERSION' } - .first - .strip - .gsub('STACK_VERSION: ','') - Rake.application.invoke_task("docker:start[#{version}]") + version = File.read('./.buildkite/pipeline.yml') + .split("\n") + .select { |a| a.include? 'STACK_VERSION' } + .first + .strip + .gsub('STACK_VERSION: ', '') + Rake.application.invoke_task("es:start[#{version}, platinum]") end end diff --git a/rake_tasks/elasticsearch_tasks.rake b/rake_tasks/elasticsearch_tasks.rake index db48b543e2..316cbb71ae 100644 --- a/rake_tasks/elasticsearch_tasks.rake +++ b/rake_tasks/elasticsearch_tasks.rake @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -namespace :elasticsearch do +namespace :es do desc 'Wait for elasticsearch cluster to be in green state' task :wait_for_green do require 'elasticsearch' @@ -41,10 +41,22 @@ namespace :elasticsearch do end end + desc 'Automatically update to latest version' + task :autoupdate_version do + require 'tempfile' + branch = `git branch --show-current`.strip + url = "https://artifacts-snapshot.elastic.co/elasticsearch/latest/#{branch}.json" + file = Tempfile.new('version') + download_file!(url, file) + version = JSON.parse(file.read)['version'] + puts "Latest version is #{version}" + Rake::Task['automation:bumpmatrix'].invoke(version) + end + def download_file!(url, filename) puts "Downloading #{filename} from #{url}" - File.open(filename, "w") do |downloaded_file| - URI.open(url, "rb") do |artifact_file| + File.open(filename, 'w') do |downloaded_file| + URI.open(url, 'rb') do |artifact_file| downloaded_file.write(artifact_file.read) end end @@ -54,19 +66,19 @@ namespace :elasticsearch do warn "[!] Couldn't download #{filename}" exit 1 end + rescue OpenURI::HTTPError => e + abort e.message rescue StandardError => e - abort e + puts e.backtrace.join("\n\t") + abort e.message end - desc 'Download artifacts (tests and REST spec) for currently running cluster' + # Deprecated + desc 'Download Elasticsearch artifacts (tests and REST spec) for currently running cluster' task :download_artifacts, :version do |_, args| json_filename = CURRENT_PATH.join('tmp/artifacts.json') - unless (version_number = args[:version] || ENV['STACK_VERSION']) - # Get version number and build hash of running cluster: - version_number = cluster_info['number'] - @build_hash = cluster_info['build_hash'] if cluster_info['build_hash'] - end + version_number = args[:version] || ENV['STACK_VERSION'] || version_from_buildkite || version_from_running_cluster # Create ./tmp if it doesn't exist Dir.mkdir(CURRENT_PATH.join('tmp'), 0700) unless File.directory?(CURRENT_PATH.join('tmp')) @@ -83,12 +95,11 @@ namespace :elasticsearch do exit 1 end - # Get the build hash if it hasn't been set from a running cluster - @build_hash ||= artifacts['version']['builds'].first.dig('projects', 'elasticsearch', 'commit_hash') - + # Either find the artifacts for the exact same build hash from the current running cluster or + # use the first one from the list of builds: build_hash_artifact = artifacts['version']['builds'].find do |build| build.dig('projects', 'elasticsearch', 'commit_hash') == @build_hash - end + end || artifacts['version']['builds'].first zip_url = build_hash_artifact.dig('projects', 'elasticsearch', 'packages').select { |k, _| k =~ /rest-resources-zip/ }.map { |_, v| v['url'] }.first # Dig into the elasticsearch packages, search for the rest-resources-zip package and return the URL: @@ -108,6 +119,18 @@ namespace :elasticsearch do File.write(CURRENT_PATH.join('tmp/rest-api-spec/build_hash'), @build_hash) end + def version_from_buildkite + require 'yaml' + yaml = YAML.load_file(File.expand_path('../.buildkite/pipeline.yml', __dir__)) + yaml['steps'].first['env']['STACK_VERSION'] + end + + def version_from_running_cluster + info = cluster_info + @build_hash = info['build_hash'] if info['build_hash'] + info['number'] + end + desc 'Check Elasticsearch health' task :health do require 'elasticsearch' diff --git a/rake_tasks/test_tasks.rake b/rake_tasks/test_tasks.rake index 038f643c1c..d0d5e3dba9 100644 --- a/rake_tasks/test_tasks.rake +++ b/rake_tasks/test_tasks.rake @@ -47,26 +47,9 @@ namespace :test do end end - desc 'Run rest api tests' - task rest_api: ['elasticsearch:wait_for_green'] do - puts '-' * 80 - sh "cd #{CURRENT_PATH.join('elasticsearch-api')} && unset BUNDLE_GEMFILE && bundle exec rake test:rest_api" - puts "\n" - end - - desc 'Run security (Platinum) rest api yaml tests' - task security: 'elasticsearch:wait_for_green' do - puts '-' * 80 - sh "cd #{CURRENT_PATH.join('elasticsearch-api')} && unset BUNDLE_GEMFILE && TEST_SUITE=platinum bundle exec rake test:rest_api" - puts "\n" - end - - namespace :platinum do - desc 'Run platinum integration tests' - task :integration do - sh "cd #{CURRENT_PATH.join('elasticsearch-api')} && unset BUNDLE_GEMFILE && bundle exec rake test:platinum:integration" - puts "\n" - end + desc 'Run YAML test runner tests' + task :yaml do + sh "cd #{CURRENT_PATH.join('elasticsearch-api')} && unset BUNDLE_GEMFILE && bundle exec rake test:yaml" end # Returns: version_number, build_hash diff --git a/rake_tasks/unified_release_tasks.rake b/rake_tasks/unified_release_tasks.rake deleted file mode 100644 index d9efcfbc5d..0000000000 --- a/rake_tasks/unified_release_tasks.rake +++ /dev/null @@ -1,138 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT 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 'fileutils' -require_relative '../elasticsearch/lib/elasticsearch/version' - -namespace :unified_release do - desc 'Build gem releases and snapshots' - task :assemble, [:version, :output_dir] do |_, args| - if ENV['WORKFLOW'] == 'snapshot' - @zip_filename = "elasticsearch-ruby-#{args[:version]}-SNAPSHOT" - @version = "#{args[:version]}.#{Time.now.strftime('%Y%m%d%H%M%S')}-SNAPSHOT" - else - @version = args[:version] - @zip_filename = "elasticsearch-ruby-#{@version}" - end - - Rake::Task['unified_release:bump'].invoke(@version) unless @version == Elasticsearch::VERSION - - build_gems(args[:output_dir]) - create_zip_file(args[:output_dir]) - end - - def build_gems(output_dir) - raise ArgumentError, 'You must specify an output dir' unless output_dir - - # Create dir if it doesn't exist - dir = CURRENT_PATH.join(output_dir).to_s - FileUtils.mkdir_p(dir) unless File.exist?(dir) - - RELEASE_TOGETHER.each do |gem| - puts '-' * 80 - puts "Building #{gem} v#{@version} to #{output_dir}" - sh "cd #{CURRENT_PATH.join(gem)} " \ - "&& gem build --silent -o #{gem}-#{@version}.gem && " \ - "mv *.gem #{CURRENT_PATH.join(output_dir)}" - end - puts '-' * 80 - end - - def create_zip_file(output_dir) - sh "cd #{CURRENT_PATH.join(output_dir)} && " \ - "zip -r #{@zip_filename}.zip * " \ - end - - desc 'Generate API code' - task :codegen do - version = YAML.load_file(File.expand_path(__dir__ + '/../.buildkite/pipeline.yml'))['steps'].first['env']['STACK_VERSION'] - - Rake::Task['elasticsearch:download_artifacts'].invoke(version) - sh "cd #{CURRENT_PATH.join('elasticsearch-api/utils')} \ - && BUNDLE_GEMFILE=`pwd`/Gemfile \ - && bundle exec thor code:generate" - end - - desc <<-DESC - Update Rubygems versions in version.rb and *.gemspec files - - Example: - - $ rake unified_release:bump[42.0.0] - DESC - task :bump, :version do |_, args| - abort('[!] Required argument [version] missing') unless (version = args[:version]) - files = ['elasticsearch/elasticsearch.gemspec'] + RELEASE_TOGETHER.map { |gem| Dir["./#{gem}/**/**/version.rb"] } - version_regexp = Regexp.new(/VERSION = ("|'([0-9.]+(-SNAPSHOT)?)'|")/) - gemspec_regexp = Regexp.new(/'elasticsearch-api',\s+'([0-9x.]+)'/) - - files.flatten.each do |file| - content = File.read(file) - is_gemspec_file = file.match?('gemspec') - regexp = if is_gemspec_file - gemspec_regexp - else - version_regexp - end - - if (match = content.match(regexp)) - old_version = match[1] - if is_gemspec_file - content.gsub!("'elasticsearch-api', '#{old_version}'", "'elasticsearch-api', '#{version}'") - else - content.gsub!(old_version, "'#{version}'") - end - else - match = content.match(version_regexp) - old_version = match[1] - content.gsub!(old_version, "'#{version}'") - end - puts "[#{old_version}] -> [#{version}] in #{file.gsub('./', '')}" - File.open(file, 'w') { |f| f.puts content } - end - rescue StandardError => e - raise "[!!!] #{e.class} : #{e.message}" - end - - desc <<-DESC - Bump the version in test matrixes: - - .github/workflows - - .buildkite/pipeline.yml - - Example: - - $ rake unified_release:bump_matrix[42.0.0] - DESC - task :bumpmatrix, :version do |_, args| - abort('[!] Required argument [version] missing') unless (version = args[:version]) - - files = [ - '.github/workflows/main.yml', - '.github/workflows/unified-release.yml', - '.buildkite/pipeline.yml' - ] - regexp = Regexp.new(/([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}?+(-SNAPSHOT)?)/) - files.each do |file| - content = File.read(file) - match = content.match(regexp) - old_version = match[1] - content.gsub!(old_version, args[:version]) - puts "[#{old_version}] -> [#{version}] in #{file.gsub('./', '')}" - File.open(file, 'w') { |f| f.puts content } - end - end -end diff --git a/rake_tasks/update_version.rake b/rake_tasks/update_version.rake deleted file mode 100644 index bd59232768..0000000000 --- a/rake_tasks/update_version.rake +++ /dev/null @@ -1,111 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -desc <<-DESC - Update Rubygems versions in version.rb and *.gemspec files - - Example: - - $ rake update_version[5.0.0,5.0.1] -DESC -task :update_version, :old, :new do |_, args| - require 'ansi' - - puts '[!!!] Required argument [old] missing'.ansi(:red) unless args[:old] - puts '[!!!] Required argument [new] missing'.ansi(:red) unless args[:new] - - files = Dir['**/**/version.rb','**/**/*.gemspec'] - - longest_line = files.map(&:size).max - - puts "\n", '= FILES '.ansi(:faint) + ('='*92).ansi(:faint), "\n" - - files.each do |file| - begin - content = File.read(file) - if content.match Regexp.new(args[:old]) - content.gsub! Regexp.new(args[:old]), args[:new] - puts "+ [#{file}]".ansi(:green).ljust(longest_line+20) + " [#{args[:old]}] -> [#{args[:new]}]".ansi(:green,:bold) - File.open(file, 'w') { |f| f.puts content } - else - puts "- [#{file}]".ansi(:yellow).ljust(longest_line+20) + " -".ansi(:faint,:strike) - end - rescue Exception => e - puts "[!!!] #{e.class} : #{e.message}".ansi(:red,:bold) - raise e - end - end -end - -task :update_changelog do - puts "\n\n", '= CHANGELOG '.ansi(:faint) + ('='*88).ansi(:faint), "\n" - - log = `git --no-pager log --reverse --no-color --pretty='* %s' HEAD --not v#{args[:old]} elasticsearch*`.split("\n") - - puts log.join("\n") - - log_entries = {} - log_entries[:client] = log.select { |l| l =~ /\[CLIENT\]/ } - log_entries[:api] = log.select { |l| l =~ /\[API\]/ } - - changelog = File.read(File.open('CHANGELOG.md', 'r')) - - changelog_update = '' - - if log.any? { |l| l =~ /CLIENT|API/ } - changelog_update << "## #{args[:new]}\n\n" - end - - unless log_entries[:client].empty? - changelog_update << "### Client\n\n" - changelog_update << log_entries[:client] - .map { |l| l.gsub /\[CLIENT\] /, '' } - .map { |l| "#{l}" } - .join("\n") - changelog_update << "\n\n" - end - - unless log_entries[:api].empty? - changelog_update << "### API\n\n" - changelog_update << log_entries[:api] - .map { |l| l.gsub /\[API\] /, '' } - .map { |l| "#{l}" } - .join("\n") - changelog_update << "\n\n" - end - - File.open('CHANGELOG.md', 'w+') { |f| f.write changelog_update and f.write changelog } - - puts "\n\n", "= DIFF ".ansi(:faint) + ('='*93).ansi(:faint) - - diff = `git --no-pager diff --patch --word-diff=color --minimal elasticsearch*`.split("\n") - - puts diff - .reject { |l| l =~ /^\e\[1mdiff \-\-git/ } - .reject { |l| l =~ /^\e\[1mindex [a-z0-9]{7}/ } - .reject { |l| l =~ /^\e\[1m\-\-\- i/ } - .reject { |l| l =~ /^\e\[36m@@/ } - .map { |l| l =~ /^\e\[1m\+\+\+ w/ ? "\n#{l} " + '-'*(104-l.size) : l } - .join("\n") - - puts "\n\n", '= COMMIT '.ansi(:faint) + ('='*91).ansi(:faint), "\n" - - puts 'git add CHANGELOG.md elasticsearch*', - "git commit --verbose --message='Release #{args[:new]}' --edit", - 'rake release', - '' -end