diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 668fc8b7b5..fca481b3e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,16 +7,18 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - java: [ 11 ] + java: [ 11, 17, 21 ] os: [ubuntu-latest, windows-latest, macOS-latest] steps: + - name: Checkout Java Client + uses: actions/checkout@v3 + - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} - - - name: Checkout Branch - uses: actions/checkout@v2 + distribution: 'temurin' + cache: 'gradle' - name: Build with Gradle run: ./gradlew clean build -x test diff --git a/.github/workflows/changelog_verifier.yml b/.github/workflows/changelog_verifier.yml index 96f99f17b0..992a38b624 100644 --- a/.github/workflows/changelog_verifier.yml +++ b/.github/workflows/changelog_verifier.yml @@ -15,4 +15,4 @@ jobs: - uses: dangoslen/changelog-enforcer@v3 with: - skipLabels: "autocut" + skipLabels: "autocut, skip-changelog" diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml deleted file mode 100644 index ecc9129902..0000000000 --- a/.github/workflows/checkstyle.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Checkstyle - -on: [push, pull_request] - -jobs: - checkstyle: - runs-on: ubuntu-latest - strategy: - matrix: - java: [ 11 ] - steps: - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java }} - - - uses: actions/checkout@v2 - - name: Check style and license headers - run: | - ./gradlew checkstyleMain checkstyleTest diff --git a/.github/workflows/dependabot_pr.yml b/.github/workflows/dependabot_pr.yml index f13889c13d..ffcdd521c1 100644 --- a/.github/workflows/dependabot_pr.yml +++ b/.github/workflows/dependabot_pr.yml @@ -18,7 +18,7 @@ jobs: installation_id: 22958780 - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ steps.github_app_token.outputs.token }} diff --git a/.github/workflows/increment-version.yml b/.github/workflows/increment-version.yml new file mode 100644 index 0000000000..e8e754dd04 --- /dev/null +++ b/.github/workflows/increment-version.yml @@ -0,0 +1,66 @@ +name: Increment Version + +on: + push: + tags: + - '*.*.*' + +permissions: {} +jobs: + build: + if: github.repository == 'opensearch-project/opensearch-java' + runs-on: ubuntu-latest + steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v2.1.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + + - uses: actions/checkout@v4 + - name: Fetch Tag and Version Information + run: | + TAG=$(echo "${GITHUB_REF#refs/*/}") + CURRENT_VERSION_ARRAY=($(echo "${TAG//v}" | tr . '\n')) + CURRENT_VERSION_ARRAY[0]=$((CURRENT_VERSION_ARRAY[0]//v)) + BASE_X=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:1}.x") + CURRENT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") + CURRENT_VERSION_ARRAY[1]=$((CURRENT_VERSION_ARRAY[1]+1)) + NEXT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") + # if [[ ${#CURRENT_VERSION_ARRAY[2]} -gt 1 ]]; then + # NEXT_VERSION_ID="${CURRENT_VERSION_ARRAY[0]:0:3}0${CURRENT_VERSION_ARRAY[1]:0:3}${CURRENT_VERSION_ARRAY[2]:0:3}99" + # else + # NEXT_VERSION_ID=$(IFS=0 ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}99") + # fi + echo "TAG=$TAG" >> $GITHUB_ENV + # echo "BASE=$BASE" >> $GITHUB_ENV + echo "BASE_X=$BASE_X" >> $GITHUB_ENV + echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV + echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV + # echo "NEXT_VERSION_ID=$NEXT_VERSION_ID" >> $GITHUB_ENV + - uses: actions/checkout@v4 + with: + ref: ${{ env.BASE_X }} + token: ${{ steps.github_app_token.outputs.token }} + + - name: Increment Minor Version + run: | + echo Incrementing $CURRENT_VERSION to $NEXT_VERSION + sed -i "s/systemProp.version = $CURRENT_VERSION/systemProp.version = $NEXT_VERSION/g" gradle.properties + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ steps.github_app_token.outputs.token }} + base: ${{ env.BASE_X }} + branch: 'create-pull-request/patch-${{ env.BASE }}' + commit-message: Increment version to ${{ env.NEXT_VERSION }} + signoff: true + delete-branch: true + labels: | + autocut + title: '[AUTO] Increment version to ${{ env.NEXT_VERSION }}.' + body: | + I've noticed that a new tag ${{ env.TAG }} was pushed, and incremented the version from ${{ env.CURRENT_VERSION }} to ${{ env.NEXT_VERSION }}. diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index 2b1a29fb3d..f5d2b8dd6e 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: lychee Link Checker id: lychee uses: lycheeverse/lychee-action@v1.5.0 diff --git a/.github/workflows/publish-snapshots.yml b/.github/workflows/publish-snapshots.yml new file mode 100644 index 0000000000..3fb806f6d7 --- /dev/null +++ b/.github/workflows/publish-snapshots.yml @@ -0,0 +1,34 @@ +name: Publish snapshots to maven + +on: + push: + branches: + - main + - '2.x' + +jobs: + build-and-publish-snapshots: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: 'gradle' + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }} + aws-region: us-east-1 + - name: publish snapshots to maven + run: | + export SONATYPE_USERNAME=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-username --query SecretString --output text) + export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text) + echo "::add-mask::$SONATYPE_USERNAME" + echo "::add-mask::$SONATYPE_PASSWORD" + ./gradlew --no-daemon publishPublishMavenPublicationToSnapshotsRepository \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000000..4374158a6c --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,44 @@ +name: Release drafter + +on: + push: + tags: + - "*" + +jobs: + draft-a-release: + name: Draft a release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - id: get_data + run: | + echo "approvers=$(cat .github/CODEOWNERS | grep @ | tr -d '* ' | sed 's/@/,/g' | sed 's/,//1')" >> $GITHUB_OUTPUT + echo "version=$(cat gradle.properties | grep "systemProp.version" | cut -d'=' -f2)" >> $GITHUB_OUTPUT + - uses: trstringer/manual-approval@v1 + with: + secret: ${{ github.TOKEN }} + approvers: ${{ steps.get_data.outputs.approvers }} + minimum-approvals: 2 + issue-title: 'Release opensearch-java : ${{ steps.get_data.outputs.version }}' + issue-body: "Please approve or deny the release of opensearch-java. **VERSION**: ${{ steps.get_data.outputs.version }} **TAG**: ${{ github.ref_name }} **COMMIT**: ${{ github.sha }}" + exclude-workflow-initiator-as-approver: true + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: 'gradle' + - name: Build with Gradle + run: | + export VERSION=`cat gradle.properties | grep "systemProp.version" | tr -d " " | cut -d '=' -f2` + echo Building the version: $VERSION + ./gradlew --no-daemon publishPublishMavenPublicationToLocalRepoRepository && tar -C build -cvf artifacts.tar.gz repository + - name: Draft a release + uses: softprops/action-gh-release@v1 + with: + draft: true + generate_release_notes: true + files: | + artifacts.tar.gz diff --git a/.github/workflows/test-integration-unreleased.yml b/.github/workflows/test-integration-unreleased.yml index a136ed906c..2c0d59a450 100644 --- a/.github/workflows/test-integration-unreleased.yml +++ b/.github/workflows/test-integration-unreleased.yml @@ -18,36 +18,57 @@ jobs: - { opensearch_ref: '1.x', java: 11 } - { opensearch_ref: '2.x', java: 11 } - { opensearch_ref: '2.x', java: 17 } - - { opensearch_ref: '2.0', java: 11 } + - { opensearch_ref: '2.x', java: 21 } - { opensearch_ref: 'main', java: 11 } - { opensearch_ref: 'main', java: 17 } + - { opensearch_ref: 'main', java: 21 } steps: - name: Set up JDK ${{ matrix.entry.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.entry.java }} + distribution: 'temurin' - name: Checkout OpenSearch - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: opensearch-project/OpenSearch ref: ${{ matrix.entry.opensearch_ref }} path: opensearch + - name: Get OpenSearch branch top + id: get-key + working-directory: opensearch + run: echo key=`git log -1 --format='%H'` >> $GITHUB_OUTPUT + + - name: Restore cached build + id: cache-restore + uses: actions/cache/restore@v3 + with: + path: opensearch/distribution/archives/linux-tar/build/distributions + key: ${{ steps.get-key.outputs.key }} + - name: Assemble OpenSearch - run: | - cd opensearch - ./gradlew assemble + if: steps.cache-restore.outputs.cache-hit != 'true' + working-directory: opensearch + run: ./gradlew :distribution:archives:linux-tar:assemble - # This step runs the docker image generated during gradle assemble in OpenSearch. It is tagged as opensearch:test. - # Reference: https://github.com/opensearch-project/OpenSearch/blob/2.0/distribution/docker/build.gradle#L190 - - name: Run Docker Image + - name: Save cached build + if: steps.cache-restore.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: opensearch/distribution/archives/linux-tar/build/distributions + key: ${{ steps.get-key.outputs.key }} + + - name: Run OpenSearch + working-directory: opensearch/distribution/archives/linux-tar/build/distributions run: | - docker run -p 9200:9200 -p 9600:9600 -d -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" opensearch:test - sleep 90 + tar xf opensearch-min-* + ./opensearch-*/bin/opensearch & + for attempt in {1..20}; do sleep 5; if curl -s localhost:9200; then echo '=====> ready'; break; fi; echo '=====> waiting...'; done - name: Checkout Java Client - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: opensearch-java @@ -55,3 +76,11 @@ jobs: run: | cd opensearch-java ./gradlew clean integrationTest -Dhttps=false + + - name: Upload Reports + if: failure() + uses: actions/upload-artifact@v3 + with: + name: test-reports + path: opensearch-java/java-client/build/reports/ + retention-days: 7 diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 921815ecb8..9308fb7078 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -12,19 +12,29 @@ jobs: - { opensearch_version: 1.0.1, java: 11 } - { opensearch_version: 1.1.0, java: 11 } - { opensearch_version: 1.2.4, java: 11 } - - { opensearch_version: 1.3.5, java: 11 } + - { opensearch_version: 1.3.13, java: 11 } - { opensearch_version: 2.0.1, java: 11 } - { opensearch_version: 2.1.0, java: 11 } - { opensearch_version: 2.2.1, java: 11 } - { opensearch_version: 2.3.0, java: 11 } + - { opensearch_version: 2.4.1, java: 11 } + - { opensearch_version: 2.5.0, java: 11 } + - { opensearch_version: 2.6.0, java: 11 } + - { opensearch_version: 2.7.0, java: 11 } + - { opensearch_version: 2.8.0, java: 11 } + - { opensearch_version: 2.9.0, java: 11 } + - { opensearch_version: 2.10.0, java: 11 } + - { opensearch_version: 2.11.1, java: 11 } steps: + - name: Checkout Java Client + uses: actions/checkout@v3 + - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.entry.java }} - - - name: Checkout Branch - uses: actions/checkout@v2 + distribution: 'temurin' + cache: 'gradle' - name: Run Docker run: | @@ -34,6 +44,14 @@ jobs: - name: Run Integration Test run: ./gradlew clean integrationTest + - name: Upload Reports + if: failure() + uses: actions/upload-artifact@v3 + with: + name: test-reports + path: java-client/build/reports/ + retention-days: 7 + - name: Stop Docker run: | docker-compose --project-directory .ci/opensearch down \ No newline at end of file diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index fbfe15671c..982d3d957a 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -7,16 +7,18 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - java: [ 11 ] + java: [ 11, 17, 21 ] os: [ubuntu-latest, windows-latest, macOS-latest] steps: + - name: Checkout Java Client + uses: actions/checkout@v3 + - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} - - - name: Checkout Branch - uses: actions/checkout@v2 + distribution: 'temurin' + cache: 'gradle' - name: Run Unit Test run: ./gradlew clean unitTest diff --git a/.gitignore b/.gitignore index 96cbff8d90..b8638f2e72 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ gradle-app.setting .ci/output java-client/bin +samples/bin \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 9534bde8ab..9d4aa6e87f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1,232 @@ # CHANGELOG Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) -## [Unreleased] +## [Unreleased 2.x] ### Added -- Github workflow for changelog verification ([#239](https://github.com/opensearch-project/opensearch-java/pull/239)) -- Github workflow for dependabot PRs ([#247](https://github.com/opensearch-project/opensearch-java/pull/247)) +- Added support for icu_collation_keyword type ([#725](https://github.com/opensearch-project/opensearch-java/pull/725)) +- Added support for flat_object field property ([#735](https://github.com/opensearch-project/opensearch-java/pull/735)) +- Expose HTTP status code through `ResponseException#status` ([#756](https://github.com/opensearch-project/opensearch-java/pull/756)) +- Added toBuilder method to all request model in core package & _types.query_dsl package ([#766](https://github.com/opensearch-project/opensearch-java/pull/766)) +- Added toQuery method in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760) +- Added missing WrapperQuery accessors and builder methods ([#806](https://github.com/opensearch-project/opensearch-java/pull/806)) +### Dependencies +- Bumps `com.diffplug.spotless` from 6.22.0 to 6.24.0 +- Bumps `org.apache.httpcomponents.client5:httpclient5` from 5.2.1 to 5.3 +- Bumps `org.owasp.dependencycheck` from 8.4.2 to 9.0.8 + +### Changed + +### Deprecated +- Deprecated "_toQuery()" in Query and QueryVariant ([#760](https://github.com/opensearch-project/opensearch-java/pull/760)) + +### Removed +- Removed unsupported `prefix` field from CompletionSuggester ([#812](https://github.com/opensearch-project/opensearch-java/pull/812)) + +### Fixed +- Fix partial success results for msearch_template ([#709](https://github.com/opensearch-project/opensearch-java/pull/709)) +- Fix deserialization of node stats response ([#745](https://github.com/opensearch-project/opensearch-java/pull/745)) +- Fix PutIndexTemplateRequest field deserialization ([#765](https://github.com/opensearch-project/opensearch-java/pull/765)) + +### Security + +## [2.8.0] - 01/11/2023 +### Added +- Added support for indexing and search index settings ([#667](https://github.com/opensearch-project/opensearch-java/pull/667)) +- Added support for neural query type ([#674](https://github.com/opensearch-project/opensearch-java/pull/674)) + +### Dependencies + +### Changed +- Allow null values in arrays ([#687](https://github.com/opensearch-project/opensearch-java/pull/687)) +- Add an example for bulk update operation in samples ([#690](https://github.com/opensearch-project/opensearch-java/pull/690)) + +### Deprecated + +### Removed + +### Fixed +- Fixed Hit response when search request has storedFields as null ([#698](https://github.com/opensearch-project/opensearch-java/pull/698)) +- Fix InnerHits storedFields deserialization/serialization ([#781](https://github.com/opensearch-project/opensearch-java/pull/781) + +### Security + +## [2.7.0] - 10/13/2023 +### Added +- Added support for "smartcn" analyzer ([#605](https://github.com/opensearch-project/opensearch-java/pull/605)) +- Added support for "cjk" analyzer ([#604](https://github.com/opensearch-project/opensearch-java/pull/604)) +- Added support for wrapper queries ([#630](https://github.com/opensearch-project/opensearch-java/pull/630)) +- Added support for "script_fields" in multi search request ([#632](https://github.com/opensearch-project/opensearch-java/pull/632)) +- Added size attribute to MultiTermsAggregation ([#627](https://github.com/opensearch-project/opensearch-java/pull/627)) +- Added version increment workflow that executes after release ([#664](https://github.com/opensearch-project/opensearch-java/pull/664)) + +### Dependencies +- Bumps `org.ajoberstar.grgit:grgit-gradle` from 5.0.0 to 5.2.0 +- Bumps `com.github.jk1.dependency-license-report` from 2.4 to 2.5 +- Bumps `io.github.classgraph:classgraph` from 4.8.160 to 4.8.161 + +### Changed +- Moved "software.amazon.awssdk" dependencies to the compileOnly scope. ([#628](https://github.com/opensearch-project/opensearch-java/pull/628)) +- Migrated from checkstyle to spotless ([#648](https://github.com/opensearch-project/opensearch-java/pull/648)) + +### Deprecated + +### Removed +- Remove generated code comments from all files ([#598](https://github.com/opensearch-project/opensearch-java/pull/598)) + +### Fixed +- Fix PutMappingRequest by removing unsupported fields ([#597](https://github.com/opensearch-project/opensearch-java/pull/597)) +- [BUG] JarHell caused by latest software.amazon.awssdk 2.20.141 ([#616](https://github.com/opensearch-project/opensearch-java/pull/616)) +- Don't over-allocate in HeapBufferedAsyncEntityConsumer in order to consume the response ([#620](https://github.com/opensearch-project/opensearch-java/pull/620)) +- Fixed CVE-2976 + added CVE checker ([#624](https://github.com/opensearch-project/opensearch-java/pull/624)) +- Fix parsing of GetFieldMappingResponse ([#641](https://github.com/opensearch-project/opensearch-java/pull/641)) +- Fix TermvectorsResponse for optional fields ([#642](https://github.com/opensearch-project/opensearch-java/pull/642)) +- Fix deserialization of MsearchTemplateResponse ([#660](https://github.com/opensearch-project/opensearch-java/pull/660)) + +### Security + +## [2.6.0] - 07/05/2023 +### Added +- Add support for knn_vector field type ([#524](https://github.com/opensearch-project/opensearch-java/pull/524)) +- Add translog option object and missing translog sync interval option in index settings ([#518](https://github.com/opensearch-project/opensearch-java/pull/518)) +- Adds the option to set slices=auto for UpdateByQueryRequest, DeleteByQueryRequest and ReindexRequest ([#538](https://github.com/opensearch-project/opensearch-java/pull/538)) +- Add support for approximate k-NN queries ([#548](https://github.com/opensearch-project/opensearch-java/pull/548)) + +### Dependencies +- Bumps `com.github.jk1.dependency-license-report` from 2.2 to 2.4 +- Bumps `io.github.classgraph:classgraph` from 4.8.157 to 4.8.160 +- Bumps `jackson` from 2.14.2 to 2.15.2 ((#537)[https://github.com/opensearch-project/opensearch-java/pull/537]) +- Update `org.apache.httpcomponents.client5:httpclient5` from `5.1.4` to `5.2.1` and `org.apache.httpcomponents.core5:httpcore5` from `5.1.5` to `5.2.2` + +### Changed + +### Deprecated +- Deprecate translogDurability and translogFlushThresholdSize in IndexSettings in favor of a separate translog object ([#518](https://github.com/opensearch-project/opensearch-java/pull/518)) + +### Removed + +### Fixed +- Fixed Suggesters for Completion, Term, and Phrase and refactored the Suggestion class ([#477](https://github.com/opensearch-project/opensearch-java/pull/477)) +- Fix highlight max_analyzer_offset field name to match with the one introduced in OpenSearch 2.2.0 ([#555](https://github.com/opensearch-project/opensearch-java/pull/555)) + +### Security + +## [2.5.0] - 06/02/2023 +### Added +- Add workflow to publish snapshots via GHA ([#454](https://github.com/opensearch-project/opensearch-java/pull/454)) +- Added Point-In-Time APIs ([#461](https://github.com/opensearch-project/opensearch-java/pull/461)) + +### Dependencies +- Bumps `com.github.jk1.dependency-license-report` from 1.19 to 2.2 +- Bumps `org.eclipse.parsson:parsson` from 1.1.2 to 1.1.4 + +### Changed +- Improve time taken by Github actions by using cache ([#439](https://github.com/opensearch-project/opensearch-java/pull/439)) +- Introduce intermediary SearchResult for SearchResponse and SearchTemplateResponse classes, enabling similar response handling for both ([#462](https://github.com/opensearch-project/opensearch-java/pull/462)) + +### Deprecated + +### Removed + +### Fixed +- Fix missing Highlight and SourceConfig in the MultisearchBody ([#442](https://github.com/opensearch-project/opensearch-java/pull/442)) +- Fix search failure with missing required property HitsMetadata.total when trackTotalHits is disabled ([#372](https://github.com/opensearch-project/opensearch-java/pull/372)) +- Fix failure when deserialing response for tasks API ([#463](https://github.com/opensearch-project/opensearch-java/pull/463)) +- Fix failure when deserializing boolean types for enums ([#463](https://github.com/opensearch-project/opensearch-java/pull/482)) +- Fix missing minScore, postFilter, searchAfter, sort, trackScores in the MultisearchBody ([#516](https://github.com/opensearch-project/opensearch-java/pull/516)) +### Security + +## [2.4.0] - 04/11/2023 + +### Added +- Add buffered lookahead for Jackson ([#338](https://github.com/opensearch-project/opensearch-java/pull/338)) +- Add support for headers and sort parameters in cat requests ([#413](https://github.com/opensearch-project/opensearch-java/pull/413)) +- Add support for data stream operations ([#419](https://github.com/opensearch-project/opensearch-java/pull/419)) + +### Dependencies +- Bumps `io.github.classgraph:classgraph` from 4.8.156 to 4.8.157 ([#408](https://github.com/opensearch-project/opensearch-java/pull/408)) + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + +## [2.3.0] - 03/15/2023 + +### Added +- Require two maintainers to approve release ([#383](https://github.com/opensearch-project/opensearch-java/pull/383)) +- Add support for mapping limit settings ([#382](https://github.com/opensearch-project/opensearch-java/pull/382)) + +### Dependencies +- Bumps `Jackson` from 2.14.1 to 2.14.2 ([#357](https://github.com/opensearch-project/opensearch-java/pull/357)) +- Bumps `classgraph` from 4.8.149 to 4.8.156 ([#395](https://github.com/opensearch-project/opensearch-java/pull/395)) + +### Changed +- Prevent SPI calls at runtime ([#293](https://github.com/opensearch-project/opensearch-java/pull/293)) + +### Deprecated + +### Removed + +### Fixed +- Fix issue where completion suggestions were failing, due to being parsed as term suggestions ([#350](https://github.com/opensearch-project/opensearch-java/pull/350)) +- Bulk UpdateOperation misses upsert options ([#353](https://github.com/opensearch-project/opensearch-java/pull/353)) +- Fix missing key property in the RangeBucket ([#381](https://github.com/opensearch-project/opensearch-java/pull/381)) + +### Security + +## [2.2.0] - 01/23/2023 + +### Added +- Add Github workflow for changelog verification ([#239](https://github.com/opensearch-project/opensearch-java/pull/239)) +- Add Github workflow for dependabot PRs ([#247](https://github.com/opensearch-project/opensearch-java/pull/247)) +- Add support for signing service name in AwsSdk2Transport ([#324](https://github.com/opensearch-project/opensearch-java/pull/324)) +- Add new OpenSearchTransport based on Apache HttpClient 5 ([#328](https://github.com/opensearch-project/opensearch-java/pull/328)) +- Add 1-click release workflows ([#321](https://github.com/opensearch-project/opensearch-java/pull/321)) +- Add support for OpenSearch Serverless ([#339](https://github.com/opensearch-project/opensearch-java/pull/339)) +- Add support to parse sub-aggregations from filter/nested aggregations ([#234](https://github.com/opensearch-project/opensearch-java/pull/234)) + ### Dependencies - Bumps `grgit-gradle` from 4.0.1 to 5.0.0 +- Update Jackson to 2.14.0 ([#259](https://github.com/opensearch-project/opensearch-java/pull/259)) +- Update Gradle to 7.6 ([#311](https://github.com/opensearch-project/opensearch-java/pull/311)) ### Changed - Update literature around changelog contributions in CONTRIBUTING.md ([#242](https://github.com/opensearch-project/opensearch-java/pull/242)) - Update tests to use JUnit's Assert ([#244](https://github.com/opensearch-project/opensearch-java/pull/244)) -- Add support to parse sub-aggregations from filter/nested aggregations ([#234](https://github.com/opensearch-project/opensearch-java/pull/234)) - Add timeout and throttle to the jenkins workflows ([#231](https://github.com/opensearch-project/opensearch-java/pull/231)) -- Updating maintainers, admins and documentation ([#248](https://github.com/opensearch-project/opensearch-java/pull/248)) +- Update maintainers, admins and documentation ([#248](https://github.com/opensearch-project/opensearch-java/pull/248)) ### Deprecated +- Deprecate the totalDataSetSize and totalDataSetSizeInBytes fields in the StoreStats ([#498](https://github.com/opensearch-project/opensearch-java/pull/498)) + ### Removed +- Remove support for unsupported dynamic_templates in bulk ([#276](https://github.com/opensearch-project/opensearch-java/pull/276)) ### Fixed - +- Make ChildrenAggregate as a SingleBucketAggregate ([#306](https://github.com/opensearch-project/opensearch-java/pull/306)) +- Fix /_nodes/stats, /_nodes/info throwing serialization error ([#315](https://github.com/opensearch-project/opensearch-java/pull/315)) +- Do not double-wrap OpenSearchException on error ([#323](https://github.com/opensearch-project/opensearch-java/pull/323)) +- Fix AwsSdk2TransportOptions.responseCompression ([#322](https://github.com/opensearch-project/opensearch-java/pull/322)) +- Fix missing Highlight and SourceConfig in the MultisearchBody ([#442](https://github.com/opensearch-project/opensearch-java/pull/442)) +- Fix parsing /_alias error response for not existing alias ([#476](https://github.com/opensearch-project/opensearch-java/pull/476)) +- Fix missing cause message in missing permission to call Fine Grained Access Control Amazon OpenSearch domain ([#473](https://github.com/opensearch-project/opensearch-java/issues/473)) +- Fix catching JsonParsingException ([#494](https://github.com/opensearch-project/opensearch-java/issues/494)) +- Fix StoryStats numeric value out of range of int ([#489](https://github.com/opensearch-project/opensearch-java/pull/489)) + ### Security - -[Unreleased]: https://github.com/opensearch-project/opensearch-java/compare/2.0...HEAD +[Unreleased 2.x]: https://github.com/opensearch-project/opensearch-java/compare/v2.8.0...2.x +[2.8.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.7.0...v2.8.0 +[2.7.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.6.0...v2.7.0 +[2.6.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.5.0...v2.6.0 +[2.5.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.4.0...v2.5.0 +[2.4.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.3.0...v2.4.0 +[2.3.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.2.0...v2.3.0 +[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index c0b9044ee4..10bc8b9767 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -1,4 +1,5 @@ - [Compatibility with OpenSearch](#compatibility-with-opensearch) +- [Compatibility with JDK](#compatibility-with-jdk) - [Upgrading](#upgrading) ## Compatibility with OpenSearch @@ -6,10 +7,19 @@ The below matrix shows the compatibility of the [`opensearch-java-client`](https://search.maven.org/artifact/org.opensearch.client/opensearch-java) with versions of [`OpenSearch`](https://opensearch.org/downloads.html#opensearch). | Client Version | OpenSearch Version | -| --- | --- | -| 1.0.0 | 1.0.0-1.3.3 | -| 2.0.0 | 1.3.3-2.0.1 | -| 2.1.0 | 1.3.3-2.3.0 | +|----------------|--------------------| +| 1.0.0 | 1.x | +| 2.x.0 | 1.3.13-2.x.x | + + +## Compatibility with JDK + +The below matrix shows the compatibility of the [`opensearch-java-client`](https://search.maven.org/artifact/org.opensearch.client/opensearch-java) with JDK versions. + +| Client Version | JDK | +|----------------|--------------------| +| 1.0.0 | 8 | +| 2.x.0 | 11 / 17 / 21 | ## Upgrading diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index fa2da6946e..6969aba856 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -7,6 +7,7 @@ - [Run Tests](#run-tests) - [Unit Tests](#unit-tests) - [Integration Tests](#integration-tests) + - [AWS Transport Integration Tests](#aws-transport-integration-tests) - [Use an Editor](#use-an-editor) - [IntelliJ IDEA](#intellij-idea) - [Visual Studio Code](#visual-studio-code) @@ -64,6 +65,20 @@ Run integration tests after starting OpenSearch cluster: ./gradlew clean integrationTest ``` +#### AWS Transport Integration Tests + +To run integration tests for the AWS transport client, ensure working AWS credentials in `/.aws/credentials` and specify your OpenSearch domain and region as follows: + +``` +./gradlew integrationTest --tests "*AwsSdk2*" -Dtests.awsSdk2support.domainHost=search-...us-west-2.es.amazonaws.com -Dtests.awsSdk2support.domainRegion=us-west-2 -Dtests.awsSdk2support.serviceName=es +``` + +For OpenSearch Serverless, change the signing service name. + +``` +./gradlew integrationTest --tests "*AwsSdk2*" -Dtests.awsSdk2support.domainHost=....us-west-2.aoss.amazonaws.com -Dtests.awsSdk2support.domainRegion=us-west-2 -Dtests.awsSdk2support.serviceName=aoss +``` + ## Use an Editor ### IntelliJ IDEA @@ -82,11 +97,28 @@ Follow links in the [Java Tutorial](https://code.visualstudio.com/docs/java/java ## Java Language Formatting Guidelines -Java files in the opensearch-java codebase are formatted with the [checkstyle plugin](https://docs.gradle.org/current/userguide/checkstyle_plugin.html). This plugin is configured using [checkstyle.xml](config/checkstyle/checkstyle.xml). To run the formatting checks: +Java files in the OpenSearch codebase are formatted with the Eclipse JDT formatter, using the [Spotless Gradle](https://github.com/diffplug/spotless/tree/master/plugin-gradle) plugin. This plugin is configured on a project-by-project basis, via `build.gradle.kts`. So long as at least one project is configured, the formatting check can be run explicitly with: -``` -./gradlew checkstyleMain checkstyleTest -``` + ./gradlew spotlessJavaCheck + +The code can be formatted with: + + ./gradlew spotlessApply + +These tasks can also be run for specific subprojects, e.g. + + ./gradlew :java-client:spotlessJavaCheck + ./gradlew :samples:spotlessJavaCheck + +Please follow these formatting guidelines: + +* Java indent is 4 spaces +* Line width is 140 characters +* Lines of code surrounded by `// tag::NAME` and `// end::NAME` comments are included in the documentation and should only be 76 characters wide not counting leading indentation. Such regions of code are not formatted automatically as it is not possible to change the line length rule of the formatter for part of a file. Please format such sections sympathetically with the rest of the code, while keeping lines to maximum length of 76 characters. +* Wildcard imports (`import foo.bar.baz.*`) are forbidden and will cause the build to fail. +* If *absolutely* necessary, you can disable formatting for regions of code with the `// tag::NAME` and `// end::NAME` directives, but note that these are intended for use in documentation, so please make it clear what you have done, and only do this where the benefit clearly outweighs the decrease in consistency. +* Note that JavaDoc and block comments i.e. `/* ... */` are not formatted, but line comments i.e `// ...` are. +* There is an implicit rule that negative boolean expressions should use the form `foo == false` instead of `!foo` for better readability of the code. While this isn't strictly enforced, if might get called out in PR reviews as something to change. ## Submitting Changes diff --git a/README.md b/README.md index a0563ca3d7..84206a71d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Checkstyle](https://github.com/opensearch-project/opensearch-java/actions/workflows/checkstyle.yml/badge.svg?branch=main)](https://github.com/opensearch-project/opensearch-java/actions/workflows/checkstyle.yml) [![Build](https://github.com/opensearch-project/opensearch-java/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/opensearch-project/opensearch-java/actions/workflows/build.yml) [![Integration Tests](https://github.com/opensearch-project/opensearch-java/actions/workflows/test-integration.yml/badge.svg?branch=main)](https://github.com/opensearch-project/opensearch-java/actions/workflows/test-integration.yml) ![Maven Central](https://img.shields.io/maven-central/v/org.opensearch.client/opensearch-java) @@ -14,6 +13,7 @@ OpenSearch Java Client - [Project Resources](#project-resources) - [Code of Conduct](#code-of-conduct) - [User Guide](#user-guide) +- [Snapshot Builds](#snapshot-builds) - [Compatibility with OpenSearch](#compatibility-with-opensearch) - [Security](#security) - [License](#license) @@ -33,8 +33,9 @@ Please see the [USER_GUIDE](USER_GUIDE.md) for code snippets. * [Project Website](https://opensearch.org/) * [Documentation](https://opensearch.org/docs/latest/clients/java/) +* [JavaDoc](https://www.javadoc.io/doc/org.opensearch.client/opensearch-java/latest/index.html) * [Maven Central](https://search.maven.org/artifact/org.opensearch.client/opensearch-java) -* [Snapshot Builds](https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/client/opensearch-java/) +* [Snapshot Builds](#snapshot-builds) * Need help? Try [Forums](https://discuss.opendistrocommunity.dev/) * [Project Principles](https://opensearch.org/#principles) * [Contributing to OpenSearch](CONTRIBUTING.md) @@ -51,6 +52,9 @@ This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUC See [User Guide](USER_GUIDE.md). +## Snapshot Builds +The [snapshots builds](https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/client/opensearch-java/) are published to sonatype using [publish-snapshots.yml](./.github/workflows/publish-snapshots.yml) workflow. + ## Compatibility with OpenSearch See [Compatibility](COMPATIBILITY.md). diff --git a/RELEASING.md b/RELEASING.md index 14dac4c92e..b19130399b 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -34,9 +34,7 @@ Repositories create consistent release labels, such as `v1.0.0`, `v1.1.0` and `v The release process is standard across repositories in this org and is run by a release manager volunteering from amongst [MAINTAINERS](MAINTAINERS.md). 1. Create a tag, e.g. `v2.1.0`, and push it to the GitHub repo. -2. The [opensearch-java-maven-sign-and-release/](https://build.ci.opensearch.org/job/opensearch-java-maven-sign-and-release/) will be automatically kicked off. -3. Login to [AWS OSS Sonatype](https://aws.oss.sonatype.org/#stagingRepositories), and locate the staged release. -4. `Close` the staged repository, and ensure all checks pass. -5. `Release` the staged respository. -6. [Create a release on GitHub](https://github.com/opensearch-project/opensearch-java/releases/new) with release notes. -7. Increment `systemProp.version` in [gradle.properties](gradle.properties) to the next patch release, e.g. `v2.1.1`, commit and push. \ No newline at end of file +1. The [release-drafter.yml](.github/workflows/release-drafter.yml) will be automatically kicked off and is responsible for drafting a new release on GitHub containing release artifacts. +1. Before creating a draft release, this workflow creates a GitHub issue asking for approval from the [maintainers](MAINTAINERS.md). See sample [issue](https://github.com/gaiksaya/opensearch-java/issues/1). The maintainers need to approve in order to continue the workflow run. +1. Once a release is drafted [opensearch-java-maven-sign-and-release/](https://build.ci.opensearch.org/job/opensearch-java-maven-sign-and-release/) jenkins workflow is triggered. The artifacts will be automcatically signed and published to maven. +1. Increment `systemProp.version` in [gradle.properties](gradle.properties) to the next patch release, e.g. `v2.1.1`, commit and push. \ No newline at end of file diff --git a/USER_GUIDE.md b/USER_GUIDE.md index f51063052e..982e2bb14c 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -1,54 +1,108 @@ -# User Guide +- [OpenSearch Java Client User Guide](#opensearch-java-client-user-guide) + - [Setup](#setup) + - [Basic Features](#basic-features) + - [Creating a client](#creating-a-client) + - [Using `RestClientTransport`](#using-restclienttransport) + - [Using `ApacheHttpClient5Transport`](#using-apachehttpclient5transport) + - [Creating an index](#creating-an-index) + - [With default settings](#with-default-settings) + - [With custom settings and mappings](#with-custom-settings-and-mappings) + - [With FlatObject mappings](#with-flat-object-mappings) + - [Indexing data](#indexing-data) + - [Searching for a document](#searching-for-a-document) + - [Deleting a document](#deleting-a-document) + - [Deleting an index](#deleting-an-index) + - [Advanced Features](#advanced-features) + - [Plugins](#plugins) + +# OpenSearch Java Client User Guide + +## Setup + +To start using the OpenSearch Java client, you need to provide a transport. The default `ApacheHttpClient5TransportBuilder` transport comes with the Java client. To use the OpenSearch Java client with the default transport, add it to your `pom.xml` file as a dependency: -- [User Guide](#user-guide) - - [Sample data](#sample-data) - - [Create an index](#create-an-index) - - [Index data](#index-data) - - [Search for the document](#search-for-the-document) - - [Search documents using a match query](#search-documents-using-a-match-query) - - [Aggregations](#aggregations) - - [Delete the document](#delete-the-document) - - [Delete the index](#delete-the-index) - - [Aggregations](#aggregations) +``` + + org.opensearch.client + opensearch-java + 2.6.0 + +``` + +If you’re using Gradle, add the following dependencies to your project: + +``` +dependencies { + implementation 'org.opensearch.client:opensearch-java:2.6.0' +} +``` + +## Basic Features -## Sample data +In the example below, we create a client, create an index with default and non-default settings, insert a document into the index, search for the document, delete the document, and finally delete the index. -### IndexData class +You can find working versions of the code below that can be run with a local instance of OpenSearch in [samples](./samples/). + +### Creating a client + +There are multiple low level transports which `OpenSearchClient` could be configured with. + +#### Using `RestClientTransport` ```java -static class IndexData { - private String firstName; - private String lastName; - - public IndexData(String firstName, String lastName) { - this.firstName = firstName; - this.lastName = lastName; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - @Override - public String toString() { - return String.format("IndexData{first name='%s', last name='%s'}", firstName, lastName); - } -} +import org.apache.http.HttpHost; + +final HttpHost[] hosts = new HttpHost[] { + new HttpHost("localhost", 9200, "http") + }; + +// Initialize the client with SSL and TLS enabled +final RestClient restClient = RestClient + .builder(hosts) + .build(); + +OpenSearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper()); +OpenSearchClient client = new OpenSearchClient(transport); ``` -## Create an index +The `JacksonJsonpMapper` class (2.x versions) only supports Java 7 objects by default. [Java 8 modules](https://github.com/FasterXML/jackson-modules-java8) to support JDK8 classes such as the Date and Time API (JSR-310), `Optional`, and more can be used by including [the additional datatype dependency](https://github.com/FasterXML/jackson-modules-java8#usage) and adding the module. For example, to include JSR-310 classes: + +```java +Transport transport = new RestClientTransport(restClient, + new JacksonJsonpMapper(new ObjectMapper().registerModule(new JavaTimeModule()))); +OpenSearchClient client = new OpenSearchClient(transport); +``` + +#### Using `ApacheHttpClient5Transport` + +```java +import org.apache.hc.core5.http.HttpHost; + +final HttpHost[] hosts = new HttpHost[] { + new HttpHost("http", "localhost", 9200) + }; + +final OpenSearchTransport transport = ApacheHttpClient5TransportBuilder + .builder(hosts) + .setMapper(new JacksonJsonpMapper()) + .build(); +OpenSearchClient client = new OpenSearchClient(transport); +``` + +The Apache HttpClient 5 based transport has dependences on Apache HttpClient 5 and Apache HttpCore 5 which has to be added to the project explicitly. + +```gradle + implementation("org.apache.httpcomponents.client5", "httpclient5", "5.2.1") + implementation("org.apache.httpcomponents.core5", "httpcore5", "5.2.2") +``` + +Upcoming OpenSearch `3.0.0` release brings HTTP/2 support and as such, the `RestClientTransport` would switch to HTTP/2 if available (for both HTTPS and/or HTTP protocols). The desired protocol could be forced using `RestClientBuilder.HttpClientConfigCallback`. + +See [SampleClient.java](./samples/src/main/java/org/opensearch/client/samples/SampleClient.java) for a working sample. + +### Creating an index + +#### With default settings ```java String index = "sample-index"; @@ -56,19 +110,52 @@ CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(i client.indices().create(createIndexRequest); ``` -## Index data +#### With custom settings and mappings + +```java +String index = "sample-index"; +IndexSettings settings = new IndexSettings.Builder() + .numberOfShards("2") + .numberOfReplicas("1") + .build(); +TypeMapping mapping = new TypeMapping.Builder() + .properties("age", new Property.Builder().integer(new IntegerNumberProperty.Builder().build()).build()) + .build(); +CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder() + .index(index) + .settings(settings) + .mappings(mapping) + .build(); +client.indices().create(createIndexRequest); +``` +#### With flat object mappings +OpenSearch supports FlatObject mappings from version 2.7.0 without additional parameters. ```java -IndexData indexData = new IndexData("John", "Doe"); +final CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(indexName) + .mappings(m -> m.properties("issue", Property.of(p -> p.flatObject(new FlatObjectProperty.Builder().build())))) + .build(); +client.indices().create(createIndexRequest); +``` + +You can find a working sample of the above code in [FlatObjectBasics.java](./samples/src/main/java/org/opensearch/client/samples/FlatObjectBasics.java). + + +### Indexing data + +[IndexData](./samples/src/main/java/org/opensearch/client/samples/util/IndexData.java) refers to sample data class. + +```java +IndexData indexData = new IndexData("Document 1", "Text for document 1"); IndexRequest indexRequest = new IndexRequest.Builder().index(index).id("1").document(indexData).build(); client.index(indexRequest); -indexData = new IndexData("John", "Joe"); +indexData = new IndexData("Document 2", "Text for document 2"); indexRequest = new IndexRequest.Builder().index(index).id("2").document(indexData).build(); client.index(indexRequest); ``` -## Search for the documents +### Searching for a document ```java SearchResponse searchResponse = client.search(s -> s.index(index), IndexData.class); @@ -77,46 +164,32 @@ for (int i = 0; i < searchResponse.hits().hits().size(); i++) { } ``` -## Search documents using a match query +### Deleting a document -```java -SearchRequest searchRequest = new SearchRequest.Builder().query(q -> q.match(m -> m.field("firstName") - .query(FieldValue.of("John")))) - .build(); +The following sample code deletes a document whose ID is 1. -SearchResponse searchResponse = client.search(searchRequest, IndexData.class); -for (int i = 0; i < searchResponse.hits().hits().size(); i++) { - System.out.println(searchResponse.hits().hits().get(i).source()); -} +```java +client.delete(d -> d.index(index).id("1")); ``` -## Aggregations +## Deleting an index ```java -SearchRequest searchRequest = new SearchRequest.Builder().query(q -> q.match(m -> m.field("firstName") - .query(FieldValue.of("John")))) - .aggregations("firstNames", new Aggregation.Builder().terms(t -> t.field("firstName.keyword")) - .build()) - .build(); - -SearchResponse searchResponse = client.search(searchRequest, IndexData.class); -for (Map.Entry entry : searchResponse.aggregations().entrySet()) { - System.out.println("Agg - " + entry.getKey()); - entry.getValue().sterms().buckets().array().forEach(b -> System.out.printf("%s : %d%n", b.key(), b.docCount())); -} +DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest.Builder().index(index).build(); +DeleteIndexResponse deleteIndexResponse = client.indices().delete(deleteIndexRequest); ``` -## Delete the document +You can find a working sample of the above code in [IndexingBasics.java](./samples/src/main/java/org/opensearch/client/samples/IndexingBasics.java). -The following sample code deletes a document whose ID is 1. +## Advanced Features -```java -client.delete(d -> d.index(index).id("1")); -``` +- [Authentication (IAM, SigV4)](./guides/auth.md) +- [Bulk Indexing](./guides/bulk.md) +- [Cat APIs](./guides/cat.md) +- [Data Stream APIs](./guides/data_stream.md) +- [Point-in-Time APIs](./guides/point_in_time.md) +- [Search](./guides/search.md) -## Delete the index +## Plugins -```java -DeleteIndexRequest deleteIndexRequest = new DeleteRequest.Builder().index(index).build(); -DeleteIndexResponse deleteIndexResponse = client.indices().delete(deleteIndexRequest); -``` \ No newline at end of file +- [k-NN](guides/plugins/knn.md) \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index df7f0dc13b..7779a42fd3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,8 +42,6 @@ allprojects { mavenCentral() maven(url = "https://plugins.gradle.org/m2/") } - - apply(plugin = "checkstyle") } // Find git information. diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 81e081c058..be0dd199c3 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -31,7 +31,7 @@ */ dependencies { - implementation("org.ajoberstar.grgit:grgit-gradle:5.0.0") + implementation("org.ajoberstar.grgit:grgit-gradle:5.2.0") } repositories { diff --git a/buildSrc/formatterConfig.xml b/buildSrc/formatterConfig.xml new file mode 100644 index 0000000000..425f9acfea --- /dev/null +++ b/buildSrc/formatterConfig.xml @@ -0,0 +1,362 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml deleted file mode 100644 index 7739883f14..0000000000 --- a/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/checkstyle/checkstyle_suppressions.xml b/config/checkstyle/checkstyle_suppressions.xml deleted file mode 100644 index edfa8870aa..0000000000 --- a/config/checkstyle/checkstyle_suppressions.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/config/checkstyle/header.java.txt b/config/checkstyle/header.java.txt deleted file mode 100644 index b5b39ea4ed..0000000000 --- a/config/checkstyle/header.java.txt +++ /dev/null @@ -1,7 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ diff --git a/gradle.properties b/gradle.properties index 712a6787e1..8fa3f72312 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -systemProp.version = 2.1.1 \ No newline at end of file +systemProp.version = 2.9.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2a..7f93135c49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 788d8e5179..48db9b89d2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -28,7 +28,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 +distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae diff --git a/gradlew b/gradlew index e5053f218f..1aa94a4269 100755 --- a/gradlew +++ b/gradlew @@ -1,33 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -42,72 +16,100 @@ # limitations under the License. # -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. - - ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -117,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -128,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index a9f778a7a9..6689b85bee 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -54,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -64,21 +65,6 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line @@ -86,17 +72,19 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/guides/auth.md b/guides/auth.md new file mode 100644 index 0000000000..658464642d --- /dev/null +++ b/guides/auth.md @@ -0,0 +1,27 @@ +- [Authentication](#authentication) + - [Amazon OpenSearch Service](#amazon-opensearch-service) + +# Authentication + +## Amazon OpenSearch Service + +Requests to [OpenSearch Service and OpenSearch Serverless](https://docs.aws.amazon.com/opensearch-service/index.html) must be signed using the AWS signing protocol. Use `AwsSdk2Transport` to send signed requests. + +```java +SdkHttpClient httpClient = ApacheHttpClient.builder().build(); + +OpenSearchClient client = new OpenSearchClient( + new AwsSdk2Transport( + httpClient, + "search-...us-west-2.es.amazonaws.com", // OpenSearch endpoint, without https:// + "es" // signing service name, use "aoss" for OpenSearch Serverless + Region.US_WEST_2, // signing service region + AwsSdk2TransportOptions.builder().build() + ) +); + +InfoResponse info = client.info(); +System.out.println(info.version().distribution() + ": " + info.version().number()); + +httpClient.close(); +``` \ No newline at end of file diff --git a/guides/bulk.md b/guides/bulk.md new file mode 100644 index 0000000000..3c12c2ddc7 --- /dev/null +++ b/guides/bulk.md @@ -0,0 +1,41 @@ +- [Bulk](#bulk) + - [Bulk Indexing](#bulk-indexing) + - [Bulk requests](#bulk-requests) + +# Bulk + +The [Bulk API](https://opensearch.org/docs/latest/api-reference/document-apis/bulk/) lets you add, update, or delete multiple documents in a single request. + +## Bulk Indexing + +## Bulk requests + +```java +String indexName = "sample-index"; +CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(index).build(); +client.indices().create(createIndexRequest); + +ArrayList ops = new ArrayList<>(); +IndexData doc1 = new IndexData("Document 1", "The text of document 1"); +ops.add(new BulkOperation.Builder().index( + IndexOperation.of(io -> io.index(indexName).id("id1").document(doc1)) +).build()); +IndexData doc2 = new IndexData("Document 2", "The text of document 2"); +ops.add(new BulkOperation.Builder().index( + IndexOperation.of(io -> io.index(indexName).id("id2").document(doc2)) +).build()); +IndexData doc3 = new IndexData("Document 3", "The text of document 3"); +ops.add(new BulkOperation.Builder().index( + IndexOperation.of(io -> io.index(indexName).id("id3").document(doc3)) +).build()); + +BulkRequest.Builder bulkReq = new BulkRequest.Builder() + .index(indexName) + .operations(ops) + .refresh(Refresh.WaitFor); +BulkResponse bulkResponse = client.bulk(bulkReq.build()); +``` + +[IndexData](../samples/src/main/java/org/opensearch/client/samples/util/IndexData.java) refers to sample data class. + +You can find a working sample of the above code in [Bulk.java](../samples/src/main/java/org/opensearch/client/samples/Bulk.java). \ No newline at end of file diff --git a/guides/cat.md b/guides/cat.md new file mode 100644 index 0000000000..a5a3adcb5e --- /dev/null +++ b/guides/cat.md @@ -0,0 +1,42 @@ +- [Cat API](#cat-api) + - [Cat Indices](#cat-indices) + - [Cat aliases](#cat-aliases) + - [Cat nodes](#cat-nodes) + - [Cat point in time segments](#cat-point-in-time-segments) + +# Cat API + +The CAT API is a human-readable interface that returns plain text instead of traditional JSON. + +## Cat Indices +The following sample code cat indices with required headers and sorted by creation date + +```java +IndicesRequest indicesRequest = new IndicesRequest.Builder() + .headers("index,health,status,pri,rep,doc.count,creation.date,creation.date.string").sort("creation.date").build(); +IndicesResponse indicesResponse = javaClient().cat().indices(indicesRequest); +``` + + +## Cat aliases +The following sample code cat aliases with name "test-alias" and sorted by index + +```java +AliasesRequest aliasesRequest = new AliasesRequest.Builder().name("test-alias").sort("index").build(); +AliasesResponse aliasesResponse = javaClient().cat().aliases(aliasesRequest); +``` + +## Cat nodes +The following sample code cat nodes sorted by cpu + +```java +NodesResponse nodesResponse = javaClient().cat().nodes(r -> r.sort("cpu")); +``` + +## Cat point in time segments +Similarly to the CAT Segments API, the PIT Segments API provides low-level information about the disk utilization of a PIT by describing its Lucene segments. + +```java +SegmentsResponse pitSegmentsResponse = javaClient().cat() + .pitSegments(r -> r.headers("index,shard,id,segment,size")); +``` \ No newline at end of file diff --git a/guides/data_stream.md b/guides/data_stream.md new file mode 100644 index 0000000000..7c49807f8c --- /dev/null +++ b/guides/data_stream.md @@ -0,0 +1,54 @@ +- [Data Stream API](#data-stream-api) + - [Create a data stream](#create-a-data-stream) + - [Get data stream](#get-data-stream) + - [Data stream stats](#data-stream-stats) + - [Delete data stream and backing indices](#delete-data-stream-and-backing-indices) + +# Data Stream API + +## Create a data stream +Before creating a data stream, you need to create an index template which configures a set of indices as a data stream. +A data stream must have a timestamp field. If not specified, OpenSearch uses `@timestamp` as the default timestamp field name. + +The following sample code creates an index template for data stream with a custom timestamp field, and creates a data stream +which matches the name pattern specified in the index template. +```java +String dataStreamIndexTemplateName = "sample-data-stream-template"; +String timestampFieldName = "my_timestamp_field"; +String namePattern = "sample-data-stream-*"; +String dataStreamName = "sample-data-stream-1"; + +// Create an index template which configures data stream +PutIndexTemplateRequest putIndexTemplateRequest = new PutIndexTemplateRequest.Builder() + .name(dataStreamIndexTemplateName) + .indexPatterns(namePattern) + .dataStream(new DataStream.Builder() + .timestampField(t -> t.name(timestampFieldName)) + .build()) + .build(); +PutIndexTemplateResponse putIndexTemplateResponse = client.indices().putIndexTemplate(putIndexTemplateRequest); + +// Create a data stream +CreateDataStreamRequest createDataStreamRequest = new CreateDataStreamRequest.Builder().name(dataStreamName).build(); +CreateDataStreamResponse createDataStreamResponse = client.indices().createDataStream(createDataStreamRequest); +``` + +## Get data stream +```java +GetDataStreamRequest getDataStreamRequest = new GetDataStreamRequest.Builder().name(dataStreamName).build(); +GetDataStreamResponse getDataStreamResponse = client.indices().getDataStream(getDataStreamRequest); +``` + +## Data stream stats +```java +DataStreamsStatsRequest dataStreamsStatsRequest = new DataStreamsStatsRequest.Builder().name(dataStreamName).build(); +DataStreamsStatsResponse dataStreamsStatsResponse = client.indices().dataStreamsStats(dataStreamsStatsRequest); +``` + +## Delete data stream and backing indices +```java +DeleteDataStreamRequest deleteDataStreamRequest = new DeleteDataStreamRequest.Builder().name(dataStreamName).build(); +DeleteDataStreamResponse deleteDataStreamResponse = client.indices().deleteDataStream(deleteDataStreamRequest); +``` + +You can find a working sample of the above code in [DataStreamBasics.java](../samples/src/main/java/org/opensearch/client/samples/DataStreamBasics.java). \ No newline at end of file diff --git a/guides/index_templates.md b/guides/index_templates.md new file mode 100644 index 0000000000..43cf79fd2d --- /dev/null +++ b/guides/index_templates.md @@ -0,0 +1,79 @@ +- [Index templates](#index-templates) + - [Setup](#setup) + + +# Index templates + +Index templates let you initialize new indexes with predefined mappings and settings. +For example, if you continuously index log data, you can define an index template so that all of these indexes have +the same number of shards and replicas. + +## Setup + +To get started, first create a client, create an index template. In this example, an index template is created, +composed of two component templates: + +- `index-settings` which specifies index settings such as shard configuration and slowlog settings +- `index-mappings` which specifies the field mappings + +```java +import org.apache.hc.core5.http.HttpHost; + +final HttpHost[] hosts = new HttpHost[] { + new HttpHost("http", "localhost", 9200) + }; + +final OpenSearchTransport transport = ApacheHttpClient5TransportBuilder + .builder(hosts) + .setMapper(new JacksonJsonpMapper()) + .build(); +OpenSearchClient client = new OpenSearchClient(transport); + +final var indexSettingsComponentTemplate = "index-settings"; +PutComponentTemplateRequest putComponentTemplateRequest = PutComponentTemplateRequest.of( + c -> c.name(indexSettingsComponentTemplate) + .settings( + s -> s.numberOfShards("2") + .numberOfReplicas("1") + .indexing( + i -> i.slowlog( + sl -> sl.level("info") + .reformat(true) + .threshold(th -> th.index(ith -> ith.warn(Time.of(t -> t.time("2s"))))) + ) + ) + .search( + se -> se.slowlog(sl -> sl.level("info").threshold(th -> th.query(q -> q.warn(Time.of(t -> t.time("2s")))))) + ) + ) +); +client.cluster().putComponentTemplate(putComponentTemplateRequest); + +final var indexMappingsComponentTemplate = "index-mappings"; +putComponentTemplateRequest = PutComponentTemplateRequest.of( + c -> c.name(indexMappingsComponentTemplate).mappings(m -> m.properties("age", p -> p.integer(i -> i))) +); +client.cluster().putComponentTemplate(putComponentTemplateRequest); + +final var indexTemplateName = "my-index-template"; +PutIndexTemplateRequest putIndexTemplateRequest = PutIndexTemplateRequest.of( + it -> it.name(indexTemplateName) + .indexPatterns("my-index-*") + .composedOf(List.of(indexSettingsComponentTemplate, indexMappingsComponentTemplate)) +); + +client.indices().putIndexTemplate(putIndexTemplateRequest); +``` + +## Usage + +Create an index with a name that matches the index template's `indexPatterns` + +```java +String indexName = "my-index-1"; +client.indices().create(CreateIndexRequest.of(c -> c.index(indexName))); +``` + +The index will be created with the index settings and mappings defined by the `my-index-template` index template. + +You can find a working sample of the above code in [IndexTemplates.java](../samples/src/main/java/org/opensearch/client/samples/IndexTemplates.java). \ No newline at end of file diff --git a/guides/plugins/knn.md b/guides/plugins/knn.md new file mode 100644 index 0000000000..a2c3db72b8 --- /dev/null +++ b/guides/plugins/knn.md @@ -0,0 +1,288 @@ +- [k-NN Plugin](#k-nn-plugin) + - [Basic Approximate k-NN](#basic-approximate-k-nn) + - [Create an Index](#create-an-index) + - [Index Vectors](#index-vectors) + - [Search for Nearest Neighbors](#search-for-nearest-neighbors) + - [Approximate k-NN with a Boolean Filter](#approximate-k-nn-with-a-boolean-filter) + - [Approximate k-NN with an Efficient Filter](#approximate-k-nn-with-an-efficient-filter) + - [Exact k-NN with a scoring script](#exact-k-nn-with-a-scoring-script) + - [Exact k-NN with the Painless scripting extensions](#exact-k-nn-with-the-painless-scripting-extensions) + +# k-NN Plugin + +Short for k-nearest neighbors, the k-NN plugin enables users to search for the k-nearest neighbors to a query point across an index of vectors. See the [plugin's documentation](https://opensearch.org/docs/latest/search-plugins/knn/index/) for more information. + +## Basic Approximate k-NN + +In the following example we create a 5-dimensional k-NN index with random data. You can find a synchronous version of this working sample in [samples/src/main/java/org/opensearch/client/samples/knn/KnnBasics.java](../../samples/src/main/java/org/opensearch/client/samples/knn/KnnBasics.java). + +```bash +$ ./gradlew :samples:run -Dsamples.mainClass=knn.KnnBasics + +[Main] INFO - Running main class: org.opensearch.client.samples.knn.KnnBasics +[KnnBasics] INFO - Server: opensearch@2.7.0 +[KnnBasics] INFO - Creating index my-index +[KnnBasics] INFO - Indexing 10 vectors +[KnnBasics] INFO - Waiting for indexing to finish +[KnnBasics] INFO - Searching for vector [0.67, 0.67, 0.37, 0.0, 0.72] +[KnnBasics] INFO - Found {values=[0.32, 0.96, 0.41, 0.04, 0.9]} with score 0.8050233 +[KnnBasics] INFO - Found {values=[0.04, 0.58, 0.13, 0.27, 0.37]} with score 0.6031363 +[KnnBasics] INFO - Found {values=[0.96, 0.88, 0.8, 0.41, 0.18]} with score 0.5640794 +[KnnBasics] INFO - Deleting index my-index +``` + +### Create an Index + +```java +final var indexName = "my-index"; +final var dimensions = 5; + +client.indices().create(r -> r + .index(indexName) + .settings(s -> s.knn(true)) + .mappings(m -> m + .properties("values", p -> p + .knnVector(k -> k.dimension(dimensions))))); +``` + +### Index Vectors + +Given the following document class definition: + +```java +public static class Doc { + private float[] values; + + public Doc() {} + + public Doc(float[] values) { + this.values = values; + } + + public static Doc rand(int dimensions) { + var values = new float[dimensions]; + for (var i = 0; i < dimensions; ++i) { + values[i] = Math.round(Math.random() * 100.0) / 100.0f; + } + return new Doc(values); + } + + // Getters/Setters & toString elided +} +``` + +Create 10 random vectors and insert them using the bulk API: + +```java +final var nVectors = 10; +var bulkRequest = new BulkRequest.Builder(); +for (var i = 0; i < nVectors; ++i) { + var id = Integer.toString(i); + var doc = Doc.rand(dimensions); + bulkRequest.operations(b -> b + .index(o -> o + .index(indexName) + .id(id) + .document(doc))); +} + +client.bulk(bulkRequest.build()); + +client.indices().refresh(i -> i.index(indexName)); +``` + +### Search for Nearest Neighbors + +Create a random vector of the same size and search for its nearest neighbors. + +```java +final var searchVector = new float[dimensions]; +for (var i = 0; i < dimensions; ++i) { + searchVector[i] = Math.round(Math.random() * 100.0) / 100.0f; +} + +var searchResponse = client.search(s -> s + .index(indexName) + .query(q -> q + .knn(k -> k + .field("values") + .vector(searchVector) + .k(3))), + Doc.class); + +for (var hit : searchResponse.hits().hits()) { + System.out.println(hit.source()); +} +``` + +## Approximate k-NN with a Boolean Filter + +In the [KnnBooleanFilter.java sample](../../samples/src/main/java/org/opensearch/client/samples/knn/KnnBooleanFilter.java) we create a 5-dimensional k-NN index with random data and a `metadata` field that contains a book genre (e.g. `fiction`). The search query is a k-NN search filtered by genre. The filter clause is outside the k-NN query clause and is applied after the k-NN search. + +```java +var searchResponse = client.search(s -> s + .index(indexName) + .query(q -> q + .bool(b -> b + .filter(f -> f + .bool(b2 -> b2 + .must(m -> m + .term(t -> t + .field("metadata.genre") + .value(v -> v.stringValue(searchGenre)))))) + .must(m -> m + .knn(k -> k + .field("values") + .vector(searchVector) + .k(5))))), + Doc.class); +``` + +```bash +$ ./gradlew :samples:run -Dsamples.mainClass=knn.KnnBooleanFilter + +[Main] INFO - Running main class: org.opensearch.client.samples.knn.KnnBooleanFilter +[KnnBooleanFilter] INFO - Server: opensearch@2.7.0 +[KnnBooleanFilter] INFO - Creating index my-index +[KnnBooleanFilter] INFO - Indexing 3000 vectors +[KnnBooleanFilter] INFO - Waiting for indexing to finish +[KnnBooleanFilter] INFO - Searching for vector [0.18, 0.71, 0.44, 0.03, 0.42] with the 'drama' genre +[KnnBooleanFilter] INFO - Found {values=[0.21, 0.58, 0.55, 0.09, 0.45], metadata={genre=drama}} with score 0.966744 +[KnnBooleanFilter] INFO - Deleting index my-index +``` + +## Approximate k-NN with an Efficient Filter + +In the [KnnEfficientFilter.java sample](../../samples/src/main/java/org/opensearch/client/samples/knn/KnnEfficientFilter.java) we implement the example in [the k-NN documentation](https://opensearch.org/docs/latest/search-plugins/knn/filter-search-knn/), which creates an index that uses the Lucene engine and HNSW as the method in the mapping, containing hotel location and parking data, then search for the top three hotels near the location with the coordinates `[5, 4]` that are rated between 8 and 10, inclusive, and provide parking. + +```java +var searchResponse = client.search(s -> s + .index(indexName) + .size(3) + .query(q -> q + .knn(k -> k + .field("location") + .vector(searchLocation) + .k(3) + .filter(Query.of(f -> f + .bool(b -> b + .must(m -> m + .range(r -> r + .field("rating") + .gte(JsonData.of(searchRatingMin)) + .lte(JsonData.of(searchRatingMax)))) + .must(m -> m + .term(t -> t + .field("parking") + .value(FieldValue.of(searchParking))))))))), + Hotel.class); +``` + +```bash +$ ./gradlew :samples:run -Dsamples.mainClass=knn.KnnEfficientFilter + +[Main] INFO - Running main class: org.opensearch.client.samples.knn.KnnEfficientFilter +[KnnEfficientFilter] INFO - Server: opensearch@2.7.0 +[KnnEfficientFilter] INFO - Creating index hotels-index +[KnnEfficientFilter] INFO - Indexing hotel {location=[5.2, 4.0], parking=true, rating=5} with id 1 +[KnnEfficientFilter] INFO - Indexing hotel {location=[5.2, 3.9], parking=false, rating=4} with id 2 +[KnnEfficientFilter] INFO - Indexing hotel {location=[4.9, 3.4], parking=true, rating=9} with id 3 +[KnnEfficientFilter] INFO - Indexing hotel {location=[4.2, 4.6], parking=false, rating=6} with id 4 +[KnnEfficientFilter] INFO - Indexing hotel {location=[3.3, 4.5], parking=true, rating=8} with id 5 +[KnnEfficientFilter] INFO - Indexing hotel {location=[6.4, 3.4], parking=true, rating=9} with id 6 +[KnnEfficientFilter] INFO - Indexing hotel {location=[4.2, 6.2], parking=true, rating=5} with id 7 +[KnnEfficientFilter] INFO - Indexing hotel {location=[2.4, 4.0], parking=true, rating=8} with id 8 +[KnnEfficientFilter] INFO - Indexing hotel {location=[1.4, 3.2], parking=false, rating=5} with id 9 +[KnnEfficientFilter] INFO - Indexing hotel {location=[7.0, 9.9], parking=true, rating=9} with id 10 +[KnnEfficientFilter] INFO - Indexing hotel {location=[3.0, 2.3], parking=false, rating=6} with id 11 +[KnnEfficientFilter] INFO - Indexing hotel {location=[5.0, 1.0], parking=true, rating=3} with id 12 +[KnnEfficientFilter] INFO - Indexing 12 documents +[KnnEfficientFilter] INFO - Waiting for indexing to finish +[KnnEfficientFilter] INFO - Searching for hotel near [5.0, 4.0] with rating >=8,<=10 and parking=true +[KnnEfficientFilter] INFO - Found {location=[4.9, 3.4], parking=true, rating=9} with score 0.72992706 +[KnnEfficientFilter] INFO - Found {location=[6.4, 3.4], parking=true, rating=9} with score 0.3012048 +[KnnEfficientFilter] INFO - Found {location=[3.3, 4.5], parking=true, rating=8} with score 0.24154587 +[KnnEfficientFilter] INFO - Deleting index hotels-index +``` + +## Exact k-NN with a scoring script + +In the [KnnScriptScore.java sample](../../samples/src/main/java/org/opensearch/client/samples/knn/KnnScriptScore.java) we create a 5-dimensional k-NN index with random data. The search query uses the [k-NN scoring script](https://opensearch.org/docs/latest/search-plugins/knn/knn-score-script/) to calculate exact nearest neighbors. + +```java +var searchResponse = client.search(s -> s + .index(indexName) + .query(q -> q + .scriptScore(ss -> ss + .query(qq -> qq.matchAll(m -> m)) + .script(sss -> sss + .inline(i -> i + .source("knn_score") + .lang("knn") + .params("field", JsonData.of("values")) + .params("query_value", JsonData.of(searchVector)) + .params("space_type", JsonData.of("cosinesimil")))))), + Doc.class); +``` + +```bash +$ ./gradlew :samples:run -Dsamples.mainClass=knn.KnnScriptScore + +[Main] INFO - Running main class: org.opensearch.client.samples.knn.KnnScriptScore +[KnnScriptScore] INFO - Server: opensearch@2.7.0 +[KnnScriptScore] INFO - Creating index my-index +[KnnScriptScore] INFO - Indexing 10 vectors +[KnnScriptScore] INFO - Waiting for indexing to finish +[KnnScriptScore] INFO - Searching for vector [0.94, 0.1, 0.39, 0.63, 0.42] +[KnnScriptScore] INFO - Found {values=[0.66, 0.23, 0.15, 0.44, 0.13]} with score 1.9564294 +[KnnScriptScore] INFO - Found {values=[0.94, 0.05, 0.86, 0.68, 0.05]} with score 1.90958 +[KnnScriptScore] INFO - Found {values=[0.88, 0.72, 0.29, 0.48, 0.56]} with score 1.8788767 +[KnnScriptScore] INFO - Found {values=[0.97, 0.99, 0.66, 0.61, 0.91]} with score 1.847905 +[KnnScriptScore] INFO - Found {values=[0.18, 0.29, 0.43, 0.63, 0.25]} with score 1.7819176 +[KnnScriptScore] INFO - Found {values=[0.35, 0.2, 0.62, 0.4, 0.96]} with score 1.7673628 +[KnnScriptScore] INFO - Found {values=[0.34, 0.59, 0.05, 0.47, 0.54]} with score 1.7316635 +[KnnScriptScore] INFO - Found {values=[0.55, 0.98, 0.07, 0.57, 0.06]} with score 1.6385877 +[KnnScriptScore] INFO - Found {values=[0.03, 0.72, 0.89, 0.83, 0.46]} with score 1.6147845 +[KnnScriptScore] INFO - Found {values=[0.17, 0.81, 0.09, 0.21, 0.3]} with score 1.4616101 +[KnnScriptScore] INFO - Deleting index my-index +``` + +## Exact k-NN with the Painless scripting extensions + +In the [KnnPainlessScript.java sample](../../samples/src/main/java/org/opensearch/client/samples/knn/KnnPainlessScript.java) we create a 5-dimensional k-NN index with random data. The search query uses the [k-NN Painless extensions](https://opensearch.org/docs/latest/search-plugins/knn/painless-functions/) to calculate exact nearest neighbors. + +```java +var searchResponse = client.search(s -> s + .index(indexName) + .query(q -> q + .scriptScore(ss -> ss + .query(qq -> qq.matchAll(m -> m)) + .script(sss -> sss + .inline(i -> i + .source("1.0 + cosineSimilarity(params.query_value, doc[params.field])") + .params("field", JsonData.of("values")) + .params("query_value", JsonData.of(searchVector)))))), + Doc.class); +``` + +```bash +$ ./gradlew :samples:run -Dsamples.mainClass=knn.KnnPainlessScript + +[Main] INFO - Running main class: org.opensearch.client.samples.knn.KnnPainlessScript +[KnnPainlessScript] INFO - Server: opensearch@2.7.0 +[KnnPainlessScript] INFO - Creating index my-index +[KnnPainlessScript] INFO - Indexing 10 vectors +[KnnPainlessScript] INFO - Waiting for indexing to finish +[KnnPainlessScript] INFO - Searching for vector [0.57, 0.86, 0.37, 0.07, 0.38] +[KnnPainlessScript] INFO - Found {values=[1.0, 0.6, 0.66, 0.03, 0.18]} with score 1.8911908 +[KnnPainlessScript] INFO - Found {values=[0.4, 0.39, 0.63, 0.09, 0.39]} with score 1.8776901 +[KnnPainlessScript] INFO - Found {values=[0.32, 0.98, 0.7, 0.7, 0.77]} with score 1.8616674 +[KnnPainlessScript] INFO - Found {values=[0.93, 0.35, 0.27, 0.45, 0.81]} with score 1.789043 +[KnnPainlessScript] INFO - Found {values=[0.81, 0.36, 0.87, 0.78, 0.56]} with score 1.7457235 +[KnnPainlessScript] INFO - Found {values=[0.55, 0.19, 0.61, 0.42, 0.4]} with score 1.743325 +[KnnPainlessScript] INFO - Found {values=[0.12, 0.54, 0.09, 0.83, 0.28]} with score 1.6045148 +[KnnPainlessScript] INFO - Found {values=[0.0, 0.04, 0.63, 0.07, 0.9]} with score 1.479921 +[KnnPainlessScript] INFO - Found {values=[0.41, 0.05, 0.52, 1.0, 0.18]} with score 1.4306322 +[KnnPainlessScript] INFO - Found {values=[0.22, 0.1, 0.59, 0.89, 0.15]} with score 1.4274814 +[KnnPainlessScript] INFO - Deleting index my-index +``` \ No newline at end of file diff --git a/guides/point_in_time.md b/guides/point_in_time.md new file mode 100644 index 0000000000..f2fa36118b --- /dev/null +++ b/guides/point_in_time.md @@ -0,0 +1,53 @@ +- [Point-in-Time](#point-in-time) + - [Point-In-Time API](#point-in-time-api) + - [Creating a point in time](#creating-a-point-in-time) + - [List all point in time](#list-all-point-in-time) + - [Delete point in time](#delete-point-in-time) + +# Point-in-Time + +[Point in Time (PIT)](https://opensearch.org/docs/latest/search-plugins/point-in-time/) lets you run different queries against a dataset that is fixed in time. + +## Point-In-Time API + +### Creating a point in time + +To create a PIT, first create an index. + +``` +java +String index = "sample-index"; +CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(index).build(); +client.indices().create(createIndexRequest); +``` + +To create a PIT, the keep_alive query parameter is required; it specifies how long to keep a PIT. + +```java +CreatePitRequest createPitRequest = new CreatePitRequest.Builder() + .targetIndexes(Collections.singletonList(index)) + .keepAlive(new Time.Builder().time("100m").build()).build(); + +CreatePitResponse createPitResponse = client.createPit(createPitRequest); +``` + +### List all point in time + +Returns all PITs in the OpenSearch cluster. + +```java +ListAllPitResponse listAllPitResponse = client.listAllPit(); +``` + +### Delete point in time + +Deletes one, several, or all PITs. PITs are automatically deleted when the keep_alive time period elapses. However, to deallocate resources, you can delete a PIT using the Delete PIT API. The Delete PIT API supports deleting a list of PITs by ID or deleting all PITs at once. + +```java +DeletePitRequest deletePitRequest = new DeletePitRequest.Builder() + .pitId(Collections.singletonList(createPitResponse.pitId())).build(); + +DeletePitResponse deletePitResponse = client.deletePit(deletePitRequest); +``` + +You can find a working sample of the above code in [PointInTime.java](../samples/src/main/java/org/opensearch/client/samples/PointInTime.java). \ No newline at end of file diff --git a/guides/search.md b/guides/search.md new file mode 100644 index 0000000000..d343b30420 --- /dev/null +++ b/guides/search.md @@ -0,0 +1,283 @@ +- [Search](#search) + - [Setup](#setup) + - [Search API](#search-api) + - [Basic Search](#basic-search) + - [Get raw JSON results](#get-raw-json-results) + - [Search documents using a match query](#search-documents-using-a-match-query) + - [Search documents using suggesters](#search-documents-using-suggesters) + - [Using completion suggester](#using-completion-suggester) + - [Using term suggester](#using-term-suggester) + - [Using phrase suggester](#using-phrase-suggester) + - [Aggregations](#aggregations) + +# Search + +OpenSearch provides a powerful search API that allows you to search for documents in an index. The search API supports a number of parameters that allow you to customize the search operation. In this guide, we will explore the search API and its parameters. + +## Setup + +To get started, first create a client, create an index and index some documents: + +```java +import org.apache.hc.core5.http.HttpHost; + +final HttpHost[] hosts = new HttpHost[] { + new HttpHost("http", "localhost", 9200) + }; + +final OpenSearchTransport transport = ApacheHttpClient5TransportBuilder + .builder(hosts) + .setMapper(new JacksonJsonpMapper()) + .build(); +OpenSearchClient client = new OpenSearchClient(transport); + +String index = "sample-index"; +CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(index).build(); +client.indices().create(createIndexRequest); + +IndexData indexData = new IndexData("Document 1", "Text for document 1"); +IndexRequest indexRequest = new IndexRequest.Builder().index(index).id("1").document(indexData).build(); +client.index(indexRequest); + +indexData = new IndexData("Document 2", "Text for document 2"); +indexRequest = new IndexRequest.Builder().index(index).id("2").document(indexData).build(); +client.index(indexRequest); +``` + +[IndexData](../samples/src/main/java/org/opensearch/client/samples/util/IndexData.java) refers to sample data class. + +## Search API + +### Basic Search + +```java +SearchResponse searchResponse = client.search(s -> s.index(index), IndexData.class); +for (int i = 0; i < searchResponse.hits().hits().size(); i++) { + System.out.println(searchResponse.hits().hits().get(i).source()); +} +``` + +#### Get raw JSON results + +When the target class is not defined or if the response result is a semi-structured data not tied to an object definition, use a raw JSON data representation as the target class. For example, the below snippet uses `ObjectNode` from jackson. + +```java +SearchResponse searchResponse = client.search(b -> b.index(index), ObjectNode.class); +for (int i = 0; i < searchResponse.hits().hits().size(); i++) { + System.out.println(searchResponse.hits().hits().get(i).source()); +} +``` + +### Search documents using a match query + +```java +SearchRequest searchRequest = new SearchRequest.Builder().query(q -> q.match(m -> m.field("text") + .query(FieldValue.of("Text for document 2")))) + .build(); + +SearchResponse searchResponse = client.search(searchRequest, IndexData.class); +for (int i = 0; i < searchResponse.hits().hits().size(); i++) { + System.out.println(searchResponse.hits().hits().get(i).source()); +} +``` + +### Search documents using suggesters + +[AppData](../samples/src/main/java/org/opensearch/client/samples/util/AppData.java) refers to the sample data class used in the below samples. + +#### Using completion suggester + +```java +String index = "completion-suggester"; + +Property intValueProp = new Property.Builder() + .long_(v -> v) + .build(); +Property msgCompletionProp = new Property.Builder() + .completion(c -> c) + .build(); +client.indices().create(c -> c + .index(index) + .mappings(m -> m + .properties("intValue", intValueProp) + .properties("msg", msgCompletionProp))); + +AppData appData = new AppData(); +appData.setIntValue(1337); +appData.setMsg("foo"); + +client.index(b -> b + .index(index) + .id("1") + .document(appData) + .refresh(Refresh.True)); + +appData.setIntValue(1338); +appData.setMsg("foobar"); + +client.index(b -> b + .index(index) + .id("2") + .document(appData) + .refresh(Refresh.True)); + +String suggesterName = "msgSuggester"; + +CompletionSuggester completionSuggester = FieldSuggesterBuilders.completion() + .field("msg") + .size(1) + .build(); +FieldSuggester fieldSuggester = new FieldSuggester.Builder().prefix("foo") + .completion(completionSuggester) + .build(); +Suggester suggester = new Suggester.Builder() + .suggesters(Collections.singletonMap(suggesterName, fieldSuggester)) + .build(); +SearchRequest searchRequest = new SearchRequest.Builder() + .index(index) + .suggest(suggester) + .build(); + +SearchResponse response = client.search(searchRequest, AppData.class); +``` + +#### Using term suggester + +```java +String index = "term-suggester"; + +// term suggester does not require a special mapping +client.indices().create(c -> c + .index(index)); + +AppData appData = new AppData(); +appData.setIntValue(1337); +appData.setMsg("foo"); + +client.index(b -> b + .index(index) + .id("1") + .document(appData) + .refresh(Refresh.True)); + +appData.setIntValue(1338); +appData.setMsg("foobar"); + +client.index(b -> b + .index(index) + .id("2") + .document(appData) + .refresh(Refresh.True)); + +String suggesterName = "msgSuggester"; + +TermSuggester termSuggester = FieldSuggesterBuilders.term() + .field("msg") + .size(1) + .build(); +FieldSuggester fieldSuggester = new FieldSuggester.Builder().text("fool") + .term(termSuggester) + .build(); +Suggester suggester = new Suggester.Builder() + .suggesters(Collections.singletonMap(suggesterName, fieldSuggester)) + .build(); +SearchRequest searchRequest = new SearchRequest.Builder() + .index(index) + .suggest(suggester) + .build(); + +SearchResponse response = client.search(searchRequest, AppData.class); +``` + +#### Using phrase suggester + +```java +String index = "test-phrase-suggester"; + +ShingleTokenFilter shingleTokenFilter = new ShingleTokenFilter.Builder().minShingleSize("2") + .maxShingleSize("3") + .build(); + +Analyzer analyzer = new Analyzer.Builder() + .custom(new CustomAnalyzer.Builder().tokenizer("standard") + .filter(Arrays.asList("lowercase", "shingle")).build()) + .build(); + +TokenFilter tokenFilter = new TokenFilter.Builder() + .definition(new TokenFilterDefinition.Builder() + .shingle(shingleTokenFilter).build()) + .build(); + +IndexSettingsAnalysis indexSettingsAnalysis = new IndexSettingsAnalysis.Builder() + .analyzer("trigram", analyzer) + .filter("shingle", tokenFilter) + .build(); + +IndexSettings settings = new IndexSettings.Builder().analysis(indexSettingsAnalysis).build(); + +TypeMapping mapping = new TypeMapping.Builder().properties("msg", new Property.Builder() + .text(new TextProperty.Builder().fields("trigram", new Property.Builder() + .text(new TextProperty.Builder().analyzer("trigram").build()) + .build()).build()) + .build()).build(); + +client.indices().create(c -> c + .index(index) + .settings(settings) + .mappings(mapping)); + +AppData appData = new AppData(); +appData.setIntValue(1337); +appData.setMsg("Design Patterns"); + +client.index(b -> b + .index(index) + .id("1") + .document(appData) + .refresh(Refresh.True)); + +appData.setIntValue(1338); +appData.setMsg("Software Architecture Patterns Explained"); + +client.index(b -> b + .index(index) + .id("2") + .document(appData) + .refresh(Refresh.True)); + +String suggesterName = "msgSuggester"; + +PhraseSuggester phraseSuggester = FieldSuggesterBuilders.phrase() + .field("msg.trigram") + .build(); +FieldSuggester fieldSuggester = new FieldSuggester.Builder().text("design paterns") + .phrase(phraseSuggester) + .build(); +Suggester suggester = new Suggester.Builder() + .suggesters(Collections.singletonMap(suggesterName, fieldSuggester)) + .build(); +SearchRequest searchRequest = new SearchRequest.Builder() + .index(index) + .suggest(suggester) + .build(); + +SearchResponse response = client.search(searchRequest, AppData.class); +``` + +### Aggregations + +```java +SearchRequest searchRequest = new SearchRequest.Builder().query(q -> q.match(m -> m.field("title") + .query(FieldValue.of("Document 1")))) + .aggregations("titles", new Aggregation.Builder().terms(t -> t.field("title.keyword")) + .build()) + .build(); + +SearchResponse searchResponse = client.search(searchRequest, IndexData.class); +for (Map.Entry entry : searchResponse.aggregations().entrySet()) { + System.out.println("Agg - " + entry.getKey()); + entry.getValue().sterms().buckets().array().forEach(b -> System.out.printf("%s : %d%n", b.key(), b.docCount())); +} +``` + +You can find a working sample of the above code in [Search.java](../samples/src/main/java/org/opensearch/client/samples/Search.java). \ No newline at end of file diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index 307c75393b..d3ff87a199 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -46,13 +46,18 @@ buildscript { plugins { java `java-library` - checkstyle `maven-publish` - id("com.github.jk1.dependency-license-report") version "1.19" + id("com.github.jk1.dependency-license-report") version "2.5" + id("org.owasp.dependencycheck") version "9.0.8" + id("com.diffplug.spotless") version "6.24.0" } -checkstyle { - toolVersion = "10.0" +apply(plugin = "org.owasp.dependencycheck") + +configurations { + all { + exclude(group = "software.amazon.awssdk", module = "third-party-jackson-core") + } } java { @@ -104,6 +109,10 @@ tasks.withType { } } +tasks.build { + dependsOn("spotlessJavaCheck") +} + tasks.test { systemProperty("tests.security.manager", "false") @@ -131,15 +140,17 @@ val integrationTest = task("integrationTest") { systemProperty("password", System.getProperty("password", "admin")) systemProperty("tests.awsSdk2support.domainHost", System.getProperty("tests.awsSdk2support.domainHost", null)) + systemProperty("tests.awsSdk2support.serviceName", + System.getProperty("tests.awsSdk2support.serviceName", "es")) systemProperty("tests.awsSdk2support.domainRegion", System.getProperty("tests.awsSdk2support.domainRegion", "us-east-1")) } dependencies { - val opensearchVersion = "2.3.0" - val jacksonVersion = "2.13.4" - val jacksonDatabindVersion = "2.13.4.2" + val opensearchVersion = "2.7.0" + val jacksonVersion = "2.15.2" + val jacksonDatabindVersion = "2.15.2" // Apache 2.0 implementation("org.opensearch.client", "opensearch-rest-client", opensearchVersion) @@ -152,7 +163,7 @@ dependencies { // Needed even if using Jackson to have an implementation of the Jsonp object model // EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 // https://github.com/eclipse-ee4j/parsson - api("org.eclipse.parsson:parsson:1.1.1") + api("org.eclipse.parsson:parsson:1.1.4") // EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 // http://json-b.net/ @@ -164,21 +175,27 @@ dependencies { implementation("com.fasterxml.jackson.core", "jackson-databind", jacksonDatabindVersion) testImplementation("com.fasterxml.jackson.datatype", "jackson-datatype-jakarta-jsonp", jacksonVersion) + // ApacheHttpClient5Transport dependencies (optional) + implementation("org.apache.httpcomponents.client5", "httpclient5", "5.3") + implementation("org.apache.httpcomponents.core5", "httpcore5", "5.2.4") + // For AwsSdk2Transport - "awsSdk2SupportImplementation"("software.amazon.awssdk","sdk-core","[2.15,3.0)") - "awsSdk2SupportImplementation"("software.amazon.awssdk","auth","[2.15,3.0)") + "awsSdk2SupportCompileOnly"("software.amazon.awssdk","sdk-core","[2.15,3.0)") + "awsSdk2SupportCompileOnly"("software.amazon.awssdk","auth","[2.15,3.0)") testImplementation("software.amazon.awssdk","sdk-core","[2.15,3.0)") testImplementation("software.amazon.awssdk","auth","[2.15,3.0)") testImplementation("software.amazon.awssdk","aws-crt-client","[2.15,3.0)") testImplementation("software.amazon.awssdk","apache-client","[2.15,3.0)") testImplementation("software.amazon.awssdk","sts","[2.15,3.0)") - + testImplementation("org.apache.logging.log4j", "log4j-api","[2.17.1,3.0)") + testImplementation("org.apache.logging.log4j", "log4j-core","[2.17.1,3.0)") + // EPL-2.0 OR BSD-3-Clause // https://eclipse-ee4j.github.io/yasson/ implementation("org.eclipse", "yasson", "2.0.2") // https://github.com/classgraph/classgraph - testImplementation("io.github.classgraph:classgraph:4.8.149") + testImplementation("io.github.classgraph:classgraph:4.8.161") // Eclipse 1.0 testImplementation("junit", "junit" , "4.13.2") { @@ -187,7 +204,7 @@ dependencies { } licenseReport { - renderers = arrayOf(SpdxReporter(File(rootProject.buildDir, "release/dependencies.csv"))) + renderers = arrayOf(SpdxReporter(rootProject.layout.buildDirectory.file("release/dependencies.csv").get().getAsFile())) excludeGroups = arrayOf("org.opensearch.client") } @@ -240,23 +257,42 @@ class SpdxReporter(val dest: File) : ReportRenderer { tasks.withType { doLast { ant.withGroovyBuilder { - "checksum"("algorithm" to "md5", "file" to archivePath) - "checksum"("algorithm" to "sha1", "file" to archivePath) - "checksum"("algorithm" to "sha-256", "file" to archivePath, "fileext" to ".sha256") - "checksum"("algorithm" to "sha-512", "file" to archivePath, "fileext" to ".sha512") + "checksum"("algorithm" to "md5", "file" to archiveFile.get()) + "checksum"("algorithm" to "sha1", "file" to archiveFile.get()) + "checksum"("algorithm" to "sha-256", "file" to archiveFile.get(), "fileext" to ".sha256") + "checksum"("algorithm" to "sha-512", "file" to archiveFile.get(), "fileext" to ".sha512") } } } +spotless { + java { + + target("**/*.java") + + // Use the default importOrder configuration + importOrder() + removeUnusedImports() + + eclipse().configFile("../buildSrc/formatterConfig.xml") + + trimTrailingWhitespace() + endWithNewline() + } +} + publishing { repositories{ if (version.toString().endsWith("SNAPSHOT")) { maven("https://aws.oss.sonatype.org/content/repositories/snapshots/") { - name = "snapshotRepo" - credentials(PasswordCredentials::class) + name = "Snapshots" + credentials { + username = System.getenv("SONATYPE_USERNAME") + password = System.getenv("SONATYPE_PASSWORD") + } } } - maven("${rootProject.buildDir}/repository") { + maven(rootProject.layout.buildDirectory.dir("repository")) { name = "localRepo" } } diff --git a/java-client/src/main/java/org/opensearch/client/ApiClient.java b/java-client/src/main/java/org/opensearch/client/ApiClient.java index 1938dea4bb..327fc235ec 100644 --- a/java-client/src/main/java/org/opensearch/client/ApiClient.java +++ b/java-client/src/main/java/org/opensearch/client/ApiClient.java @@ -32,12 +32,11 @@ package org.opensearch.client; -import org.opensearch.client.transport.TransportOptions; -import org.opensearch.client.transport.Transport; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapperBase; - -import javax.annotation.Nullable; +import org.opensearch.client.transport.Transport; +import org.opensearch.client.transport.TransportOptions; public abstract class ApiClient> { diff --git a/java-client/src/main/java/org/opensearch/client/json/AttributedJsonpMapper.java b/java-client/src/main/java/org/opensearch/client/json/AttributedJsonpMapper.java index 92eb9d0b8f..baf834324a 100644 --- a/java-client/src/main/java/org/opensearch/client/json/AttributedJsonpMapper.java +++ b/java-client/src/main/java/org/opensearch/client/json/AttributedJsonpMapper.java @@ -72,7 +72,7 @@ public boolean ignoreUnknownFields() { @SuppressWarnings("unchecked") public T attribute(String name) { if (this.name.equals(name)) { - return (T)this.value; + return (T) this.value; } else { return mapper.attribute(name); } diff --git a/java-client/src/main/java/org/opensearch/client/json/BuildFunctionDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/BuildFunctionDeserializer.java index 677fb94098..aeb22671c2 100644 --- a/java-client/src/main/java/org/opensearch/client/json/BuildFunctionDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/BuildFunctionDeserializer.java @@ -33,7 +33,6 @@ package org.opensearch.client.json; import jakarta.json.stream.JsonParser; - import java.util.function.Function; /** diff --git a/java-client/src/main/java/org/opensearch/client/json/DelegatingDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/DelegatingDeserializer.java index 84e96ef5dd..1cf864be7b 100644 --- a/java-client/src/main/java/org/opensearch/client/json/DelegatingDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/DelegatingDeserializer.java @@ -33,7 +33,6 @@ package org.opensearch.client.json; import jakarta.json.stream.JsonParser; - import java.util.EnumSet; public abstract class DelegatingDeserializer implements JsonpDeserializer { @@ -68,7 +67,7 @@ public T deserialize(JsonParser parser, JsonpMapper mapper, JsonParser.Event eve */ public static JsonpDeserializer unwrap(JsonpDeserializer deserializer) { while (deserializer instanceof DelegatingDeserializer) { - deserializer = ((DelegatingDeserializer) deserializer).unwrap(); + deserializer = ((DelegatingDeserializer) deserializer).unwrap(); } return deserializer; } diff --git a/java-client/src/main/java/org/opensearch/client/json/DelegatingJsonParser.java b/java-client/src/main/java/org/opensearch/client/json/DelegatingJsonParser.java new file mode 100644 index 0000000000..c1b5b5c303 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/json/DelegatingJsonParser.java @@ -0,0 +1,136 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.json; + +import jakarta.json.JsonArray; +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; +import jakarta.json.stream.JsonLocation; +import jakarta.json.stream.JsonParser; +import java.math.BigDecimal; +import java.util.Map; +import java.util.stream.Stream; + +public abstract class DelegatingJsonParser implements JsonParser { + + private final JsonParser parser; + + public DelegatingJsonParser(JsonParser parser) { + this.parser = parser; + } + + @Override + public boolean hasNext() { + return parser.hasNext(); + } + + @Override + public Event next() { + return parser.next(); + } + + @Override + public String getString() { + return parser.getString(); + } + + @Override + public boolean isIntegralNumber() { + return parser.isIntegralNumber(); + } + + @Override + public int getInt() { + return parser.getInt(); + } + + @Override + public long getLong() { + return parser.getLong(); + } + + @Override + public BigDecimal getBigDecimal() { + return parser.getBigDecimal(); + } + + @Override + public JsonLocation getLocation() { + return parser.getLocation(); + } + + @Override + public JsonObject getObject() { + return parser.getObject(); + } + + @Override + public JsonValue getValue() { + return parser.getValue(); + } + + @Override + public JsonArray getArray() { + return parser.getArray(); + } + + @Override + public Stream getArrayStream() { + return parser.getArrayStream(); + } + + @Override + public Stream> getObjectStream() { + return parser.getObjectStream(); + } + + @Override + public Stream getValueStream() { + return parser.getValueStream(); + } + + @Override + public void skipArray() { + parser.skipArray(); + } + + @Override + public void skipObject() { + parser.skipObject(); + } + + @Override + public void close() { + parser.close(); + } +} diff --git a/java-client/src/main/java/org/opensearch/client/json/ExternallyTaggedUnion.java b/java-client/src/main/java/org/opensearch/client/json/ExternallyTaggedUnion.java index 84a6e6e7e4..4d5b954539 100644 --- a/java-client/src/main/java/org/opensearch/client/json/ExternallyTaggedUnion.java +++ b/java-client/src/main/java/org/opensearch/client/json/ExternallyTaggedUnion.java @@ -32,49 +32,66 @@ package org.opensearch.client.json; -import org.opensearch.client.util.TaggedUnion; +import static jakarta.json.stream.JsonParser.Event; + import jakarta.json.stream.JsonGenerator; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParsingException; - +import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.function.BiFunction; - -import static jakarta.json.stream.JsonParser.Event; +import java.util.function.Function; +import javax.annotation.Nullable; +import org.opensearch.client.util.TaggedUnion; /** * Utilities for union types whose discriminant is not directly part of the structure, either as an enclosing property name or as - * an inner property. This is used for Elasticsearch aggregation results and suggesters, using the {@code typed_keys} parameter that + * an inner property. This is used for OpenSearch aggregation results and suggesters, using the {@code typed_keys} parameter that * encodes a name+type in a single JSON property. * */ -public interface ExternallyTaggedUnion { +public class ExternallyTaggedUnion { + + private ExternallyTaggedUnion() {} /** * A deserializer for externally-tagged unions. Since the union variant discriminant is provided externally, this cannot be a * regular {@link JsonpDeserializer} as the caller has to provide the discriminant value. */ - class Deserializer, Member> { + public static class Deserializer, Member> { private final Map> deserializers; - private final BiFunction unionCtor; + private final Function unionCtor; + @Nullable + private final BiFunction unKnownUnionCtor; - public Deserializer(Map> deserializers, BiFunction unionCtor) { + public Deserializer(Map> deserializers, Function unionCtor) { this.deserializers = deserializers; this.unionCtor = unionCtor; + this.unKnownUnionCtor = null; } - /** - * Deserialize a union value, given its type. - */ - public Union deserialize(String type, JsonParser parser, JsonpMapper mapper) { + public Deserializer( + Map> deserializers, + Function unionCtor, + BiFunction unKnownUnionCtor + ) { + this.deserializers = deserializers; + this.unionCtor = unionCtor; + this.unKnownUnionCtor = unKnownUnionCtor; + } + + public Union deserialize(String type, JsonParser parser, JsonpMapper mapper, Event event) { JsonpDeserializer deserializer = deserializers.get(type); if (deserializer == null) { - throw new JsonParsingException("Unknown variant type '" + type + "'", parser.getLocation()); + if (unKnownUnionCtor != null) { + return unKnownUnionCtor.apply(type, JsonData._DESERIALIZER.deserialize(parser, mapper, event)); + } } - return unionCtor.apply(type, deserializer.deserialize(parser, mapper)); + return unionCtor.apply(deserializer.deserialize(parser, mapper, event)); } /** @@ -86,8 +103,9 @@ public TypedKeysDeserializer typedKeys() { } } - class TypedKeysDeserializer> extends JsonpDeserializerBase> { + public static class TypedKeysDeserializer> extends JsonpDeserializerBase> { Deserializer deserializer; + protected TypedKeysDeserializer(Deserializer deser) { super(EnumSet.of(Event.START_OBJECT)); this.deserializer = deser; @@ -115,15 +133,47 @@ public void deserializeEntry(String key, JsonParser parser, JsonpMapper mapper, String type = key.substring(0, hashPos); String name = key.substring(hashPos + 1); - targetMap.put(name, deserializer.deserialize(type, parser, mapper)); + targetMap.put(name, deserializer.deserialize(type, parser, mapper, parser.next())); } } + public static > JsonpDeserializer>> arrayDeserializer( + TypedKeysDeserializer deserializer + ) { + return JsonpDeserializer.of(EnumSet.of(Event.START_OBJECT), (parser, mapper, event) -> { + Map> result = new HashMap<>(); + String key = null; + while ((event = parser.next()) != Event.END_OBJECT) { + JsonpUtils.expectEvent(parser, event, Event.KEY_NAME); + // Split key and type + key = parser.getString(); + int hashPos = key.indexOf('#'); + + String type = key.substring(0, hashPos); + String name = key.substring(hashPos + 1); + + List list = new ArrayList<>(); + JsonpUtils.expectNextEvent(parser, Event.START_ARRAY); + try { + while ((event = parser.next()) != Event.END_ARRAY) { + list.add(deserializer.deserializer.deserialize(type, parser, mapper, event)); + } + } catch (Exception e) { + throw e; + } + result.put(name, list); + } + return result; + }); + } + /** * Serialize an externally tagged union using the typed keys encoding. */ - static > void serializeTypedKeys( - Map map, JsonGenerator generator, JsonpMapper mapper + public static > void serializeTypedKeys( + Map map, + JsonGenerator generator, + JsonpMapper mapper ) { generator.writeStartObject(); serializeTypedKeysInner(map, generator, mapper); @@ -133,10 +183,12 @@ public void deserializeEntry(String key, JsonParser parser, JsonpMapper mapper, /** * Serialize an externally tagged union using the typed keys encoding, without the enclosing start/end object. */ - static > void serializeTypedKeysInner( - Map map, JsonGenerator generator, JsonpMapper mapper + public static > void serializeTypedKeysInner( + Map map, + JsonGenerator generator, + JsonpMapper mapper ) { - for (Map.Entry entry: map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { T value = entry.getValue(); generator.writeKey(value._kind().jsonValue() + "#" + entry.getKey()); value.serialize(generator, mapper); diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonData.java b/java-client/src/main/java/org/opensearch/client/json/JsonData.java index 3e2e95748e..ad907650bb 100644 --- a/java-client/src/main/java/org/opensearch/client/json/JsonData.java +++ b/java-client/src/main/java/org/opensearch/client/json/JsonData.java @@ -34,7 +34,6 @@ import jakarta.json.JsonValue; import jakarta.json.stream.JsonParser; - import java.util.EnumSet; /** @@ -71,19 +70,19 @@ public interface JsonData extends JsonpSerializable { /** * Converts this object to a target class. */ - T to(Class clazz, JsonpMapper mapper); + T to(Class clazz, JsonpMapper mapper); /** * Converts this object using a deserializer. A mapper must have been provided at creation time. * * @throws IllegalStateException if no mapper was provided at creation time. */ - T deserialize(JsonpDeserializer deserializer); + T deserialize(JsonpDeserializer deserializer); /** * Converts this object using a deserializer. */ - T deserialize(JsonpDeserializer deserializer, JsonpMapper mapper); + T deserialize(JsonpDeserializer deserializer, JsonpMapper mapper); /** * Creates a raw JSON value from an existing object. A mapper will be needed to convert the result. @@ -109,7 +108,5 @@ static JsonData from(JsonParser parser, JsonpMapper mapper) { return of(parser.getValue(), mapper); } - JsonpDeserializer _DESERIALIZER = JsonpDeserializer.of( - EnumSet.allOf(JsonParser.Event.class), JsonData::from - ); + JsonpDeserializer _DESERIALIZER = JsonpDeserializer.of(EnumSet.allOf(JsonParser.Event.class), JsonData::from); } diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonDataImpl.java b/java-client/src/main/java/org/opensearch/client/json/JsonDataImpl.java index 56c7c8d0d3..72c9e0235b 100644 --- a/java-client/src/main/java/org/opensearch/client/json/JsonDataImpl.java +++ b/java-client/src/main/java/org/opensearch/client/json/JsonDataImpl.java @@ -35,7 +35,6 @@ import jakarta.json.JsonValue; import jakarta.json.stream.JsonGenerator; import jakarta.json.stream.JsonParser; - import java.io.StringReader; import java.io.StringWriter; @@ -67,8 +66,9 @@ public JsonValue toJson(JsonpMapper mapper) { // Provided mapper has precedence over the one that was optionally set at creation time mapper = mapper != null ? mapper : this.mapper; if (mapper == null) { - throw new IllegalStateException("Contains a '" + value.getClass().getName() + - "' that cannot be converted to a JsonValue without a mapper"); + throw new IllegalStateException( + "Contains a '" + value.getClass().getName() + "' that cannot be converted to a JsonValue without a mapper" + ); } final JsonParser parser = getParser(mapper); diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonEnum.java b/java-client/src/main/java/org/opensearch/client/json/JsonEnum.java index 6d5aaf9e03..0965041d7e 100644 --- a/java-client/src/main/java/org/opensearch/client/json/JsonEnum.java +++ b/java-client/src/main/java/org/opensearch/client/json/JsonEnum.java @@ -35,16 +35,15 @@ import jakarta.json.stream.JsonGenerator; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParsingException; - -import javax.annotation.Nullable; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; import java.util.NoSuchElementException; +import javax.annotation.Nullable; /** * Base interface for enumerations in API types. Members have a JSON representation and also accept - * aliases when parsed from a string value. + * aliases when parsed from a string value. For some enumerations primitive boolean values are also supported. */ public interface JsonEnum extends JsonpSerializable { String jsonValue(); @@ -62,19 +61,24 @@ default void serialize(JsonGenerator generator, JsonpMapper params) { class Deserializer extends JsonpDeserializerBase { private final Map lookupTable; + private static final EnumSet ACCEPTED_EVENTS = EnumSet.of( + JsonParser.Event.VALUE_STRING, + JsonParser.Event.KEY_NAME, + JsonParser.Event.VALUE_TRUE, + JsonParser.Event.VALUE_FALSE + ); + + private static final EnumSet NATIVE_EVENTS = EnumSet.of(JsonParser.Event.VALUE_STRING); + public Deserializer(T[] values) { - super( - EnumSet.of(JsonParser.Event.VALUE_STRING, JsonParser.Event.KEY_NAME), - EnumSet.of(JsonParser.Event.VALUE_STRING) - ); + super(ACCEPTED_EVENTS, NATIVE_EVENTS); - // Use the same size calculation as in java.lang.Enum.enumConstantDirectory - this.lookupTable = new HashMap<>((int)(values.length / 0.75f) + 1); + this.lookupTable = new HashMap<>((int) (values.length / 0.75f) + 1); for (T member : values) { this.lookupTable.put(member.jsonValue(), member); String[] aliases = member.aliases(); if (aliases != null) { - for (String alias: aliases) { + for (String alias : aliases) { this.lookupTable.put(alias, member); } } @@ -83,7 +87,18 @@ public Deserializer(T[] values) { @Override public T deserialize(JsonParser parser, JsonpMapper mapper, JsonParser.Event event) { - String value = parser.getString(); + String value; + switch (event) { + case VALUE_TRUE: + value = "true"; + break; + case VALUE_FALSE: + value = "false"; + break; + default: + value = parser.getString(); + } + return deserialize(value, parser); } diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonLocationImpl.java b/java-client/src/main/java/org/opensearch/client/json/JsonLocationImpl.java new file mode 100644 index 0000000000..7b3502a048 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/json/JsonLocationImpl.java @@ -0,0 +1,68 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.json; + +import jakarta.json.stream.JsonLocation; + +class JsonLocationImpl implements JsonLocation { + + private final long columnNo; + private final long lineNo; + private final long offset; + + JsonLocationImpl(long lineNo, long columnNo, long streamOffset) { + this.lineNo = lineNo; + this.columnNo = columnNo; + this.offset = streamOffset; + } + + @Override + public long getLineNumber() { + return lineNo; + } + + @Override + public long getColumnNumber() { + return columnNo; + } + + @Override + public long getStreamOffset() { + return offset; + } + + @Override + public String toString() { + return "(line no=" + lineNo + ", column no=" + columnNo + ", offset=" + offset + ")"; + } +} diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializable.java b/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializable.java index 5616c31a8b..dc05f477ca 100644 --- a/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializable.java +++ b/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializable.java @@ -41,7 +41,7 @@ /** * Indicates that a class has a {@link JsonpDeserializer} as a static field. */ -@Target({ElementType.TYPE}) +@Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface JsonpDeserializable { diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializer.java index 3c12aa2884..e35079ffd7 100644 --- a/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializer.java @@ -32,16 +32,15 @@ package org.opensearch.client.json; -import org.opensearch.client.util.TriFunction; import jakarta.json.JsonValue; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParser.Event; - import java.util.EnumSet; import java.util.List; import java.util.Map; import java.util.function.BiFunction; import java.util.function.Supplier; +import org.opensearch.client.util.TriFunction; public interface JsonpDeserializer { @@ -98,13 +97,13 @@ default V deserialize(JsonParser parser, JsonpMapper mapper) { */ V deserialize(JsonParser parser, JsonpMapper mapper, Event event); - //--------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- /** * Creates a deserializer for a class that delegates to the mapper provided to * {@link #deserialize(JsonParser, JsonpMapper)}. */ - static JsonpDeserializer of (Class clazz) { + static JsonpDeserializer of(Class clazz) { return new JsonpDeserializerBase(EnumSet.allOf(JsonParser.Event.class)) { @Override public T deserialize(JsonParser parser, JsonpMapper mapper) { @@ -145,7 +144,7 @@ static JsonpDeserializer lazy(Supplier> ctor) { return new LazyDeserializer<>(ctor); } - //----- Builtin types + // ----- Builtin types static JsonpDeserializer fixedValue(T value) { return new JsonpDeserializerBase(EnumSet.noneOf(Event.class)) { @@ -229,7 +228,8 @@ static JsonpDeserializer> stringMapDeserializer(JsonpDeserial } static JsonpDeserializer> enumMapDeserializer( - JsonpDeserializer keyDeserializer, JsonpDeserializer valueDeserializer + JsonpDeserializer keyDeserializer, + JsonpDeserializer valueDeserializer ) { return new JsonpDeserializerBase.EnumMapDeserializer(keyDeserializer, valueDeserializer); } diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializerBase.java b/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializerBase.java index d706f8ec72..bc8da85c58 100644 --- a/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializerBase.java +++ b/java-client/src/main/java/org/opensearch/client/json/JsonpDeserializerBase.java @@ -37,7 +37,6 @@ import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParser.Event; import jakarta.json.stream.JsonParsingException; - import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; @@ -65,14 +64,9 @@ protected JsonpDeserializerBase(EnumSet acceptedEvents, EnumSet na /** Combines accepted events from a number of deserializers */ protected static EnumSet allAcceptedEvents(JsonpDeserializer... deserializers) { EnumSet result = EnumSet.noneOf(Event.class); - for (JsonpDeserializer deserializer: deserializers) { + for (JsonpDeserializer deserializer : deserializers) { EnumSet set = deserializer.acceptedEvents(); - // Disabled for now. Only happens with the experimental Union2 and is caused by string and number - // parsers leniency. Need to be replaced with a check on a preferred event type. - //if (!Collections.disjoint(result, set)) { - // throw new IllegalArgumentException("Deserializer accepted events are not disjoint"); - //} result.addAll(set); } @@ -98,16 +92,14 @@ public final boolean accepts(Event event) { return acceptedEvents.contains(event); } - //--------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - //----- Builtin types + // ----- Builtin types static final JsonpDeserializer STRING = // String parsing is lenient and accepts any other primitive type - new JsonpDeserializerBase(EnumSet.of( - Event.KEY_NAME, Event.VALUE_STRING, Event.VALUE_NUMBER, - Event.VALUE_FALSE, Event.VALUE_TRUE - ), + new JsonpDeserializerBase( + EnumSet.of(Event.KEY_NAME, Event.VALUE_STRING, Event.VALUE_NUMBER, Event.VALUE_FALSE, Event.VALUE_TRUE), EnumSet.of(Event.VALUE_STRING) ) { @Override @@ -122,77 +114,72 @@ public String deserialize(JsonParser parser, JsonpMapper mapper, Event event) { } }; - static final JsonpDeserializer INTEGER = - new JsonpDeserializerBase( - EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), - EnumSet.of(Event.VALUE_NUMBER) - ) { - @Override - public Integer deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - if (event == Event.VALUE_STRING) { - return Integer.valueOf(parser.getString()); - } - return parser.getInt(); + static final JsonpDeserializer INTEGER = new JsonpDeserializerBase( + EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), + EnumSet.of(Event.VALUE_NUMBER) + ) { + @Override + public Integer deserialize(JsonParser parser, JsonpMapper mapper, Event event) { + if (event == Event.VALUE_STRING) { + return Integer.valueOf(parser.getString()); } - }; + return parser.getInt(); + } + }; - static final JsonpDeserializer BOOLEAN = - new JsonpDeserializerBase( - EnumSet.of(Event.VALUE_FALSE, Event.VALUE_TRUE, Event.VALUE_STRING), - EnumSet.of(Event.VALUE_FALSE, Event.VALUE_TRUE) - ) { - @Override - public Boolean deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - if (event == Event.VALUE_STRING) { - return Boolean.parseBoolean(parser.getString()); - } else { - return event == Event.VALUE_TRUE; - } + static final JsonpDeserializer BOOLEAN = new JsonpDeserializerBase( + EnumSet.of(Event.VALUE_FALSE, Event.VALUE_TRUE, Event.VALUE_STRING), + EnumSet.of(Event.VALUE_FALSE, Event.VALUE_TRUE) + ) { + @Override + public Boolean deserialize(JsonParser parser, JsonpMapper mapper, Event event) { + if (event == Event.VALUE_STRING) { + return Boolean.parseBoolean(parser.getString()); + } else { + return event == Event.VALUE_TRUE; } - }; + } + }; - static final JsonpDeserializer LONG = - new JsonpDeserializerBase( - EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), - EnumSet.of(Event.VALUE_NUMBER) - ) { - @Override - public Long deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - if (event == Event.VALUE_STRING) { - return Long.valueOf(parser.getString()); - } - return parser.getLong(); + static final JsonpDeserializer LONG = new JsonpDeserializerBase( + EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), + EnumSet.of(Event.VALUE_NUMBER) + ) { + @Override + public Long deserialize(JsonParser parser, JsonpMapper mapper, Event event) { + if (event == Event.VALUE_STRING) { + return Long.valueOf(parser.getString()); } - }; + return parser.getLong(); + } + }; - static final JsonpDeserializer FLOAT = - new JsonpDeserializerBase( - EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), - EnumSet.of(Event.VALUE_NUMBER) + static final JsonpDeserializer FLOAT = new JsonpDeserializerBase( + EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), + EnumSet.of(Event.VALUE_NUMBER) - ) { - @Override - public Float deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - if (event == Event.VALUE_STRING) { - return Float.valueOf(parser.getString()); - } - return parser.getBigDecimal().floatValue(); + ) { + @Override + public Float deserialize(JsonParser parser, JsonpMapper mapper, Event event) { + if (event == Event.VALUE_STRING) { + return Float.valueOf(parser.getString()); } - }; + return parser.getBigDecimal().floatValue(); + } + }; - static final JsonpDeserializer DOUBLE = - new JsonpDeserializerBase( - EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), - EnumSet.of(Event.VALUE_NUMBER) - ) { - @Override - public Double deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - if (event == Event.VALUE_STRING) { - return Double.valueOf(parser.getString()); - } - return parser.getBigDecimal().doubleValue(); + static final JsonpDeserializer DOUBLE = new JsonpDeserializerBase( + EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), + EnumSet.of(Event.VALUE_NUMBER) + ) { + @Override + public Double deserialize(JsonParser parser, JsonpMapper mapper, Event event) { + if (event == Event.VALUE_STRING) { + return Double.valueOf(parser.getString()); } - }; + return parser.getBigDecimal().doubleValue(); + } + }; static final class DoubleOrNullDeserializer extends JsonpDeserializerBase { static final EnumSet nativeEvents = EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_NULL); @@ -240,8 +227,14 @@ public Integer deserialize(JsonParser parser, JsonpMapper mapper, Event event) { static final class StringOrNullDeserializer extends JsonpDeserializerBase { static final EnumSet nativeEvents = EnumSet.of(Event.VALUE_STRING, Event.VALUE_NULL); - static final EnumSet acceptedEvents = EnumSet.of(Event.KEY_NAME, Event.VALUE_STRING, - Event.VALUE_NUMBER, Event.VALUE_FALSE, Event.VALUE_TRUE, Event.VALUE_NULL); + static final EnumSet acceptedEvents = EnumSet.of( + Event.KEY_NAME, + Event.VALUE_STRING, + Event.VALUE_NUMBER, + Event.VALUE_FALSE, + Event.VALUE_TRUE, + Event.VALUE_NULL + ); StringOrNullDeserializer() { super(acceptedEvents, nativeEvents); @@ -262,50 +255,43 @@ public String deserialize(JsonParser parser, JsonpMapper mapper, Event event) { } } - static final JsonpDeserializer DOUBLE_OR_NAN = - new JsonpDeserializerBase( - EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING, Event.VALUE_NULL), - EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_NULL) - ) { - @Override - public Double deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - if (event == Event.VALUE_NULL) { - return Double.NaN; - } - if (event == Event.VALUE_STRING) { - return Double.valueOf(parser.getString()); - } - return parser.getBigDecimal().doubleValue(); + static final JsonpDeserializer DOUBLE_OR_NAN = new JsonpDeserializerBase( + EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING, Event.VALUE_NULL), + EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_NULL) + ) { + @Override + public Double deserialize(JsonParser parser, JsonpMapper mapper, Event event) { + if (event == Event.VALUE_NULL) { + return Double.NaN; } - }; - - static final JsonpDeserializer NUMBER = - new JsonpDeserializerBase( - EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), - EnumSet.of(Event.VALUE_NUMBER) - ) { - @Override - public Number deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - if (event == Event.VALUE_STRING) { - return Double.valueOf(parser.getString()); - } - return ((JsonNumber)parser.getValue()).numberValue(); + if (event == Event.VALUE_STRING) { + return Double.valueOf(parser.getString()); } - }; + return parser.getBigDecimal().doubleValue(); + } + }; - static final JsonpDeserializer JSON_VALUE = - new JsonpDeserializerBase( - EnumSet.allOf(Event.class) - ) { - @Override - public JsonValue deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - return parser.getValue(); + static final JsonpDeserializer NUMBER = new JsonpDeserializerBase( + EnumSet.of(Event.VALUE_NUMBER, Event.VALUE_STRING), + EnumSet.of(Event.VALUE_NUMBER) + ) { + @Override + public Number deserialize(JsonParser parser, JsonpMapper mapper, Event event) { + if (event == Event.VALUE_STRING) { + return Double.valueOf(parser.getString()); } - }; + return ((JsonNumber) parser.getValue()).numberValue(); + } + }; - static final JsonpDeserializer VOID = new JsonpDeserializerBase( - EnumSet.noneOf(Event.class) - ) { + static final JsonpDeserializer JSON_VALUE = new JsonpDeserializerBase(EnumSet.allOf(Event.class)) { + @Override + public JsonValue deserialize(JsonParser parser, JsonpMapper mapper, Event event) { + return parser.getValue(); + } + }; + + static final JsonpDeserializer VOID = new JsonpDeserializerBase(EnumSet.noneOf(Event.class)) { @Override public Void deserialize(JsonParser parser, JsonpMapper mapper) { throw new JsonParsingException("Void types should not have any value", parser.getLocation()); @@ -317,7 +303,7 @@ public Void deserialize(JsonParser parser, JsonpMapper mapper, Event event) { } }; - //----- Collections + // ----- Collections static class ArrayDeserializer implements JsonpDeserializer> { private final JsonpDeserializer itemDeserializer; @@ -349,8 +335,13 @@ public List deserialize(JsonParser parser, JsonpMapper mapper, Event event) { if (event == Event.START_ARRAY) { List result = new ArrayList<>(); while ((event = parser.next()) != Event.END_ARRAY) { - JsonpUtils.ensureAccepts(itemDeserializer, parser, event); - result.add(itemDeserializer.deserialize(parser, mapper, event)); + // JSON null: add null unless the deserializer can handle it + if (event == Event.VALUE_NULL && !itemDeserializer.accepts(event)) { + result.add(null); + } else { + JsonpUtils.ensureAccepts(itemDeserializer, parser, event); + result.add(itemDeserializer.deserialize(parser, mapper, event)); + } } return result; } else { diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonpMapperBase.java b/java-client/src/main/java/org/opensearch/client/json/JsonpMapperBase.java index 2ce6e7f788..9e3295f984 100644 --- a/java-client/src/main/java/org/opensearch/client/json/JsonpMapperBase.java +++ b/java-client/src/main/java/org/opensearch/client/json/JsonpMapperBase.java @@ -35,9 +35,8 @@ import jakarta.json.JsonValue; import jakarta.json.stream.JsonGenerator; import jakarta.json.stream.JsonParser; - -import javax.annotation.Nullable; import java.lang.reflect.Field; +import javax.annotation.Nullable; public abstract class JsonpMapperBase implements JsonpMapper { @@ -61,7 +60,7 @@ public static JsonpDeserializer findDeserializer(Class clazz) { if (annotation != null) { try { Field field = clazz.getDeclaredField(annotation.field()); - return (JsonpDeserializer)field.get(null); + return (JsonpDeserializer) field.get(null); } catch (Exception e) { throw new RuntimeException("No deserializer found in '" + clazz.getName() + "." + annotation.field() + "'"); } diff --git a/java-client/src/main/java/org/opensearch/client/json/JsonpUtils.java b/java-client/src/main/java/org/opensearch/client/json/JsonpUtils.java index 80c9e85baf..604bf2791e 100644 --- a/java-client/src/main/java/org/opensearch/client/json/JsonpUtils.java +++ b/java-client/src/main/java/org/opensearch/client/json/JsonpUtils.java @@ -32,20 +32,20 @@ package org.opensearch.client.json; -import org.opensearch.client.util.ObjectBuilder; import jakarta.json.JsonObject; import jakarta.json.JsonString; import jakarta.json.JsonValue; import jakarta.json.stream.JsonGenerator; +import jakarta.json.stream.JsonLocation; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParser.Event; import jakarta.json.stream.JsonParsingException; - -import javax.annotation.Nullable; import java.io.StringReader; import java.util.AbstractMap; import java.util.Map; import java.util.stream.Collectors; +import javax.annotation.Nullable; +import org.opensearch.client.util.ObjectBuilder; public class JsonpUtils { @@ -93,7 +93,7 @@ public static void skipValue(JsonParser parser) { * Skip the value at the current position of the parser. */ public static void skipValue(JsonParser parser, Event event) { - switch(event) { + switch (event) { case START_OBJECT: parser.skipObject(); break; @@ -110,7 +110,7 @@ public static void skipValue(JsonParser parser, Event event) { public static T buildVariant(JsonParser parser, ObjectBuilder builder) { if (builder == null) { - throw new JsonParsingException("No variant found" , parser.getLocation()); + throw new JsonParsingException("No variant found", parser.getLocation()); } return builder.build(); } @@ -133,22 +133,51 @@ public static void serialize(T value, JsonGenerator generator, @Nullable Jso * (the object has been consumed from the original one). */ public static Map.Entry lookAheadFieldValue( - String name, String defaultValue, JsonParser parser, JsonpMapper mapper + String name, + String defaultValue, + JsonParser parser, + JsonpMapper mapper ) { - // FIXME: need a buffering parser wrapper so that we don't roundtrip through a JsonObject and a String - // FIXME: resulting parser should return locations that are offset with the original parser's location - JsonObject object = parser.getObject(); - String result = object.getString(name, null); + JsonLocation location = parser.getLocation(); - if (result == null) { - result = defaultValue; - } + if (parser instanceof LookAheadJsonParser) { + // Fast buffered path + Map.Entry result = ((LookAheadJsonParser) parser).lookAheadFieldValue(name, defaultValue); + if (result.getKey() == null) { + throw new JsonParsingException("Property '" + name + "' not found", location); + } + return result; - if (result == null) { - throw new JsonParsingException("Property '" + name + "' not found", parser.getLocation()); + } else { + // Unbuffered path: parse the object into a JsonObject, then extract the value and parse it again + JsonObject object = parser.getObject(); + String result = object.getString(name, null); + + if (result == null) { + result = defaultValue; + } + + if (result == null) { + throw new JsonParsingException("Property '" + name + "' not found", location); + } + + JsonParser newParser = objectParser(object, mapper); + + // Pin location to the start of the look ahead, as the new parser will return locations in its own buffer + newParser = new DelegatingJsonParser(newParser) { + @Override + public JsonLocation getLocation() { + return new JsonLocationImpl(location.getLineNumber(), location.getColumnNumber(), location.getStreamOffset()) { + @Override + public String toString() { + return "(in object at " + super.toString().substring(1); + } + }; + } + }; + + return new AbstractMap.SimpleImmutableEntry<>(result, newParser); } - - return new AbstractMap.SimpleImmutableEntry<>(result, objectParser(object, mapper)); } /** @@ -165,17 +194,15 @@ public static JsonParser objectParser(JsonObject object, JsonpMapper mapper) { } public static String toString(JsonValue value) { - switch(value.getValueType()) { + switch (value.getValueType()) { case OBJECT: throw new IllegalArgumentException("Json objects cannot be used as string"); case ARRAY: - return value.asJsonArray().stream() - .map(JsonpUtils::toString) - .collect(Collectors.joining(",")); + return value.asJsonArray().stream().map(JsonpUtils::toString).collect(Collectors.joining(",")); case STRING: - return ((JsonString)value).getString(); + return ((JsonString) value).getString(); case TRUE: return "true"; diff --git a/java-client/src/main/java/org/opensearch/client/json/LookAheadJsonParser.java b/java-client/src/main/java/org/opensearch/client/json/LookAheadJsonParser.java new file mode 100644 index 0000000000..63e9a9f318 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/json/LookAheadJsonParser.java @@ -0,0 +1,58 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.json; + +import jakarta.json.stream.JsonParser; +import java.util.Map; + +public interface LookAheadJsonParser extends JsonParser { + + /** + * Look ahead the value of a text property in the JSON stream. The parser must be on the {@code START_OBJECT} event. + * + * @param name the field name to look up. + * @param defaultValue default value if the field is not found. + * @return a pair containing the field value (or {@code null} if not found), and a parser to be used to read the JSON object. + */ + Map.Entry lookAheadFieldValue(String name, String defaultValue); + + /** + * In union types, find the variant to be used by looking up property names in the JSON stream until we find one that + * uniquely identifies the variant. + * + * @param the type of variant descriptors used by the caller. + * @param variants a map of variant descriptors, keyed by the property name that uniquely identifies the variant. + * @return a pair containing the variant descriptor (or {@code null} if not found), and a parser to be used to read the JSON object. + */ + Map.Entry findVariant(Map variants); +} diff --git a/java-client/src/main/java/org/opensearch/client/json/NamedDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/NamedDeserializer.java index 212ee8e6ff..e162d2a783 100644 --- a/java-client/src/main/java/org/opensearch/client/json/NamedDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/NamedDeserializer.java @@ -35,7 +35,6 @@ import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParser.Event; import jakarta.json.stream.JsonParsingException; - import java.util.EnumSet; /** @@ -71,17 +70,19 @@ public EnumSet acceptedEvents() { @Override public T deserialize(JsonParser parser, JsonpMapper mapper) { - if (mapper.>attribute(name) == null) { - throw new JsonParsingException("Missing deserializer", parser.getLocation()); + JsonpDeserializer deserializer = mapper.attribute(name); + if (deserializer == null) { + throw new JsonParsingException("Missing deserializer for generic type: " + name, parser.getLocation()); } - return mapper.>attribute(name).deserialize(parser, mapper); + return deserializer.deserialize(parser, mapper); } @Override public T deserialize(JsonParser parser, JsonpMapper mapper, JsonParser.Event event) { - if (mapper.>attribute(name) == null) { - throw new JsonParsingException("Missing deserializer", parser.getLocation()); + JsonpDeserializer deserializer = mapper.attribute(name); + if (deserializer == null) { + throw new JsonParsingException("Missing deserializer for generic type: " + name, parser.getLocation()); } - return mapper.>attribute(name).deserialize(parser, mapper, event); + return deserializer.deserialize(parser, mapper, event); } } diff --git a/java-client/src/main/java/org/opensearch/client/json/ObjectBuilderDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/ObjectBuilderDeserializer.java index 112686f7c9..4943e83eb3 100644 --- a/java-client/src/main/java/org/opensearch/client/json/ObjectBuilderDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/ObjectBuilderDeserializer.java @@ -32,12 +32,11 @@ package org.opensearch.client.json; -import org.opensearch.client.util.ObjectBuilder; import jakarta.json.stream.JsonParser; - import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +import org.opensearch.client.util.ObjectBuilder; /** * An object deserializer based on an {@link ObjectBuilder}. @@ -63,10 +62,10 @@ public static JsonpDeserializer lazy( Function buildFn ) { return new LazyDeserializer<>(() -> { - ObjectDeserializer builderDeser = new ObjectDeserializer(builderCtor); - builderDeserializerSetup.accept(builderDeser); - return new BuildFunctionDeserializer<>(builderDeser, buildFn); - }); + ObjectDeserializer builderDeser = new ObjectDeserializer(builderCtor); + builderDeserializerSetup.accept(builderDeser); + return new BuildFunctionDeserializer<>(builderDeser, buildFn); + }); } public static > JsonpDeserializer createForObject( diff --git a/java-client/src/main/java/org/opensearch/client/json/ObjectDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/ObjectDeserializer.java index d7e3c59317..316b0239e3 100644 --- a/java-client/src/main/java/org/opensearch/client/json/ObjectDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/ObjectDeserializer.java @@ -32,12 +32,9 @@ package org.opensearch.client.json; -import org.opensearch.client.util.QuadConsumer; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParser.Event; import jakarta.json.stream.JsonParsingException; - -import javax.annotation.Nullable; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; @@ -47,6 +44,8 @@ import java.util.function.BiConsumer; import java.util.function.ObjIntConsumer; import java.util.function.Supplier; +import javax.annotation.Nullable; +import org.opensearch.client.util.QuadConsumer; public class ObjectDeserializer implements JsonpDeserializer { @@ -68,10 +67,7 @@ public static class FieldObjectDeserializer extends Field private final BiConsumer setter; private final JsonpDeserializer deserializer; - public FieldObjectDeserializer( - BiConsumer setter, JsonpDeserializer deserializer, - String name - ) { + public FieldObjectDeserializer(BiConsumer setter, JsonpDeserializer deserializer, String name) { super(name); this.setter = setter; this.deserializer = deserializer; @@ -106,7 +102,7 @@ public void deserialize(JsonParser parser, JsonpMapper mapper, String fieldName, } }; - //--------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- private static final EnumSet EventSetObject = EnumSet.of(Event.START_OBJECT, Event.KEY_NAME); private static final EnumSet EventSetObjectAndString = EnumSet.of(Event.START_OBJECT, Event.VALUE_STRING, Event.KEY_NAME); @@ -222,7 +218,7 @@ protected void parseUnknownField(JsonParser parser, JsonpMapper mapper, String f } else { throw new JsonParsingException( - "Unknown field '" + fieldName + "' for type '" + object.getClass().getName() +"'", + "Unknown field '" + fieldName + "' for type '" + object.getClass().getName() + "'", parser.getLocation() ); } @@ -246,27 +242,22 @@ public void shortcutProperty(String name) { acceptedEvents = EventSetObjectAndString; } - //----- Object types + // ----- Object types - public void add( - BiConsumer setter, - JsonpDeserializer deserializer, - String name - ) { - FieldObjectDeserializer fieldDeserializer = - new FieldObjectDeserializer<>(setter, deserializer, name); + public void add(BiConsumer setter, JsonpDeserializer deserializer, String name) { + FieldObjectDeserializer fieldDeserializer = new FieldObjectDeserializer<>(setter, deserializer, name); this.fieldDeserializers.put(name, fieldDeserializer); } public void add( BiConsumer setter, JsonpDeserializer deserializer, - String name, String... aliases + String name, + String... aliases ) { - FieldObjectDeserializer fieldDeserializer = - new FieldObjectDeserializer<>(setter, deserializer, name); + FieldObjectDeserializer fieldDeserializer = new FieldObjectDeserializer<>(setter, deserializer, name); this.fieldDeserializers.put(name, fieldDeserializer); - for (String alias: aliases) { + for (String alias : aliases) { this.fieldDeserializers.put(alias, fieldDeserializer); } } @@ -280,33 +271,11 @@ public void setTypeProperty(String name, String defaultType) { this.defaultType = defaultType; } - //----- Primitive types + // ----- Primitive types public void add(ObjIntConsumer setter, String name, String... deprecatedNames) { // FIXME (perf): add specialized deserializer to avoid intermediate boxing add(setter::accept, JsonpDeserializer.integerDeserializer(), name, deprecatedNames); } -// Experiment: avoid boxing, allow multiple primitive parsers (e.g. int as number & string) -// public void add( -// ObjIntConsumer setter, -// JsonpIntParser vp, -// String name, String... deprecatedNames -// ) { -// this.fieldDeserializers.put(name, new FieldDeserializer(name, deprecatedNames) { -// @Override -// public void deserialize(JsonParser parser, JsonpMapper mapper, String fieldName, ObjectType object) { -// JsonpUtils.expectNextEvent(parser, Event.VALUE_NUMBER); -// setter.accept(object, vp.parse(parser)); -// } -// }); -// } -// -// public static class JsonpIntParser { -// public int parse(JsonParser parser) { -// JsonpUtils.expectNextEvent(parser, Event.VALUE_NUMBER); -// return parser.getInt(); -// } -// } - } diff --git a/java-client/src/main/java/org/opensearch/client/json/UnexpectedJsonEventException.java b/java-client/src/main/java/org/opensearch/client/json/UnexpectedJsonEventException.java index e717f73a9e..c7aa821133 100644 --- a/java-client/src/main/java/org/opensearch/client/json/UnexpectedJsonEventException.java +++ b/java-client/src/main/java/org/opensearch/client/json/UnexpectedJsonEventException.java @@ -35,7 +35,6 @@ import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParser.Event; import jakarta.json.stream.JsonParsingException; - import java.util.EnumSet; public class UnexpectedJsonEventException extends JsonParsingException { diff --git a/java-client/src/main/java/org/opensearch/client/json/UnionDeserializer.java b/java-client/src/main/java/org/opensearch/client/json/UnionDeserializer.java index dc54bf43e6..55527cefc0 100644 --- a/java-client/src/main/java/org/opensearch/client/json/UnionDeserializer.java +++ b/java-client/src/main/java/org/opensearch/client/json/UnionDeserializer.java @@ -32,12 +32,11 @@ package org.opensearch.client.json; -import org.opensearch.client.util.ObjectBuilder; import jakarta.json.JsonObject; +import jakarta.json.stream.JsonLocation; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParser.Event; import jakarta.json.stream.JsonParsingException; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -48,6 +47,9 @@ import java.util.Map; import java.util.Set; import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.stream.Collectors; +import org.opensearch.client.util.ObjectBuilder; public class UnionDeserializer implements JsonpDeserializer { @@ -59,6 +61,7 @@ public AmbiguousUnionException(String message) { private abstract static class EventHandler { abstract Union deserialize(JsonParser parser, JsonpMapper mapper, Event event, BiFunction buildFn); + abstract EnumSet nativeEvents(); } @@ -99,7 +102,7 @@ private static class MultiMemberHandler extends EventHandle @Override EnumSet nativeEvents() { EnumSet result = EnumSet.noneOf(Event.class); - for (SingleMemberHandler smh: handlers) { + for (SingleMemberHandler smh : handlers) { result.addAll(smh.deserializer.nativeEvents()); } return result; @@ -108,10 +111,10 @@ EnumSet nativeEvents() { @Override Union deserialize(JsonParser parser, JsonpMapper mapper, Event event, BiFunction buildFn) { RuntimeException exception = null; - for (EventHandler d: handlers) { + for (EventHandler d : handlers) { try { return d.deserialize(parser, mapper, event, buildFn); - } catch(RuntimeException ex) { + } catch (RuntimeException ex) { exception = ex; } } @@ -169,14 +172,11 @@ public Builder addMember(Kind tag, JsonpDeserializer unwrapped = DelegatingDeserializer.unwrap(deserializer); if (unwrapped instanceof ObjectDeserializer) { ObjectDeserializer od = (ObjectDeserializer) unwrapped; - Set allFields = od.fieldNames(); - Set fields = new HashSet<>(allFields); // copy to update - for (UnionDeserializer.SingleMemberHandler member: objectMembers) { - // Remove respective fields on both sides to keep specific ones - fields.removeAll(member.fields); - member.fields.removeAll(allFields); - } - UnionDeserializer.SingleMemberHandler member = new SingleMemberHandler<>(tag, deserializer, fields); + UnionDeserializer.SingleMemberHandler member = new SingleMemberHandler<>( + tag, + deserializer, + new HashSet<>(od.fieldNames()) + ); objectMembers.add(member); if (od.shortcutProperty() != null) { // also add it as a string @@ -184,7 +184,7 @@ public Builder addMember(Kind tag, JsonpDeserializer member = new SingleMemberHandler<>(tag, deserializer); - for (Event e: deserializer.nativeEvents()) { + for (Event e : deserializer.nativeEvents()) { addMember(e, tag, member); } } @@ -194,8 +194,20 @@ public Builder addMember(Kind tag, JsonpDeserializer build() { + Map fieldFrequencies = objectMembers.stream() + .flatMap(m -> m.fields.stream()) + .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); + Set duplicateFields = fieldFrequencies.entrySet() + .stream() + .filter(entry -> entry.getValue() > 1) + .map(Map.Entry::getKey) + .collect(Collectors.toSet()); + for (UnionDeserializer.SingleMemberHandler member : objectMembers) { + member.fields.removeAll(duplicateFields); + } + // Check that no object member had all its fields removed - for (UnionDeserializer.SingleMemberHandler member: objectMembers) { + for (UnionDeserializer.SingleMemberHandler member : objectMembers) { if (member.fields.isEmpty()) { throw new AmbiguousUnionException("All properties of '" + member.tag + "' also exist in other object members"); } @@ -206,10 +218,6 @@ public JsonpDeserializer build() { otherMembers.put(Event.START_OBJECT, objectMembers.remove(0)); } -// if (objectMembers.size() > 1) { -// System.out.println("multiple objects in " + buildFn); -// } - return new UnionDeserializer<>(objectMembers, otherMembers, buildFn); } } @@ -217,12 +225,12 @@ public JsonpDeserializer build() { private final BiFunction buildFn; private final EnumSet nativeEvents; private final Map> objectMembers; - private final Map> otherMembers; + private final Map> nonObjectMembers; private final EventHandler fallbackObjectMember; public UnionDeserializer( List> objectMembers, - Map> otherMembers, + Map> nonObjectMembers, BiFunction buildFn ) { this.buildFn = buildFn; @@ -232,24 +240,24 @@ public UnionDeserializer( this.objectMembers = Collections.emptyMap(); } else { this.objectMembers = new HashMap<>(); - for (SingleMemberHandler member: objectMembers) { - for (String field: member.fields) { + for (SingleMemberHandler member : objectMembers) { + for (String field : member.fields) { this.objectMembers.put(field, member); } } } - this.otherMembers = otherMembers; + this.nonObjectMembers = nonObjectMembers; this.nativeEvents = EnumSet.noneOf(Event.class); - for (EventHandler member: otherMembers.values()) { + for (EventHandler member : nonObjectMembers.values()) { this.nativeEvents.addAll(member.nativeEvents()); } if (objectMembers.isEmpty()) { fallbackObjectMember = null; } else { - fallbackObjectMember = this.otherMembers.remove(Event.START_OBJECT); + fallbackObjectMember = this.nonObjectMembers.remove(Event.START_OBJECT); this.nativeEvents.add(Event.START_OBJECT); } } @@ -274,17 +282,32 @@ public Union deserialize(JsonParser parser, JsonpMapper mapper) { @Override public Union deserialize(JsonParser parser, JsonpMapper mapper, Event event) { - EventHandler member = otherMembers.get(event); + EventHandler member = nonObjectMembers.get(event); + JsonLocation location = parser.getLocation(); if (member == null && event == Event.START_OBJECT && !objectMembers.isEmpty()) { - // Parse as an object to find matching field names - JsonObject object = parser.getObject(); + if (parser instanceof LookAheadJsonParser) { + Map.Entry, JsonParser> memberAndParser = ((LookAheadJsonParser) parser).findVariant( + objectMembers + ); - for (String field: object.keySet()) { - member = objectMembers.get(field); - if (member != null) { - break; + member = memberAndParser.getKey(); + // Parse the buffered parser + parser = memberAndParser.getValue(); + + } else { + // Parse as an object to find matching field names + JsonObject object = parser.getObject(); + + for (String field : object.keySet()) { + member = objectMembers.get(field); + if (member != null) { + break; + } } + + // Traverse the object we have inspected + parser = JsonpUtils.objectParser(object, mapper); } if (member == null) { @@ -292,14 +315,12 @@ public Union deserialize(JsonParser parser, JsonpMapper mapper, Event event) { } if (member != null) { - // Traverse the object we have inspected - parser = JsonpUtils.objectParser(object, mapper); event = parser.next(); } } if (member == null) { - throw new JsonParsingException("Cannot determine what union member to deserialize", parser.getLocation()); + throw new JsonParsingException("Cannot determine what union member to deserialize", location); } return member.deserialize(parser, mapper, event, buildFn); diff --git a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonProvider.java b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonProvider.java index 56045e4e51..bc14bf1537 100644 --- a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonProvider.java +++ b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonProvider.java @@ -47,7 +47,6 @@ import jakarta.json.stream.JsonGeneratorFactory; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParserFactory; - import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -81,7 +80,7 @@ public JsonFactory jacksonJsonFactory() { return this.jsonFactory; } - //--------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- // Parser private final ParserFactory defaultParserFactory = new ParserFactory(null); @@ -166,7 +165,7 @@ public JsonParser createParser(JsonArray array) { } } - //--------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- // Generator private final JsonGeneratorFactory defaultGeneratorFactory = new GeneratorFactory(null); @@ -233,7 +232,7 @@ public JsonGenerator createGenerator(OutputStream out, Charset charset) { } } - //--------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- // Unsupported operations /** diff --git a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpGenerator.java b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpGenerator.java index 38b5f48bc5..50dc7f2f8f 100644 --- a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpGenerator.java +++ b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpGenerator.java @@ -38,7 +38,6 @@ import jakarta.json.JsonValue; import jakarta.json.stream.JsonGenerationException; import jakarta.json.stream.JsonGenerator; - import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; @@ -195,7 +194,7 @@ public JsonGenerator write(String name, double value) { public JsonGenerator write(String name, boolean value) { try { generator.writeFieldName(name); - generator.writeBooleanField(name, value); + generator.writeBoolean(value); } catch (IOException e) { throw JacksonUtils.convertException(e); } @@ -339,10 +338,10 @@ public void flush() { } private void writeValue(JsonValue value) throws IOException { - switch(value.getValueType()) { + switch (value.getValueType()) { case OBJECT: generator.writeStartObject(); - for (Map.Entry entry: value.asJsonObject().entrySet()) { + for (Map.Entry entry : value.asJsonObject().entrySet()) { generator.writeFieldName(entry.getKey()); writeValue(entry.getValue()); } @@ -351,14 +350,14 @@ private void writeValue(JsonValue value) throws IOException { case ARRAY: generator.writeStartArray(); - for (JsonValue item: value.asJsonArray()) { + for (JsonValue item : value.asJsonArray()) { writeValue(item); } generator.writeEndArray(); break; case STRING: - generator.writeString(((JsonString)value).getString()); + generator.writeString(((JsonString) value).getString()); break; case FALSE: diff --git a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpMapper.java b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpMapper.java index b6b44e66f3..186018a0d2 100644 --- a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpMapper.java +++ b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpMapper.java @@ -32,11 +32,6 @@ package org.opensearch.client.json.jackson; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpDeserializerBase; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.JsonpMapperBase; -import org.opensearch.client.json.JsonpSerializer; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.databind.ObjectMapper; @@ -44,9 +39,13 @@ import jakarta.json.spi.JsonProvider; import jakarta.json.stream.JsonGenerator; import jakarta.json.stream.JsonParser; - import java.io.IOException; import java.util.EnumSet; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpDeserializerBase; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpMapperBase; +import org.opensearch.client.json.JsonpSerializer; public class JacksonJsonpMapper extends JsonpMapperBase { @@ -54,18 +53,19 @@ public class JacksonJsonpMapper extends JsonpMapperBase { private final ObjectMapper objectMapper; public JacksonJsonpMapper(ObjectMapper objectMapper) { - this(objectMapper, new JsonFactory()); + // Creating the json factory from the mapper ensures it will be returned by JsonParser.getCodec() + this(objectMapper, objectMapper.getFactory()); } public JacksonJsonpMapper(ObjectMapper objectMapper, JsonFactory jsonFactory) { this.provider = new JacksonJsonProvider(jsonFactory); - this.objectMapper = objectMapper - .configure(SerializationFeature.INDENT_OUTPUT, false) - .setSerializationInclusion(JsonInclude.Include.NON_NULL); + this.objectMapper = objectMapper; } public JacksonJsonpMapper() { - this(new ObjectMapper()); + this( + new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, false).setSerializationInclusion(JsonInclude.Include.NON_NULL) + ); } /** @@ -81,7 +81,7 @@ public JsonProvider jsonProvider() { } @Override - protected JsonpDeserializer getDefaultDeserializer(Class clazz) { + protected JsonpDeserializer getDefaultDeserializer(Class clazz) { return new JacksonValueParser<>(clazz); } @@ -98,7 +98,7 @@ public void serialize(T value, JsonGenerator generator) { return; } - com.fasterxml.jackson.core.JsonGenerator jkGenerator = ((JacksonJsonpGenerator)generator).jacksonGenerator(); + com.fasterxml.jackson.core.JsonGenerator jkGenerator = ((JacksonJsonpGenerator) generator).jacksonGenerator(); try { objectMapper.writeValue(jkGenerator, value); } catch (IOException ioe) { @@ -122,11 +122,11 @@ public T deserialize(JsonParser parser, JsonpMapper mapper, JsonParser.Event eve throw new IllegalArgumentException("Jackson's ObjectMapper can only be used with the JacksonJsonpProvider"); } - com.fasterxml.jackson.core.JsonParser jkParser = ((JacksonJsonpParser)parser).jacksonParser(); + com.fasterxml.jackson.core.JsonParser jkParser = ((JacksonJsonpParser) parser).jacksonParser(); try { return objectMapper.readValue(jkParser, clazz); - } catch(IOException ioe) { + } catch (IOException ioe) { throw JacksonUtils.convertException(ioe); } } diff --git a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpParser.java b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpParser.java index de95dbce0e..8597b81604 100644 --- a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpParser.java +++ b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonJsonpParser.java @@ -33,19 +33,23 @@ package org.opensearch.client.json.jackson; import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.util.JsonParserSequence; +import com.fasterxml.jackson.databind.util.TokenBuffer; import jakarta.json.JsonArray; import jakarta.json.JsonObject; import jakarta.json.JsonValue; import jakarta.json.stream.JsonLocation; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParsingException; - import java.io.IOException; import java.math.BigDecimal; +import java.util.AbstractMap; import java.util.EnumMap; import java.util.Map; import java.util.NoSuchElementException; import java.util.stream.Stream; +import org.opensearch.client.json.LookAheadJsonParser; +import org.opensearch.client.json.UnexpectedJsonEventException; /** * A JSONP parser implementation on top of Jackson. @@ -55,7 +59,7 @@ * getter method (e.g. {@link #getInt()} or {@link #getString()} should be called until the next call to {@link #next()}. * Such calls will throw an {@code IllegalStateException}. */ -public class JacksonJsonpParser implements JsonParser { +public class JacksonJsonpParser implements LookAheadJsonParser { private final com.fasterxml.jackson.core.JsonParser parser; @@ -100,7 +104,7 @@ private JsonParsingException convertException(IOException ioe) { private JsonToken fetchNextToken() { try { return parser.nextToken(); - } catch(IOException e) { + } catch (IOException e) { throw convertException(e); } } @@ -137,7 +141,7 @@ public Event next() { Event result = tokenToEvent.get(token); if (result == null) { - throw new JsonParsingException("Unsupported Jackson event type '"+ token + "'", getLocation()); + throw new JsonParsingException("Unsupported Jackson event type '" + token + "'", getLocation()); } return result; @@ -209,8 +213,7 @@ public void close() { public JsonObject getObject() { ensureTokenIsCurrent(); if (parser.currentToken() != JsonToken.START_OBJECT) { - throw new IllegalStateException("Unexpected event '" + parser.currentToken() + - "' at " + parser.getTokenLocation()); + throw new IllegalStateException("Unexpected event '" + parser.currentToken() + "' at " + parser.getTokenLocation()); } if (valueParser == null) { valueParser = new JsonValueParser(); @@ -229,8 +232,7 @@ public JsonArray getArray() { valueParser = new JsonValueParser(); } if (parser.currentToken() != JsonToken.START_ARRAY) { - throw new IllegalStateException("Unexpected event '" + parser.currentToken() + - "' at " + parser.getTokenLocation()); + throw new IllegalStateException("Unexpected event '" + parser.currentToken() + "' at " + parser.getTokenLocation()); } try { return valueParser.parseArray(parser); @@ -272,7 +274,7 @@ public void skipObject() { depth--; break; } - } while(!(token == JsonToken.END_OBJECT && depth == 0)); + } while (!(token == JsonToken.END_OBJECT && depth == 0)); } catch (IOException e) { throw convertException(e); } @@ -298,7 +300,7 @@ public void skipArray() { depth--; break; } - } while(!(token == JsonToken.END_ARRAY && depth == 0)); + } while (!(token == JsonToken.END_ARRAY && depth == 0)); } catch (IOException e) { throw convertException(e); } @@ -319,7 +321,99 @@ public Stream getArrayStream() { */ @Override public Stream getValueStream() { - return JsonParser.super.getValueStream(); + return LookAheadJsonParser.super.getValueStream(); + } + + // ----- Look ahead methods + + public Map.Entry lookAheadFieldValue(String name, String defaultValue) { + + TokenBuffer tb = new TokenBuffer(parser, null); + + try { + // The resulting parser must contain the full object, including START_EVENT + tb.copyCurrentEvent(parser); + while (parser.nextToken() != JsonToken.END_OBJECT) { + + expectEvent(JsonToken.FIELD_NAME); + // Do not copy current event here, each branch will take care of it + + String fieldName = parser.getCurrentName(); + if (fieldName.equals(name)) { + // Found + tb.copyCurrentEvent(parser); + expectNextEvent(JsonToken.VALUE_STRING); + tb.copyCurrentEvent(parser); + + return new AbstractMap.SimpleImmutableEntry<>( + parser.getText(), + new JacksonJsonpParser(JsonParserSequence.createFlattened(false, tb.asParser(), parser)) + ); + } else { + tb.copyCurrentStructure(parser); + } + } + // Copy ending END_OBJECT + tb.copyCurrentEvent(parser); + } catch (IOException e) { + throw JacksonUtils.convertException(e); + } + + // Field not found + return new AbstractMap.SimpleImmutableEntry<>( + defaultValue, + new JacksonJsonpParser(JsonParserSequence.createFlattened(false, tb.asParser(), parser)) + ); + } + + @Override + public Map.Entry findVariant(Map variants) { + // We're on a START_OBJECT event + TokenBuffer tb = new TokenBuffer(parser, null); + + try { + // The resulting parser must contain the full object, including START_EVENT + tb.copyCurrentEvent(parser); + while (parser.nextToken() != JsonToken.END_OBJECT) { + + expectEvent(JsonToken.FIELD_NAME); + String fieldName = parser.getCurrentName(); + + Variant variant = variants.get(fieldName); + if (variant != null) { + tb.copyCurrentEvent(parser); + return new AbstractMap.SimpleImmutableEntry<>( + variant, + new JacksonJsonpParser(JsonParserSequence.createFlattened(false, tb.asParser(), parser)) + ); + } else { + tb.copyCurrentStructure(parser); + } + } + // Copy ending END_OBJECT + tb.copyCurrentEvent(parser); + } catch (IOException e) { + throw JacksonUtils.convertException(e); + } + + // No variant found: return the buffered parser and let the caller decide what to do. + return new AbstractMap.SimpleImmutableEntry<>( + null, + new JacksonJsonpParser(JsonParserSequence.createFlattened(false, tb.asParser(), parser)) + ); + } + + private void expectNextEvent(JsonToken expected) throws IOException { + JsonToken event = parser.nextToken(); + if (event != expected) { + throw new UnexpectedJsonEventException(this, tokenToEvent.get(event), tokenToEvent.get(expected)); + } } -} + private void expectEvent(JsonToken expected) { + JsonToken event = parser.currentToken(); + if (event != expected) { + throw new UnexpectedJsonEventException(this, tokenToEvent.get(event), tokenToEvent.get(expected)); + } + } +} diff --git a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonUtils.java b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonUtils.java index 988474f7ce..7c1894ea95 100644 --- a/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonUtils.java +++ b/java-client/src/main/java/org/opensearch/client/json/jackson/JacksonUtils.java @@ -36,7 +36,6 @@ import jakarta.json.JsonException; import jakarta.json.stream.JsonGenerationException; import jakarta.json.stream.JsonParsingException; - import java.io.IOException; class JacksonUtils { diff --git a/java-client/src/main/java/org/opensearch/client/json/jackson/JsonValueParser.java b/java-client/src/main/java/org/opensearch/client/json/jackson/JsonValueParser.java index fbc9101a37..3b4b9dd0d1 100644 --- a/java-client/src/main/java/org/opensearch/client/json/jackson/JsonValueParser.java +++ b/java-client/src/main/java/org/opensearch/client/json/jackson/JsonValueParser.java @@ -41,7 +41,6 @@ import jakarta.json.JsonValue; import jakarta.json.spi.JsonProvider; import jakarta.json.stream.JsonParsingException; - import java.io.IOException; /** @@ -49,14 +48,16 @@ * object (e.g. START_OBJECT, VALUE_NUMBER, etc). */ class JsonValueParser { - private final JsonProvider provider = JsonProvider.provider(); + private static class DefaultJsonProvider { + private static final JsonProvider INSTANCE = JsonProvider.provider(); + } public JsonObject parseObject(JsonParser parser) throws IOException { - JsonObjectBuilder ob = provider.createObjectBuilder(); + JsonObjectBuilder ob = DefaultJsonProvider.INSTANCE.createObjectBuilder(); JsonToken token; - while((token = parser.nextToken()) != JsonToken.END_OBJECT) { + while ((token = parser.nextToken()) != JsonToken.END_OBJECT) { if (token != JsonToken.FIELD_NAME) { throw new JsonParsingException("Expected a property name", new JacksonJsonpLocation(parser)); } @@ -68,9 +69,9 @@ public JsonObject parseObject(JsonParser parser) throws IOException { } public JsonArray parseArray(JsonParser parser) throws IOException { - JsonArrayBuilder ab = provider.createArrayBuilder(); + JsonArrayBuilder ab = DefaultJsonProvider.INSTANCE.createArrayBuilder(); - while(parser.nextToken() != JsonToken.END_ARRAY) { + while (parser.nextToken() != JsonToken.END_ARRAY) { ab.add(parseValue(parser)); } return ab.build(); @@ -94,22 +95,22 @@ public JsonValue parseValue(JsonParser parser) throws IOException { return JsonValue.NULL; case VALUE_STRING: - return provider.createValue(parser.getText()); + return DefaultJsonProvider.INSTANCE.createValue(parser.getText()); case VALUE_NUMBER_FLOAT: case VALUE_NUMBER_INT: - switch(parser.getNumberType()) { + switch (parser.getNumberType()) { case INT: - return provider.createValue(parser.getIntValue()); + return DefaultJsonProvider.INSTANCE.createValue(parser.getIntValue()); case LONG: - return provider.createValue(parser.getLongValue()); + return DefaultJsonProvider.INSTANCE.createValue(parser.getLongValue()); case FLOAT: case DOUBLE: - return provider.createValue(parser.getDoubleValue()); + return DefaultJsonProvider.INSTANCE.createValue(parser.getDoubleValue()); case BIG_DECIMAL: - return provider.createValue(parser.getDecimalValue()); + return DefaultJsonProvider.INSTANCE.createValue(parser.getDecimalValue()); case BIG_INTEGER: - return provider.createValue(parser.getBigIntegerValue()); + return DefaultJsonProvider.INSTANCE.createValue(parser.getBigIntegerValue()); } default: diff --git a/java-client/src/main/java/org/opensearch/client/json/jsonb/JsonbJsonpMapper.java b/java-client/src/main/java/org/opensearch/client/json/jsonb/JsonbJsonpMapper.java index a01d478326..0a7c98e2da 100644 --- a/java-client/src/main/java/org/opensearch/client/json/jsonb/JsonbJsonpMapper.java +++ b/java-client/src/main/java/org/opensearch/client/json/jsonb/JsonbJsonpMapper.java @@ -32,21 +32,20 @@ package org.opensearch.client.json.jsonb; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpDeserializerBase; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.JsonpMapperBase; -import org.opensearch.client.json.JsonpSerializable; import jakarta.json.bind.Jsonb; import jakarta.json.bind.spi.JsonbProvider; import jakarta.json.spi.JsonProvider; import jakarta.json.stream.JsonGenerator; import jakarta.json.stream.JsonParser; import jakarta.json.stream.JsonParser.Event; - import java.io.CharArrayReader; import java.io.CharArrayWriter; import java.util.EnumSet; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpDeserializerBase; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpMapperBase; +import org.opensearch.client.json.JsonpSerializable; public class JsonbJsonpMapper extends JsonpMapperBase { @@ -74,7 +73,7 @@ protected JsonpDeserializer getDefaultDeserializer(Class clazz) { @Override public void serialize(T value, JsonGenerator generator) { if (value instanceof JsonpSerializable) { - ((JsonpSerializable)value).serialize(generator, this); + ((JsonpSerializable) value).serialize(generator, this); return; } @@ -126,7 +125,7 @@ private void transferAll(JsonParser from, JsonGenerator to) { */ private void transferAll(JsonParser from, JsonParser.Event event, JsonGenerator to) { transferEvent(from, event, to); - switch(event) { + switch (event) { case START_OBJECT: { int depth = 1; do { @@ -140,9 +139,9 @@ private void transferAll(JsonParser from, JsonParser.Event event, JsonGenerator depth--; break; } - } while(!(event == Event.END_OBJECT && depth == 0)); + } while (!(event == Event.END_OBJECT && depth == 0)); } - break; + break; case START_ARRAY: { int depth = 1; @@ -157,9 +156,9 @@ private void transferAll(JsonParser from, JsonParser.Event event, JsonGenerator depth--; break; } - } while(!(event == Event.END_ARRAY && depth == 0)); + } while (!(event == Event.END_ARRAY && depth == 0)); } - break; + break; default: // nothing more diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java index 56979730b1..5d869c6f59 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java @@ -30,15 +30,15 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch.cat.OpenSearchCatAsyncClient; import org.opensearch.client.opensearch.cluster.OpenSearchClusterAsyncClient; import org.opensearch.client.opensearch.core.BulkRequest; @@ -116,6 +116,12 @@ import org.opensearch.client.opensearch.core.UpdateByQueryRethrottleResponse; import org.opensearch.client.opensearch.core.UpdateRequest; import org.opensearch.client.opensearch.core.UpdateResponse; +import org.opensearch.client.opensearch.core.pit.CreatePitRequest; +import org.opensearch.client.opensearch.core.pit.CreatePitResponse; +import org.opensearch.client.opensearch.core.pit.DeletePitRequest; +import org.opensearch.client.opensearch.core.pit.DeletePitResponse; +import org.opensearch.client.opensearch.core.pit.ListAllPitRequest; +import org.opensearch.client.opensearch.core.pit.ListAllPitResponse; import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesAsyncClient; import org.opensearch.client.opensearch.features.OpenSearchFeaturesAsyncClient; import org.opensearch.client.opensearch.indices.OpenSearchIndicesAsyncClient; @@ -124,1392 +130,1567 @@ import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownAsyncClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotAsyncClient; import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient; -import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.transport.endpoints.BooleanResponse; import org.opensearch.client.transport.endpoints.EndpointWithResponseMapperAttr; import org.opensearch.client.util.ObjectBuilder; -import java.io.IOException; -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; -import javax.annotation.Nullable; /** * Client for the namespace. */ public class OpenSearchAsyncClient extends ApiClient { - public OpenSearchAsyncClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchAsyncClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchAsyncClient(this.transport, transportOptions); - } - - // ----- Child clients - - public OpenSearchCatAsyncClient cat() { - return new OpenSearchCatAsyncClient(this.transport, this.transportOptions); - } - - - public OpenSearchClusterAsyncClient cluster() { - return new OpenSearchClusterAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchDanglingIndicesAsyncClient danglingIndices() { - return new OpenSearchDanglingIndicesAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchFeaturesAsyncClient features() { - return new OpenSearchFeaturesAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchIndicesAsyncClient indices() { - return new OpenSearchIndicesAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchIngestAsyncClient ingest() { - return new OpenSearchIngestAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchNodesAsyncClient nodes() { - return new OpenSearchNodesAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchShutdownAsyncClient shutdown() { - return new OpenSearchShutdownAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchSnapshotAsyncClient snapshot() { - return new OpenSearchSnapshotAsyncClient(this.transport, this.transportOptions); - } - - public OpenSearchTasksAsyncClient tasks() { - return new OpenSearchTasksAsyncClient(this.transport, this.transportOptions); - } - - // ----- Endpoint: bulk - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * - */ - - public CompletableFuture bulk(BulkRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) BulkRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * @param fn - * a function that initializes a builder to create the - * {@link BulkRequest} - * - */ - - public final CompletableFuture bulk(Function> fn) - throws IOException, OpenSearchException { - return bulk(fn.apply(new BulkRequest.Builder()).build()); - } - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * - */ - - public CompletableFuture bulk() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new BulkRequest.Builder().build(), BulkRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: clear_scroll - - /** - * Explicitly clears the search context for a scroll. - * - * - */ - - public CompletableFuture clearScroll(ClearScrollRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ClearScrollRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Explicitly clears the search context for a scroll. - * - * @param fn - * a function that initializes a builder to create the - * {@link ClearScrollRequest} - * - */ - - public final CompletableFuture clearScroll( - Function> fn) - throws IOException, OpenSearchException { - return clearScroll(fn.apply(new ClearScrollRequest.Builder()).build()); - } - - /** - * Explicitly clears the search context for a scroll. - * - * - */ - - public CompletableFuture clearScroll() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new ClearScrollRequest.Builder().build(), - ClearScrollRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: count - - /** - * Returns number of documents matching a query. - * - * - */ - - public CompletableFuture count(CountRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) CountRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns number of documents matching a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link CountRequest} - * - */ - - public final CompletableFuture count(Function> fn) - throws IOException, OpenSearchException { - return count(fn.apply(new CountRequest.Builder()).build()); - } - - /** - * Returns number of documents matching a query. - * - * - */ - - public CompletableFuture count() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new CountRequest.Builder().build(), CountRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: create - - /** - * Creates a new document in the index. - *

- * Returns a 409 response when a document with a same ID already exists in the - * index. - * - * - */ - - public CompletableFuture create(CreateRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, CreateResponse, ErrorResponse> endpoint = - (JsonEndpoint, CreateResponse, ErrorResponse>) CreateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates a new document in the index. - *

- * Returns a 409 response when a document with a same ID already exists in the - * index. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateRequest} - * - */ - - public final CompletableFuture create( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return create(fn.apply(new CreateRequest.Builder()).build()); - } - - // ----- Endpoint: delete - - /** - * Removes a document from the index. - * - * - */ - - public CompletableFuture delete(DeleteRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Removes a document from the index. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteRequest} - * - */ - - public final CompletableFuture delete( - Function> fn) - throws IOException, OpenSearchException { - return delete(fn.apply(new DeleteRequest.Builder()).build()); - } - - // ----- Endpoint: delete_by_query - - /** - * Deletes documents matching the provided query. - * - * - */ - - public CompletableFuture deleteByQuery(DeleteByQueryRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteByQueryRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes documents matching the provided query. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteByQueryRequest} - * - */ - - public final CompletableFuture deleteByQuery( - Function> fn) - throws IOException, OpenSearchException { - return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build()); - } - - // ----- Endpoint: delete_by_query_rethrottle - - /** - * Changes the number of requests per second for a particular Delete By Query - * operation. - * - * - */ - - public CompletableFuture deleteByQueryRethrottle( - DeleteByQueryRethrottleRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - DeleteByQueryRethrottleRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Delete By Query - * operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteByQueryRethrottleRequest} - * - */ - - public final CompletableFuture deleteByQueryRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return deleteByQueryRethrottle(fn.apply(new DeleteByQueryRethrottleRequest.Builder()).build()); - } - - // ----- Endpoint: delete_script - - /** - * Deletes a script. - * - * - */ - - public CompletableFuture deleteScript(DeleteScriptRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteScriptRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Deletes a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteScriptRequest} - * - */ - - public final CompletableFuture deleteScript( - Function> fn) - throws IOException, OpenSearchException { - return deleteScript(fn.apply(new DeleteScriptRequest.Builder()).build()); - } - - // ----- Endpoint: exists - - /** - * Returns information about whether a document exists in an index. - * - * - */ - - public CompletableFuture exists(ExistsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ExistsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a document exists in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsRequest} - * - */ - - public final CompletableFuture exists( - Function> fn) - throws IOException, OpenSearchException { - return exists(fn.apply(new ExistsRequest.Builder()).build()); - } - - // ----- Endpoint: exists_source - - /** - * Returns information about whether a document source exists in an index. - * - * - */ - - public CompletableFuture existsSource(ExistsSourceRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ExistsSourceRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a document source exists in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsSourceRequest} - * - */ - - public final CompletableFuture existsSource( - Function> fn) - throws IOException, OpenSearchException { - return existsSource(fn.apply(new ExistsSourceRequest.Builder()).build()); - } - - // ----- Endpoint: explain - - /** - * Returns information about why a specific matches (or doesn't match) a query. - * - * - */ - - public CompletableFuture> explain(ExplainRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) ExplainRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.explain.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about why a specific matches (or doesn't match) a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExplainRequest} - * - */ - - public final CompletableFuture> explain( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return explain(fn.apply(new ExplainRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: field_caps - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - */ - - public CompletableFuture fieldCaps(FieldCapsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) FieldCapsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link FieldCapsRequest} - * - */ - - public final CompletableFuture fieldCaps( - Function> fn) - throws IOException, OpenSearchException { - return fieldCaps(fn.apply(new FieldCapsRequest.Builder()).build()); - } - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * - */ - - public CompletableFuture fieldCaps() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new FieldCapsRequest.Builder().build(), FieldCapsRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get - - /** - * Returns a document. - * - * - */ - - public CompletableFuture> get(GetRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) GetRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.get.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns a document. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetRequest} - * - */ - - public final CompletableFuture> get( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return get(fn.apply(new GetRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: get_script - - /** - * Returns a script. - * - * - */ - - public CompletableFuture getScript(GetScriptRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) GetScriptRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetScriptRequest} - * - */ - - public final CompletableFuture getScript( - Function> fn) - throws IOException, OpenSearchException { - return getScript(fn.apply(new GetScriptRequest.Builder()).build()); - } - - // ----- Endpoint: get_script_context - - /** - * Returns all script contexts. - * - * - */ - public CompletableFuture getScriptContext() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(GetScriptContextRequest._INSTANCE, GetScriptContextRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get_script_languages - - /** - * Returns available script types, languages and contexts - * - * - */ - public CompletableFuture getScriptLanguages() - throws IOException, OpenSearchException { - return this.transport.performRequestAsync(GetScriptLanguagesRequest._INSTANCE, - GetScriptLanguagesRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: get_source - - /** - * Returns the source of a document. - * - * - */ - - public CompletableFuture> getSource(GetSourceRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) GetSourceRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.get_source.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns the source of a document. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetSourceRequest} - * - */ - - public final CompletableFuture> getSource( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return getSource(fn.apply(new GetSourceRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: index - - /** - * Creates or updates a document in an index. - * - * - */ - - public CompletableFuture index(IndexRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, IndexResponse, ErrorResponse> endpoint = - (JsonEndpoint, IndexResponse, ErrorResponse>) IndexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates a document in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link IndexRequest} - * - */ - - public final CompletableFuture index( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return index(fn.apply(new IndexRequest.Builder()).build()); - } - - // ----- Endpoint: info - - /** - * Returns basic information about the cluster. - * - * - */ - public CompletableFuture info() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: mget - - /** - * Allows to get multiple documents in one request. - * - * - */ - - public CompletableFuture> mget(MgetRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) MgetRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.mget.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to get multiple documents in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MgetRequest} - * - */ - - public final CompletableFuture> mget( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return mget(fn.apply(new MgetRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: msearch - - /** - * Allows to execute several search operations in one request. - * - * - */ - - public CompletableFuture> msearch(MsearchRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) MsearchRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.msearch.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to execute several search operations in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MsearchRequest} - * - */ - - public final CompletableFuture> msearch( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return msearch(fn.apply(new MsearchRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: msearch_template - - /** - * Allows to execute several search template operations in one request. - * - * - */ - - public CompletableFuture> msearchTemplate( - MsearchTemplateRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - MsearchTemplateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.msearch_template.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to execute several search template operations in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MsearchTemplateRequest} - * - */ - - public final CompletableFuture> msearchTemplate( - Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return msearchTemplate(fn.apply(new MsearchTemplateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: mtermvectors - - /** - * Returns multiple termvectors in one request. - * - * - */ - - public CompletableFuture mtermvectors(MtermvectorsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) MtermvectorsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns multiple termvectors in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MtermvectorsRequest} - * - */ - - public final CompletableFuture mtermvectors( - Function> fn) - throws IOException, OpenSearchException { - return mtermvectors(fn.apply(new MtermvectorsRequest.Builder()).build()); - } - - /** - * Returns multiple termvectors in one request. - * - * - */ - - public CompletableFuture mtermvectors() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new MtermvectorsRequest.Builder().build(), - MtermvectorsRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: ping - - /** - * Returns whether the cluster is running. - * - * - */ - public CompletableFuture ping() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(PingRequest._INSTANCE, PingRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: put_script - - /** - * Creates or updates a script. - * - * - */ - - public CompletableFuture putScript(PutScriptRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) PutScriptRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link PutScriptRequest} - * - */ - - public final CompletableFuture putScript( - Function> fn) - throws IOException, OpenSearchException { - return putScript(fn.apply(new PutScriptRequest.Builder()).build()); - } - - // ----- Endpoint: rank_eval - - /** - * Allows to evaluate the quality of ranked search results over a set of typical - * search queries - * - * - */ - - public CompletableFuture rankEval(RankEvalRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) RankEvalRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to evaluate the quality of ranked search results over a set of typical - * search queries - * - * @param fn - * a function that initializes a builder to create the - * {@link RankEvalRequest} - * - */ - - public final CompletableFuture rankEval( - Function> fn) - throws IOException, OpenSearchException { - return rankEval(fn.apply(new RankEvalRequest.Builder()).build()); - } - - // ----- Endpoint: reindex - - /** - * 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. - * - * - */ - - public CompletableFuture reindex(ReindexRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ReindexRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * 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. - * - * @param fn - * a function that initializes a builder to create the - * {@link ReindexRequest} - * - */ - - public final CompletableFuture reindex( - Function> fn) - throws IOException, OpenSearchException { - return reindex(fn.apply(new ReindexRequest.Builder()).build()); - } - - /** - * 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. - * - * - */ - - public CompletableFuture reindex() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new ReindexRequest.Builder().build(), ReindexRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: reindex_rethrottle - - /** - * Changes the number of requests per second for a particular Reindex operation. - * - * - */ - - public CompletableFuture reindexRethrottle(ReindexRethrottleRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - ReindexRethrottleRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Reindex operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link ReindexRethrottleRequest} - * - */ - - public final CompletableFuture reindexRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return reindexRethrottle(fn.apply(new ReindexRethrottleRequest.Builder()).build()); - } - - // ----- Endpoint: render_search_template - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public CompletableFuture renderSearchTemplate(RenderSearchTemplateRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - RenderSearchTemplateRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * @param fn - * a function that initializes a builder to create the - * {@link RenderSearchTemplateRequest} - * - */ - - public final CompletableFuture renderSearchTemplate( - Function> fn) - throws IOException, OpenSearchException { - return renderSearchTemplate(fn.apply(new RenderSearchTemplateRequest.Builder()).build()); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public CompletableFuture renderSearchTemplate() - throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new RenderSearchTemplateRequest.Builder().build(), - RenderSearchTemplateRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: scripts_painless_execute - - /** - * Allows an arbitrary script to be executed and a result to be returned - * - * - */ - - public CompletableFuture> scriptsPainlessExecute( - ScriptsPainlessExecuteRequest request, Class tResultClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - ScriptsPainlessExecuteRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.scripts_painless_execute.TResult", - getDeserializer(tResultClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows an arbitrary script to be executed and a result to be returned - * - * @param fn - * a function that initializes a builder to create the - * {@link ScriptsPainlessExecuteRequest} - * - */ - - public final CompletableFuture> scriptsPainlessExecute( - Function> fn, - Class tResultClass) throws IOException, OpenSearchException { - return scriptsPainlessExecute(fn.apply(new ScriptsPainlessExecuteRequest.Builder()).build(), tResultClass); - } - - // ----- Endpoint: scroll - - /** - * Allows to retrieve a large numbers of results from a single search request. - * - */ - - public CompletableFuture> scroll(ScrollRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) ScrollRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.scroll.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to retrieve a large numbers of results from a single search request. - * - * @param fn - * a function that initializes a builder to create the - * {@link ScrollRequest} - */ - - public final CompletableFuture> scroll( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return scroll(fn.apply(new ScrollRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: search - - /** - * Returns results matching a query. - * - * - */ - - public CompletableFuture> search(SearchRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) SearchRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.search.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns results matching a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchRequest} - * - */ - - public final CompletableFuture> search( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return search(fn.apply(new SearchRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: search_shards - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * - */ - - public CompletableFuture searchShards(SearchShardsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) SearchShardsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchShardsRequest} - * - */ - - public final CompletableFuture searchShards( - Function> fn) - throws IOException, OpenSearchException { - return searchShards(fn.apply(new SearchShardsRequest.Builder()).build()); - } - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * - */ - - public CompletableFuture searchShards() throws IOException, OpenSearchException { - return this.transport.performRequestAsync(new SearchShardsRequest.Builder().build(), - SearchShardsRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: search_template - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public CompletableFuture> searchTemplate( - SearchTemplateRequest request, Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - SearchTemplateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.search_template.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchTemplateRequest} - * - */ - - public final CompletableFuture> searchTemplate( - Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: terms_enum - - /** - * 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. - * - * - */ - - public CompletableFuture termsEnum(TermsEnumRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) TermsEnumRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * 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. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermsEnumRequest} - * - */ - - public final CompletableFuture termsEnum( - Function> fn) - throws IOException, OpenSearchException { - return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); - } - - // ----- Endpoint: termvectors - - /** - * Returns information and statistics about terms in the fields of a particular - * document. - * - * - */ - - public CompletableFuture termvectors(TermvectorsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, TermvectorsResponse, ErrorResponse> endpoint = - (JsonEndpoint, TermvectorsResponse, ErrorResponse>) TermvectorsRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Returns information and statistics about terms in the fields of a particular - * document. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermvectorsRequest} - * - */ - - public final CompletableFuture termvectors( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return termvectors(fn.apply(new TermvectorsRequest.Builder()).build()); - } - - // ----- Endpoint: update - - /** - * Updates a document with a script or partial document. - * - * - */ - - public CompletableFuture> update( - UpdateRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, UpdateResponse, ErrorResponse> endpoint = - (JsonEndpoint, UpdateResponse, ErrorResponse>) UpdateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.update.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Updates a document with a script or partial document. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateRequest} - * - */ - - public final CompletableFuture> update( - Function, - ObjectBuilder>> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return update(fn.apply(new UpdateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: update_by_query - - /** - * Performs an update on every document in the index without changing the - * source, for example to pick up a mapping change. - * - * - */ - - public CompletableFuture updateByQuery(UpdateByQueryRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - UpdateByQueryRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Performs an update on every document in the index without changing the - * source, for example to pick up a mapping change. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateByQueryRequest} - * - */ - - public final CompletableFuture updateByQuery( - Function> fn) - throws IOException, OpenSearchException { - return updateByQuery(fn.apply(new UpdateByQueryRequest.Builder()).build()); - } - - // ----- Endpoint: update_by_query_rethrottle - - /** - * Changes the number of requests per second for a particular Update By Query - * operation. - * - * - */ - - public CompletableFuture updateByQueryRethrottle( - UpdateByQueryRethrottleRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - UpdateByQueryRethrottleRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Update By Query - * operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateByQueryRethrottleRequest} - * - */ - - public final CompletableFuture updateByQueryRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return updateByQueryRethrottle(fn.apply(new UpdateByQueryRethrottleRequest.Builder()).build()); - } + public OpenSearchAsyncClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchAsyncClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public OpenSearchAsyncClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchAsyncClient(this.transport, transportOptions); + } + + // ----- Child clients + + public OpenSearchCatAsyncClient cat() { + return new OpenSearchCatAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchClusterAsyncClient cluster() { + return new OpenSearchClusterAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchDanglingIndicesAsyncClient danglingIndices() { + return new OpenSearchDanglingIndicesAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchFeaturesAsyncClient features() { + return new OpenSearchFeaturesAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchIndicesAsyncClient indices() { + return new OpenSearchIndicesAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchIngestAsyncClient ingest() { + return new OpenSearchIngestAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchNodesAsyncClient nodes() { + return new OpenSearchNodesAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchShutdownAsyncClient shutdown() { + return new OpenSearchShutdownAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchSnapshotAsyncClient snapshot() { + return new OpenSearchSnapshotAsyncClient(this.transport, this.transportOptions); + } + + public OpenSearchTasksAsyncClient tasks() { + return new OpenSearchTasksAsyncClient(this.transport, this.transportOptions); + } + + // ----- Endpoint: bulk + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * + */ + + public CompletableFuture bulk(BulkRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + BulkRequest, + BulkResponse, + ErrorResponse>) BulkRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * @param fn + * a function that initializes a builder to create the + * {@link BulkRequest} + * + */ + + public final CompletableFuture bulk(Function> fn) throws IOException, + OpenSearchException { + return bulk(fn.apply(new BulkRequest.Builder()).build()); + } + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * + */ + + public CompletableFuture bulk() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(new BulkRequest.Builder().build(), BulkRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: clear_scroll + + /** + * Explicitly clears the search context for a scroll. + * + * + */ + + public CompletableFuture clearScroll(ClearScrollRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ClearScrollRequest, + ClearScrollResponse, + ErrorResponse>) ClearScrollRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Explicitly clears the search context for a scroll. + * + * @param fn + * a function that initializes a builder to create the + * {@link ClearScrollRequest} + * + */ + + public final CompletableFuture clearScroll( + Function> fn + ) throws IOException, OpenSearchException { + return clearScroll(fn.apply(new ClearScrollRequest.Builder()).build()); + } + + /** + * Explicitly clears the search context for a scroll. + * + * + */ + + public CompletableFuture clearScroll() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new ClearScrollRequest.Builder().build(), + ClearScrollRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: count + + /** + * Returns number of documents matching a query. + * + * + */ + + public CompletableFuture count(CountRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + CountRequest, + CountResponse, + ErrorResponse>) CountRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns number of documents matching a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link CountRequest} + * + */ + + public final CompletableFuture count(Function> fn) throws IOException, + OpenSearchException { + return count(fn.apply(new CountRequest.Builder()).build()); + } + + /** + * Returns number of documents matching a query. + * + * + */ + + public CompletableFuture count() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(new CountRequest.Builder().build(), CountRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: create + + /** + * Creates a new document in the index. + *

+ * Returns a 409 response when a document with a same ID already exists in the + * index. + * + * + */ + + public CompletableFuture create(CreateRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, CreateResponse, ErrorResponse> endpoint = (JsonEndpoint< + CreateRequest, + CreateResponse, + ErrorResponse>) CreateRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Creates a new document in the index. + *

+ * Returns a 409 response when a document with a same ID already exists in the + * index. + * + * @param fn + * a function that initializes a builder to create the + * {@link CreateRequest} + * + */ + + public final CompletableFuture create( + Function, ObjectBuilder>> fn + ) throws IOException, OpenSearchException { + return create(fn.apply(new CreateRequest.Builder()).build()); + } + + // ----- Endpoint: create_point_in_time + + /** + * Provides low-level information about the disk utilization of a PIT by + * describing its Lucene segments. + * + * + */ + + public CompletableFuture createPit(CreatePitRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + CreatePitRequest, + CreatePitResponse, + ErrorResponse>) CreatePitRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Provides low-level information about the disk utilization of a PIT by + * describing its Lucene segments. + * + * @param fn + * a function that initializes a builder to create the + * {@link CreatePitRequest} + * + */ + + public final CompletableFuture createPit(Function> fn) + throws IOException, OpenSearchException { + return createPit(fn.apply(new CreatePitRequest.Builder()).build()); + } + + // ----- Endpoint: delete + + /** + * Removes a document from the index. + * + * + */ + + public CompletableFuture delete(DeleteRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteRequest, + DeleteResponse, + ErrorResponse>) DeleteRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Removes a document from the index. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteRequest} + * + */ + + public final CompletableFuture delete(Function> fn) + throws IOException, OpenSearchException { + return delete(fn.apply(new DeleteRequest.Builder()).build()); + } + + // ----- Endpoint: delete_point_in_time + + /** + * Delete Point In Time + * + * + */ + + public CompletableFuture deletePit(DeletePitRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeletePitRequest, + DeletePitResponse, + ErrorResponse>) DeletePitRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Delete Point In Time + * + * @param fn + * a function that initializes a builder to create the + * {@link DeletePitRequest} + * + */ + + public final CompletableFuture deletePit(Function> fn) + throws IOException, OpenSearchException { + return deletePit(fn.apply(new DeletePitRequest.Builder()).build()); + } + + // ----- Endpoint: delete_by_query + + /** + * Deletes documents matching the provided query. + * + * + */ + + public CompletableFuture deleteByQuery(DeleteByQueryRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteByQueryRequest, + DeleteByQueryResponse, + ErrorResponse>) DeleteByQueryRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Deletes documents matching the provided query. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteByQueryRequest} + * + */ + + public final CompletableFuture deleteByQuery( + Function> fn + ) throws IOException, OpenSearchException { + return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build()); + } + + // ----- Endpoint: delete_by_query_rethrottle + + /** + * Changes the number of requests per second for a particular Delete By Query + * operation. + * + * + */ + + public CompletableFuture deleteByQueryRethrottle(DeleteByQueryRethrottleRequest request) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteByQueryRethrottleRequest, + DeleteByQueryRethrottleResponse, + ErrorResponse>) DeleteByQueryRethrottleRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Delete By Query + * operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteByQueryRethrottleRequest} + * + */ + + public final CompletableFuture deleteByQueryRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return deleteByQueryRethrottle(fn.apply(new DeleteByQueryRethrottleRequest.Builder()).build()); + } + + // ----- Endpoint: delete_script + + /** + * Deletes a script. + * + * + */ + + public CompletableFuture deleteScript(DeleteScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteScriptRequest, + DeleteScriptResponse, + ErrorResponse>) DeleteScriptRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Deletes a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteScriptRequest} + * + */ + + public final CompletableFuture deleteScript( + Function> fn + ) throws IOException, OpenSearchException { + return deleteScript(fn.apply(new DeleteScriptRequest.Builder()).build()); + } + + // ----- Endpoint: exists + + /** + * Returns information about whether a document exists in an index. + * + * + */ + + public CompletableFuture exists(ExistsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ExistsRequest, + BooleanResponse, + ErrorResponse>) ExistsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information about whether a document exists in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExistsRequest} + * + */ + + public final CompletableFuture exists(Function> fn) + throws IOException, OpenSearchException { + return exists(fn.apply(new ExistsRequest.Builder()).build()); + } + + // ----- Endpoint: exists_source + + /** + * Returns information about whether a document source exists in an index. + * + * + */ + + public CompletableFuture existsSource(ExistsSourceRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ExistsSourceRequest, + BooleanResponse, + ErrorResponse>) ExistsSourceRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information about whether a document source exists in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExistsSourceRequest} + * + */ + + public final CompletableFuture existsSource( + Function> fn + ) throws IOException, OpenSearchException { + return existsSource(fn.apply(new ExistsSourceRequest.Builder()).build()); + } + + // ----- Endpoint: explain + + /** + * Returns information about why a specific matches (or doesn't match) a query. + * + * + */ + + public CompletableFuture> explain(ExplainRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ExplainRequest, + ExplainResponse, + ErrorResponse>) ExplainRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.explain.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information about why a specific matches (or doesn't match) a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExplainRequest} + * + */ + + public final CompletableFuture> explain( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return explain(fn.apply(new ExplainRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: field_caps + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + */ + + public CompletableFuture fieldCaps(FieldCapsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + FieldCapsRequest, + FieldCapsResponse, + ErrorResponse>) FieldCapsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * @param fn + * a function that initializes a builder to create the + * {@link FieldCapsRequest} + * + */ + + public final CompletableFuture fieldCaps(Function> fn) + throws IOException, OpenSearchException { + return fieldCaps(fn.apply(new FieldCapsRequest.Builder()).build()); + } + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * + */ + + public CompletableFuture fieldCaps() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new FieldCapsRequest.Builder().build(), + FieldCapsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: get + + /** + * Returns a document. + * + * + */ + + public CompletableFuture> get(GetRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + GetRequest, + GetResponse, + ErrorResponse>) GetRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.get.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns a document. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRequest} + * + */ + + public final CompletableFuture> get( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return get(fn.apply(new GetRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: get_script + + /** + * Returns a script. + * + * + */ + + public CompletableFuture getScript(GetScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + GetScriptRequest, + GetScriptResponse, + ErrorResponse>) GetScriptRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetScriptRequest} + * + */ + + public final CompletableFuture getScript(Function> fn) + throws IOException, OpenSearchException { + return getScript(fn.apply(new GetScriptRequest.Builder()).build()); + } + + // ----- Endpoint: get_script_context + + /** + * Returns all script contexts. + * + * + */ + public CompletableFuture getScriptContext() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + GetScriptContextRequest._INSTANCE, + GetScriptContextRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: get_script_languages + + /** + * Returns available script types, languages and contexts + * + * + */ + public CompletableFuture getScriptLanguages() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + GetScriptLanguagesRequest._INSTANCE, + GetScriptLanguagesRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: get_source + + /** + * Returns the source of a document. + * + * + */ + + public CompletableFuture> getSource(GetSourceRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + GetSourceRequest, + GetSourceResponse, + ErrorResponse>) GetSourceRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.get_source.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns the source of a document. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetSourceRequest} + * + */ + + public final CompletableFuture> getSource( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return getSource(fn.apply(new GetSourceRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: index + + /** + * Creates or updates a document in an index. + * + * + */ + + public CompletableFuture index(IndexRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, IndexResponse, ErrorResponse> endpoint = (JsonEndpoint< + IndexRequest, + IndexResponse, + ErrorResponse>) IndexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Creates or updates a document in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link IndexRequest} + * + */ + + public final CompletableFuture index( + Function, ObjectBuilder>> fn + ) throws IOException, OpenSearchException { + return index(fn.apply(new IndexRequest.Builder()).build()); + } + + // ----- Endpoint: info + + /** + * Returns basic information about the cluster. + * + * + */ + public CompletableFuture info() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: list_point_in_time + + /** + * List all Point In Time + * + * + */ + + public CompletableFuture listAllPit() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(ListAllPitRequest._INSTANCE, ListAllPitRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: mget + + /** + * Allows to get multiple documents in one request. + * + * + */ + + public CompletableFuture> mget(MgetRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MgetRequest, + MgetResponse, + ErrorResponse>) MgetRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.mget.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to get multiple documents in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MgetRequest} + * + */ + + public final CompletableFuture> mget( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return mget(fn.apply(new MgetRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: msearch + + /** + * Allows to execute several search operations in one request. + * + * + */ + + public CompletableFuture> msearch(MsearchRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MsearchRequest, + MsearchResponse, + ErrorResponse>) MsearchRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.msearch.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to execute several search operations in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MsearchRequest} + * + */ + + public final CompletableFuture> msearch( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return msearch(fn.apply(new MsearchRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: msearch_template + + /** + * Allows to execute several search template operations in one request. + * + * + */ + + public CompletableFuture> msearchTemplate( + MsearchTemplateRequest request, + Class tDocumentClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MsearchTemplateRequest, + MsearchTemplateResponse, + ErrorResponse>) MsearchTemplateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.msearch_template.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to execute several search template operations in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MsearchTemplateRequest} + * + */ + + public final CompletableFuture> msearchTemplate( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return msearchTemplate(fn.apply(new MsearchTemplateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: mtermvectors + + /** + * Returns multiple termvectors in one request. + * + * + */ + + public CompletableFuture mtermvectors(MtermvectorsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + MtermvectorsRequest, + MtermvectorsResponse, + ErrorResponse>) MtermvectorsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns multiple termvectors in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MtermvectorsRequest} + * + */ + + public final CompletableFuture mtermvectors( + Function> fn + ) throws IOException, OpenSearchException { + return mtermvectors(fn.apply(new MtermvectorsRequest.Builder()).build()); + } + + /** + * Returns multiple termvectors in one request. + * + * + */ + + public CompletableFuture mtermvectors() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new MtermvectorsRequest.Builder().build(), + MtermvectorsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: ping + + /** + * Returns whether the cluster is running. + * + * + */ + public CompletableFuture ping() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(PingRequest._INSTANCE, PingRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: put_script + + /** + * Creates or updates a script. + * + * + */ + + public CompletableFuture putScript(PutScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + PutScriptRequest, + PutScriptResponse, + ErrorResponse>) PutScriptRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Creates or updates a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link PutScriptRequest} + * + */ + + public final CompletableFuture putScript(Function> fn) + throws IOException, OpenSearchException { + return putScript(fn.apply(new PutScriptRequest.Builder()).build()); + } + + // ----- Endpoint: rank_eval + + /** + * Allows to evaluate the quality of ranked search results over a set of typical + * search queries + * + * + */ + + public CompletableFuture rankEval(RankEvalRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + RankEvalRequest, + RankEvalResponse, + ErrorResponse>) RankEvalRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to evaluate the quality of ranked search results over a set of typical + * search queries + * + * @param fn + * a function that initializes a builder to create the + * {@link RankEvalRequest} + * + */ + + public final CompletableFuture rankEval(Function> fn) + throws IOException, OpenSearchException { + return rankEval(fn.apply(new RankEvalRequest.Builder()).build()); + } + + // ----- Endpoint: reindex + + /** + * 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. + * + * + */ + + public CompletableFuture reindex(ReindexRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ReindexRequest, + ReindexResponse, + ErrorResponse>) ReindexRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * 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. + * + * @param fn + * a function that initializes a builder to create the + * {@link ReindexRequest} + * + */ + + public final CompletableFuture reindex(Function> fn) + throws IOException, OpenSearchException { + return reindex(fn.apply(new ReindexRequest.Builder()).build()); + } + + /** + * 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. + * + * + */ + + public CompletableFuture reindex() throws IOException, OpenSearchException { + return this.transport.performRequestAsync(new ReindexRequest.Builder().build(), ReindexRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: reindex_rethrottle + + /** + * Changes the number of requests per second for a particular Reindex operation. + * + * + */ + + public CompletableFuture reindexRethrottle(ReindexRethrottleRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ReindexRethrottleRequest, + ReindexRethrottleResponse, + ErrorResponse>) ReindexRethrottleRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Reindex operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link ReindexRethrottleRequest} + * + */ + + public final CompletableFuture reindexRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return reindexRethrottle(fn.apply(new ReindexRethrottleRequest.Builder()).build()); + } + + // ----- Endpoint: render_search_template + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public CompletableFuture renderSearchTemplate(RenderSearchTemplateRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + RenderSearchTemplateRequest, + RenderSearchTemplateResponse, + ErrorResponse>) RenderSearchTemplateRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * @param fn + * a function that initializes a builder to create the + * {@link RenderSearchTemplateRequest} + * + */ + + public final CompletableFuture renderSearchTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return renderSearchTemplate(fn.apply(new RenderSearchTemplateRequest.Builder()).build()); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public CompletableFuture renderSearchTemplate() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new RenderSearchTemplateRequest.Builder().build(), + RenderSearchTemplateRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: scripts_painless_execute + + /** + * Allows an arbitrary script to be executed and a result to be returned + * + * + */ + + public CompletableFuture> scriptsPainlessExecute( + ScriptsPainlessExecuteRequest request, + Class tResultClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ScriptsPainlessExecuteRequest, + ScriptsPainlessExecuteResponse, + ErrorResponse>) ScriptsPainlessExecuteRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.scripts_painless_execute.TResult", + getDeserializer(tResultClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows an arbitrary script to be executed and a result to be returned + * + * @param fn + * a function that initializes a builder to create the + * {@link ScriptsPainlessExecuteRequest} + * + */ + + public final CompletableFuture> scriptsPainlessExecute( + Function> fn, + Class tResultClass + ) throws IOException, OpenSearchException { + return scriptsPainlessExecute(fn.apply(new ScriptsPainlessExecuteRequest.Builder()).build(), tResultClass); + } + + // ----- Endpoint: scroll + + /** + * Allows to retrieve a large numbers of results from a single search request. + * + */ + + public CompletableFuture> scroll(ScrollRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ScrollRequest, + ScrollResponse, + ErrorResponse>) ScrollRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.scroll.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to retrieve a large numbers of results from a single search request. + * + * @param fn + * a function that initializes a builder to create the + * {@link ScrollRequest} + */ + + public final CompletableFuture> scroll( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return scroll(fn.apply(new ScrollRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: search + + /** + * Returns results matching a query. + * + * + */ + + public CompletableFuture> search(SearchRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + SearchRequest, + SearchResponse, + ErrorResponse>) SearchRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.search.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns results matching a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchRequest} + * + */ + + public final CompletableFuture> search( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return search(fn.apply(new SearchRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: search_shards + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * + */ + + public CompletableFuture searchShards(SearchShardsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + SearchShardsRequest, + SearchShardsResponse, + ErrorResponse>) SearchShardsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchShardsRequest} + * + */ + + public final CompletableFuture searchShards( + Function> fn + ) throws IOException, OpenSearchException { + return searchShards(fn.apply(new SearchShardsRequest.Builder()).build()); + } + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * + */ + + public CompletableFuture searchShards() throws IOException, OpenSearchException { + return this.transport.performRequestAsync( + new SearchShardsRequest.Builder().build(), + SearchShardsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: search_template + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public CompletableFuture> searchTemplate( + SearchTemplateRequest request, + Class tDocumentClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + SearchTemplateRequest, + SearchTemplateResponse, + ErrorResponse>) SearchTemplateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.search_template.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchTemplateRequest} + * + */ + + public final CompletableFuture> searchTemplate( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: terms_enum + + /** + * 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. + * + * + */ + + public CompletableFuture termsEnum(TermsEnumRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + TermsEnumRequest, + TermsEnumResponse, + ErrorResponse>) TermsEnumRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * 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. + * + * @param fn + * a function that initializes a builder to create the + * {@link TermsEnumRequest} + * + */ + + public final CompletableFuture termsEnum(Function> fn) + throws IOException, OpenSearchException { + return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); + } + + // ----- Endpoint: termvectors + + /** + * Returns information and statistics about terms in the fields of a particular + * document. + * + * + */ + + public CompletableFuture termvectors(TermvectorsRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, TermvectorsResponse, ErrorResponse> endpoint = (JsonEndpoint< + TermvectorsRequest, + TermvectorsResponse, + ErrorResponse>) TermvectorsRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Returns information and statistics about terms in the fields of a particular + * document. + * + * @param fn + * a function that initializes a builder to create the + * {@link TermvectorsRequest} + * + */ + + public final CompletableFuture termvectors( + Function, ObjectBuilder>> fn + ) throws IOException, OpenSearchException { + return termvectors(fn.apply(new TermvectorsRequest.Builder()).build()); + } + + // ----- Endpoint: update + + /** + * Updates a document with a script or partial document. + * + * + */ + + public CompletableFuture> update( + UpdateRequest request, + Class tDocumentClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, UpdateResponse, ErrorResponse> endpoint = (JsonEndpoint< + UpdateRequest, + UpdateResponse, + ErrorResponse>) UpdateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.update.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Updates a document with a script or partial document. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateRequest} + * + */ + + public final CompletableFuture> update( + Function, ObjectBuilder>> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return update(fn.apply(new UpdateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: update_by_query + + /** + * Performs an update on every document in the index without changing the + * source, for example to pick up a mapping change. + * + * + */ + + public CompletableFuture updateByQuery(UpdateByQueryRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + UpdateByQueryRequest, + UpdateByQueryResponse, + ErrorResponse>) UpdateByQueryRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Performs an update on every document in the index without changing the + * source, for example to pick up a mapping change. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateByQueryRequest} + * + */ + + public final CompletableFuture updateByQuery( + Function> fn + ) throws IOException, OpenSearchException { + return updateByQuery(fn.apply(new UpdateByQueryRequest.Builder()).build()); + } + + // ----- Endpoint: update_by_query_rethrottle + + /** + * Changes the number of requests per second for a particular Update By Query + * operation. + * + * + */ + + public CompletableFuture updateByQueryRethrottle(UpdateByQueryRethrottleRequest request) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + UpdateByQueryRethrottleRequest, + UpdateByQueryRethrottleResponse, + ErrorResponse>) UpdateByQueryRethrottleRequest._ENDPOINT; + + return this.transport.performRequestAsync(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Update By Query + * operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateByQueryRethrottleRequest} + * + */ + + public final CompletableFuture updateByQueryRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return updateByQueryRethrottle(fn.apply(new UpdateByQueryRethrottleRequest.Builder()).build()); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java index 56ef79d5b1..3b2d8d76ff 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java @@ -30,15 +30,14 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch; +import java.io.IOException; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.ApiClient; -import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch._types.ErrorResponse; +import org.opensearch.client.opensearch._types.OpenSearchException; import org.opensearch.client.opensearch.cat.OpenSearchCatClient; import org.opensearch.client.opensearch.cluster.OpenSearchClusterClient; import org.opensearch.client.opensearch.core.BulkRequest; @@ -116,6 +115,12 @@ import org.opensearch.client.opensearch.core.UpdateByQueryRethrottleResponse; import org.opensearch.client.opensearch.core.UpdateRequest; import org.opensearch.client.opensearch.core.UpdateResponse; +import org.opensearch.client.opensearch.core.pit.CreatePitRequest; +import org.opensearch.client.opensearch.core.pit.CreatePitResponse; +import org.opensearch.client.opensearch.core.pit.DeletePitRequest; +import org.opensearch.client.opensearch.core.pit.DeletePitResponse; +import org.opensearch.client.opensearch.core.pit.ListAllPitRequest; +import org.opensearch.client.opensearch.core.pit.ListAllPitResponse; import org.opensearch.client.opensearch.dangling_indices.OpenSearchDanglingIndicesClient; import org.opensearch.client.opensearch.features.OpenSearchFeaturesClient; import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient; @@ -124,1369 +129,1540 @@ import org.opensearch.client.opensearch.shutdown.OpenSearchShutdownClient; import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotClient; import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient; -import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.JsonEndpoint; +import org.opensearch.client.transport.OpenSearchTransport; import org.opensearch.client.transport.TransportOptions; import org.opensearch.client.transport.endpoints.BooleanResponse; import org.opensearch.client.transport.endpoints.EndpointWithResponseMapperAttr; import org.opensearch.client.util.ObjectBuilder; -import java.io.IOException; -import java.util.function.Function; -import javax.annotation.Nullable; /** * Client for the namespace. */ public class OpenSearchClient extends ApiClient { - public OpenSearchClient(OpenSearchTransport transport) { - super(transport, null); - } - - public OpenSearchClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { - super(transport, transportOptions); - } - - @Override - public OpenSearchClient withTransportOptions(@Nullable TransportOptions transportOptions) { - return new OpenSearchClient(this.transport, transportOptions); - } - - // ----- Child clients - - public OpenSearchCatClient cat() { - return new OpenSearchCatClient(this.transport, this.transportOptions); - } - - public OpenSearchClusterClient cluster() { - return new OpenSearchClusterClient(this.transport, this.transportOptions); - } - - public OpenSearchDanglingIndicesClient danglingIndices() { - return new OpenSearchDanglingIndicesClient(this.transport, this.transportOptions); - } - - public OpenSearchFeaturesClient features() { - return new OpenSearchFeaturesClient(this.transport, this.transportOptions); - } - - public OpenSearchIndicesClient indices() { - return new OpenSearchIndicesClient(this.transport, this.transportOptions); - } - - public OpenSearchIngestClient ingest() { - return new OpenSearchIngestClient(this.transport, this.transportOptions); - } - - public OpenSearchNodesClient nodes() { - return new OpenSearchNodesClient(this.transport, this.transportOptions); - } - - public OpenSearchShutdownClient shutdown() { - return new OpenSearchShutdownClient(this.transport, this.transportOptions); - } - - public OpenSearchSnapshotClient snapshot() { - return new OpenSearchSnapshotClient(this.transport, this.transportOptions); - } - - public OpenSearchTasksClient tasks() { - return new OpenSearchTasksClient(this.transport, this.transportOptions); - } - - // ----- Endpoint: bulk - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * - */ - - public BulkResponse bulk(BulkRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) BulkRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * @param fn - * a function that initializes a builder to create the - * {@link BulkRequest} - * - */ - - public final BulkResponse bulk(Function> fn) - throws IOException, OpenSearchException { - return bulk(fn.apply(new BulkRequest.Builder()).build()); - } - - /** - * Allows to perform multiple index/update/delete operations in a single - * request. - * - * - */ - - public BulkResponse bulk() throws IOException, OpenSearchException { - return this.transport.performRequest(new BulkRequest.Builder().build(), BulkRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: clear_scroll - - /** - * Explicitly clears the search context for a scroll. - * - * - */ - - public ClearScrollResponse clearScroll(ClearScrollRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ClearScrollRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Explicitly clears the search context for a scroll. - * - * @param fn - * a function that initializes a builder to create the - * {@link ClearScrollRequest} - * - */ - - public final ClearScrollResponse clearScroll( - Function> fn) - throws IOException, OpenSearchException { - return clearScroll(fn.apply(new ClearScrollRequest.Builder()).build()); - } - - /** - * Explicitly clears the search context for a scroll. - * - * - */ - - public ClearScrollResponse clearScroll() throws IOException, OpenSearchException { - return this.transport.performRequest(new ClearScrollRequest.Builder().build(), ClearScrollRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: count - - /** - * Returns number of documents matching a query. - * - * - */ - - public CountResponse count(CountRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) CountRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns number of documents matching a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link CountRequest} - * - */ - - public final CountResponse count(Function> fn) - throws IOException, OpenSearchException { - return count(fn.apply(new CountRequest.Builder()).build()); - } - - /** - * Returns number of documents matching a query. - * - * - */ - - public CountResponse count() throws IOException, OpenSearchException { - return this.transport.performRequest(new CountRequest.Builder().build(), CountRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: create - - /** - * Creates a new document in the index. - *

- * Returns a 409 response when a document with a same ID already exists in the - * index. - * - * - */ - - public CreateResponse create(CreateRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, CreateResponse, ErrorResponse> endpoint = - (JsonEndpoint, CreateResponse, ErrorResponse>) CreateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates a new document in the index. - *

- * Returns a 409 response when a document with a same ID already exists in the - * index. - * - * @param fn - * a function that initializes a builder to create the - * {@link CreateRequest} - * - */ - - public final CreateResponse create( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return create(fn.apply(new CreateRequest.Builder()).build()); - } - - // ----- Endpoint: delete - - /** - * Removes a document from the index. - * - * - */ - - public DeleteResponse delete(DeleteRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Removes a document from the index. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteRequest} - * - */ - - public final DeleteResponse delete(Function> fn) - throws IOException, OpenSearchException { - return delete(fn.apply(new DeleteRequest.Builder()).build()); - } - - // ----- Endpoint: delete_by_query - - /** - * Deletes documents matching the provided query. - * - * - */ - - public DeleteByQueryResponse deleteByQuery(DeleteByQueryRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteByQueryRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes documents matching the provided query. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteByQueryRequest} - * - */ - - public final DeleteByQueryResponse deleteByQuery( - Function> fn) - throws IOException, OpenSearchException { - return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build()); - } - - // ----- Endpoint: delete_by_query_rethrottle - - /** - * Changes the number of requests per second for a particular Delete By Query - * operation. - * - * - */ - - public DeleteByQueryRethrottleResponse deleteByQueryRethrottle(DeleteByQueryRethrottleRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - DeleteByQueryRethrottleRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Delete By Query - * operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteByQueryRethrottleRequest} - * - */ - - public final DeleteByQueryRethrottleResponse deleteByQueryRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return deleteByQueryRethrottle(fn.apply(new DeleteByQueryRethrottleRequest.Builder()).build()); - } - - // ----- Endpoint: delete_script - - /** - * Deletes a script. - * - * - */ - - public DeleteScriptResponse deleteScript(DeleteScriptRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) DeleteScriptRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Deletes a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link DeleteScriptRequest} - * - */ - - public final DeleteScriptResponse deleteScript( - Function> fn) - throws IOException, OpenSearchException { - return deleteScript(fn.apply(new DeleteScriptRequest.Builder()).build()); - } - - // ----- Endpoint: exists - - /** - * Returns information about whether a document exists in an index. - * - * - */ - - public BooleanResponse exists(ExistsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ExistsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a document exists in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsRequest} - * - */ - - public final BooleanResponse exists(Function> fn) - throws IOException, OpenSearchException { - return exists(fn.apply(new ExistsRequest.Builder()).build()); - } - - // ----- Endpoint: exists_source - - /** - * Returns information about whether a document source exists in an index. - * - * - */ - - public BooleanResponse existsSource(ExistsSourceRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ExistsSourceRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about whether a document source exists in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExistsSourceRequest} - * - */ - - public final BooleanResponse existsSource( - Function> fn) - throws IOException, OpenSearchException { - return existsSource(fn.apply(new ExistsSourceRequest.Builder()).build()); - } - - // ----- Endpoint: explain - - /** - * Returns information about why a specific matches (or doesn't match) a query. - * - * - */ - - public ExplainResponse explain(ExplainRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) ExplainRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.explain.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about why a specific matches (or doesn't match) a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link ExplainRequest} - * - */ - - public final ExplainResponse explain( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return explain(fn.apply(new ExplainRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: field_caps - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * - */ - - public FieldCapsResponse fieldCaps(FieldCapsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) FieldCapsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * @param fn - * a function that initializes a builder to create the - * {@link FieldCapsRequest} - * - */ - - public final FieldCapsResponse fieldCaps(Function> fn) - throws IOException, OpenSearchException { - return fieldCaps(fn.apply(new FieldCapsRequest.Builder()).build()); - } - - /** - * Returns the information about the capabilities of fields among multiple - * indices. - * - * - */ - - public FieldCapsResponse fieldCaps() throws IOException, OpenSearchException { - return this.transport.performRequest(new FieldCapsRequest.Builder().build(), FieldCapsRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get - - /** - * Returns a document. - * - * - */ - - public GetResponse get(GetRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) GetRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.get.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns a document. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetRequest} - * - */ - - public final GetResponse get(Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return get(fn.apply(new GetRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: get_script - - /** - * Returns a script. - * - * - */ - - public GetScriptResponse getScript(GetScriptRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) GetScriptRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetScriptRequest} - * - */ - - public final GetScriptResponse getScript(Function> fn) - throws IOException, OpenSearchException { - return getScript(fn.apply(new GetScriptRequest.Builder()).build()); - } - - // ----- Endpoint: get_script_context - - /** - * Returns all script contexts. - * - * - */ - public GetScriptContextResponse getScriptContext() throws IOException, OpenSearchException { - return this.transport.performRequest(GetScriptContextRequest._INSTANCE, GetScriptContextRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get_script_languages - - /** - * Returns available script types, languages and contexts - * - * - */ - public GetScriptLanguagesResponse getScriptLanguages() throws IOException, OpenSearchException { - return this.transport.performRequest(GetScriptLanguagesRequest._INSTANCE, GetScriptLanguagesRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: get_source - - /** - * Returns the source of a document. - * - * - */ - - public GetSourceResponse getSource(GetSourceRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - GetSourceRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.get_source.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns the source of a document. - * - * @param fn - * a function that initializes a builder to create the - * {@link GetSourceRequest} - * - */ - - public final GetSourceResponse getSource( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return getSource(fn.apply(new GetSourceRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: index - - /** - * Creates or updates a document in an index. - * - * - */ - - public IndexResponse index(IndexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, IndexResponse, ErrorResponse> endpoint = - (JsonEndpoint, IndexResponse, ErrorResponse>) IndexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates a document in an index. - * - * @param fn - * a function that initializes a builder to create the - * {@link IndexRequest} - * - */ - - public final IndexResponse index( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return index(fn.apply(new IndexRequest.Builder()).build()); - } - - // ----- Endpoint: info - - /** - * Returns basic information about the cluster. - * - * - */ - public InfoResponse info() throws IOException, OpenSearchException { - return this.transport.performRequest(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: mget - - /** - * Allows to get multiple documents in one request. - * - * - */ - - public MgetResponse mget(MgetRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) MgetRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.mget.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to get multiple documents in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MgetRequest} - * - */ - - public final MgetResponse mget(Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return mget(fn.apply(new MgetRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: msearch - - /** - * Allows to execute several search operations in one request. - * - * - */ - - public MsearchResponse msearch(MsearchRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) MsearchRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.msearch.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to execute several search operations in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MsearchRequest} - * - */ - - public final MsearchResponse msearch( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return msearch(fn.apply(new MsearchRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: msearch_template - - /** - * Allows to execute several search template operations in one request. - * - * - */ - - public MsearchTemplateResponse msearchTemplate(MsearchTemplateRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - MsearchTemplateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.msearch_template.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to execute several search template operations in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MsearchTemplateRequest} - * - */ - - public final MsearchTemplateResponse msearchTemplate( - Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return msearchTemplate(fn.apply(new MsearchTemplateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: mtermvectors - - /** - * Returns multiple termvectors in one request. - * - * - */ - - public MtermvectorsResponse mtermvectors(MtermvectorsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) MtermvectorsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns multiple termvectors in one request. - * - * @param fn - * a function that initializes a builder to create the - * {@link MtermvectorsRequest} - * - */ - - public final MtermvectorsResponse mtermvectors( - Function> fn) - throws IOException, OpenSearchException { - return mtermvectors(fn.apply(new MtermvectorsRequest.Builder()).build()); - } - - /** - * Returns multiple termvectors in one request. - * - * - */ - - public MtermvectorsResponse mtermvectors() throws IOException, OpenSearchException { - return this.transport.performRequest(new MtermvectorsRequest.Builder().build(), MtermvectorsRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: ping - - /** - * Returns whether the cluster is running. - * - * - */ - public BooleanResponse ping() throws IOException, OpenSearchException { - return this.transport.performRequest(PingRequest._INSTANCE, PingRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: put_script - - /** - * Creates or updates a script. - * - * - */ - - public PutScriptResponse putScript(PutScriptRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) PutScriptRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Creates or updates a script. - * - * @param fn - * a function that initializes a builder to create the - * {@link PutScriptRequest} - * - */ - - public final PutScriptResponse putScript(Function> fn) - throws IOException, OpenSearchException { - return putScript(fn.apply(new PutScriptRequest.Builder()).build()); - } - - // ----- Endpoint: rank_eval - - /** - * Allows to evaluate the quality of ranked search results over a set of typical - * search queries - * - * - */ - - public RankEvalResponse rankEval(RankEvalRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) RankEvalRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to evaluate the quality of ranked search results over a set of typical - * search queries - * - * @param fn - * a function that initializes a builder to create the - * {@link RankEvalRequest} - * - */ - - public final RankEvalResponse rankEval(Function> fn) - throws IOException, OpenSearchException { - return rankEval(fn.apply(new RankEvalRequest.Builder()).build()); - } - - // ----- Endpoint: reindex - - /** - * 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. - * - * - */ - - public ReindexResponse reindex(ReindexRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) ReindexRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * 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. - * - * @param fn - * a function that initializes a builder to create the - * {@link ReindexRequest} - * - */ - - public final ReindexResponse reindex(Function> fn) - throws IOException, OpenSearchException { - return reindex(fn.apply(new ReindexRequest.Builder()).build()); - } - - /** - * 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. - * - * - */ - - public ReindexResponse reindex() throws IOException, OpenSearchException { - return this.transport.performRequest(new ReindexRequest.Builder().build(), ReindexRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: reindex_rethrottle - - /** - * Changes the number of requests per second for a particular Reindex operation. - * - * - */ - - public ReindexRethrottleResponse reindexRethrottle(ReindexRethrottleRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - ReindexRethrottleRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Reindex operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link ReindexRethrottleRequest} - * - */ - - public final ReindexRethrottleResponse reindexRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return reindexRethrottle(fn.apply(new ReindexRethrottleRequest.Builder()).build()); - } - - // ----- Endpoint: render_search_template - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public RenderSearchTemplateResponse renderSearchTemplate(RenderSearchTemplateRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - RenderSearchTemplateRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * @param fn - * a function that initializes a builder to create the - * {@link RenderSearchTemplateRequest} - * - */ - - public final RenderSearchTemplateResponse renderSearchTemplate( - Function> fn) - throws IOException, OpenSearchException { - return renderSearchTemplate(fn.apply(new RenderSearchTemplateRequest.Builder()).build()); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public RenderSearchTemplateResponse renderSearchTemplate() throws IOException, OpenSearchException { - return this.transport.performRequest(new RenderSearchTemplateRequest.Builder().build(), - RenderSearchTemplateRequest._ENDPOINT, this.transportOptions); - } - - // ----- Endpoint: scripts_painless_execute - - /** - * Allows an arbitrary script to be executed and a result to be returned - * - * - */ - - public ScriptsPainlessExecuteResponse scriptsPainlessExecute( - ScriptsPainlessExecuteRequest request, Class tResultClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - ScriptsPainlessExecuteRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.scripts_painless_execute.TResult", - getDeserializer(tResultClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows an arbitrary script to be executed and a result to be returned - * - * @param fn - * a function that initializes a builder to create the - * {@link ScriptsPainlessExecuteRequest} - * - */ - - public final ScriptsPainlessExecuteResponse scriptsPainlessExecute( - Function> fn, - Class tResultClass) throws IOException, OpenSearchException { - return scriptsPainlessExecute(fn.apply(new ScriptsPainlessExecuteRequest.Builder()).build(), tResultClass); - } - - // ----- Endpoint: scroll - - /** - * Allows to retrieve a large numbers of results from a single search request. - * - */ - - public ScrollResponse scroll(ScrollRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) ScrollRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.scroll.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to retrieve a large numbers of results from a single search request. - * - * @param fn - * a function that initializes a builder to create the - * {@link ScrollRequest} - */ - - public final ScrollResponse scroll( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return scroll(fn.apply(new ScrollRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: search - - /** - * Returns results matching a query. - * - * - */ - - public SearchResponse search(SearchRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) SearchRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.search.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns results matching a query. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchRequest} - * - */ - - public final SearchResponse search( - Function> fn, Class tDocumentClass) - throws IOException, OpenSearchException { - return search(fn.apply(new SearchRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: search_shards - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * - */ - - public SearchShardsResponse searchShards(SearchShardsRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) SearchShardsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchShardsRequest} - * - */ - - public final SearchShardsResponse searchShards( - Function> fn) - throws IOException, OpenSearchException { - return searchShards(fn.apply(new SearchShardsRequest.Builder()).build()); - } - - /** - * Returns information about the indices and shards that a search request would - * be executed against. - * - * - */ - - public SearchShardsResponse searchShards() throws IOException, OpenSearchException { - return this.transport.performRequest(new SearchShardsRequest.Builder().build(), SearchShardsRequest._ENDPOINT, - this.transportOptions); - } - - // ----- Endpoint: search_template - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * - */ - - public SearchTemplateResponse searchTemplate(SearchTemplateRequest request, - Class tDocumentClass) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, ErrorResponse> endpoint = - (JsonEndpoint, ErrorResponse>) - SearchTemplateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.search_template.TDocument", - getDeserializer(tDocumentClass)); - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Allows to use the Mustache language to pre-render a search definition. - * - * @param fn - * a function that initializes a builder to create the - * {@link SearchTemplateRequest} - * - */ - - public final SearchTemplateResponse searchTemplate( - Function> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: terms_enum - - /** - * 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. - * - * - */ - - public TermsEnumResponse termsEnum(TermsEnumRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) TermsEnumRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * 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. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermsEnumRequest} - * - */ - - public final TermsEnumResponse termsEnum(Function> fn) - throws IOException, OpenSearchException { - return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); - } - - // ----- Endpoint: termvectors - - /** - * Returns information and statistics about terms in the fields of a particular - * document. - * - * - */ - - public TermvectorsResponse termvectors(TermvectorsRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, TermvectorsResponse, ErrorResponse> endpoint = - (JsonEndpoint, TermvectorsResponse, ErrorResponse>) TermvectorsRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Returns information and statistics about terms in the fields of a particular - * document. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermvectorsRequest} - * - */ - - public final TermvectorsResponse termvectors( - Function, ObjectBuilder>> fn) - throws IOException, OpenSearchException { - return termvectors(fn.apply(new TermvectorsRequest.Builder()).build()); - } - - // ----- Endpoint: update - - /** - * Updates a document with a script or partial document. - * - * - */ - - public UpdateResponse update( - UpdateRequest request, Class tDocumentClass) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint, UpdateResponse, ErrorResponse> endpoint = - (JsonEndpoint, UpdateResponse, ErrorResponse>) UpdateRequest._ENDPOINT; - endpoint = new EndpointWithResponseMapperAttr<>(endpoint, - "org.opensearch.client:Deserializer:_global.update.TDocument", getDeserializer(tDocumentClass)); - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Updates a document with a script or partial document. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateRequest} - * - */ - - public final UpdateResponse update( - - Function, - ObjectBuilder>> fn, - Class tDocumentClass) throws IOException, OpenSearchException { - return update(fn.apply(new UpdateRequest.Builder()).build(), tDocumentClass); - } - - // ----- Endpoint: update_by_query - - /** - * Performs an update on every document in the index without changing the - * source, for example to pick up a mapping change. - * - * - */ - - public UpdateByQueryResponse updateByQuery(UpdateByQueryRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - UpdateByQueryRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Performs an update on every document in the index without changing the - * source, for example to pick up a mapping change. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateByQueryRequest} - * - */ - - public final UpdateByQueryResponse updateByQuery( - Function> fn) - throws IOException, OpenSearchException { - return updateByQuery(fn.apply(new UpdateByQueryRequest.Builder()).build()); - } - - // ----- Endpoint: update_by_query_rethrottle - - /** - * Changes the number of requests per second for a particular Update By Query - * operation. - * - * - */ - - public UpdateByQueryRethrottleResponse updateByQueryRethrottle(UpdateByQueryRethrottleRequest request) - throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = - (JsonEndpoint) - UpdateByQueryRethrottleRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * Changes the number of requests per second for a particular Update By Query - * operation. - * - * @param fn - * a function that initializes a builder to create the - * {@link UpdateByQueryRethrottleRequest} - * - */ - - public final UpdateByQueryRethrottleResponse updateByQueryRethrottle( - Function> fn) - throws IOException, OpenSearchException { - return updateByQueryRethrottle(fn.apply(new UpdateByQueryRethrottleRequest.Builder()).build()); - } + public OpenSearchClient(OpenSearchTransport transport) { + super(transport, null); + } + + public OpenSearchClient(OpenSearchTransport transport, @Nullable TransportOptions transportOptions) { + super(transport, transportOptions); + } + + @Override + public OpenSearchClient withTransportOptions(@Nullable TransportOptions transportOptions) { + return new OpenSearchClient(this.transport, transportOptions); + } + + // ----- Child clients + + public OpenSearchCatClient cat() { + return new OpenSearchCatClient(this.transport, this.transportOptions); + } + + public OpenSearchClusterClient cluster() { + return new OpenSearchClusterClient(this.transport, this.transportOptions); + } + + public OpenSearchDanglingIndicesClient danglingIndices() { + return new OpenSearchDanglingIndicesClient(this.transport, this.transportOptions); + } + + public OpenSearchFeaturesClient features() { + return new OpenSearchFeaturesClient(this.transport, this.transportOptions); + } + + public OpenSearchIndicesClient indices() { + return new OpenSearchIndicesClient(this.transport, this.transportOptions); + } + + public OpenSearchIngestClient ingest() { + return new OpenSearchIngestClient(this.transport, this.transportOptions); + } + + public OpenSearchNodesClient nodes() { + return new OpenSearchNodesClient(this.transport, this.transportOptions); + } + + public OpenSearchShutdownClient shutdown() { + return new OpenSearchShutdownClient(this.transport, this.transportOptions); + } + + public OpenSearchSnapshotClient snapshot() { + return new OpenSearchSnapshotClient(this.transport, this.transportOptions); + } + + public OpenSearchTasksClient tasks() { + return new OpenSearchTasksClient(this.transport, this.transportOptions); + } + + // ----- Endpoint: bulk + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * + */ + + public BulkResponse bulk(BulkRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + BulkRequest, + BulkResponse, + ErrorResponse>) BulkRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * @param fn + * a function that initializes a builder to create the + * {@link BulkRequest} + * + */ + + public final BulkResponse bulk(Function> fn) throws IOException, OpenSearchException { + return bulk(fn.apply(new BulkRequest.Builder()).build()); + } + + /** + * Allows to perform multiple index/update/delete operations in a single + * request. + * + * + */ + + public BulkResponse bulk() throws IOException, OpenSearchException { + return this.transport.performRequest(new BulkRequest.Builder().build(), BulkRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: clear_scroll + + /** + * Explicitly clears the search context for a scroll. + * + * + */ + + public ClearScrollResponse clearScroll(ClearScrollRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ClearScrollRequest, + ClearScrollResponse, + ErrorResponse>) ClearScrollRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Explicitly clears the search context for a scroll. + * + * @param fn + * a function that initializes a builder to create the + * {@link ClearScrollRequest} + * + */ + + public final ClearScrollResponse clearScroll(Function> fn) + throws IOException, OpenSearchException { + return clearScroll(fn.apply(new ClearScrollRequest.Builder()).build()); + } + + /** + * Explicitly clears the search context for a scroll. + * + * + */ + + public ClearScrollResponse clearScroll() throws IOException, OpenSearchException { + return this.transport.performRequest(new ClearScrollRequest.Builder().build(), ClearScrollRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: count + + /** + * Returns number of documents matching a query. + * + * + */ + + public CountResponse count(CountRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + CountRequest, + CountResponse, + ErrorResponse>) CountRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns number of documents matching a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link CountRequest} + * + */ + + public final CountResponse count(Function> fn) throws IOException, + OpenSearchException { + return count(fn.apply(new CountRequest.Builder()).build()); + } + + /** + * Returns number of documents matching a query. + * + * + */ + + public CountResponse count() throws IOException, OpenSearchException { + return this.transport.performRequest(new CountRequest.Builder().build(), CountRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: create + + /** + * Creates a new document in the index. + *

+ * Returns a 409 response when a document with a same ID already exists in the + * index. + * + * + */ + + public CreateResponse create(CreateRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, CreateResponse, ErrorResponse> endpoint = (JsonEndpoint< + CreateRequest, + CreateResponse, + ErrorResponse>) CreateRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Creates a new document in the index. + *

+ * Returns a 409 response when a document with a same ID already exists in the + * index. + * + * @param fn + * a function that initializes a builder to create the + * {@link CreateRequest} + * + */ + + public final CreateResponse create(Function, ObjectBuilder>> fn) + throws IOException, OpenSearchException { + return create(fn.apply(new CreateRequest.Builder()).build()); + } + + // ----- Endpoint: create_point_in_time + + /** + * Provides low-level information about the disk utilization of a PIT by + * describing its Lucene segments. + * + * + */ + + public CreatePitResponse createPit(CreatePitRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + CreatePitRequest, + CreatePitResponse, + ErrorResponse>) CreatePitRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Provides low-level information about the disk utilization of a PIT by + * describing its Lucene segments. + * + * @param fn + * a function that initializes a builder to create the + * {@link CreatePitRequest} + * + */ + + public final CreatePitResponse createPit(Function> fn) throws IOException, + OpenSearchException { + return createPit(fn.apply(new CreatePitRequest.Builder()).build()); + } + + // ----- Endpoint: delete + + /** + * Removes a document from the index. + * + * + */ + + public DeleteResponse delete(DeleteRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteRequest, + DeleteResponse, + ErrorResponse>) DeleteRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Removes a document from the index. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteRequest} + * + */ + + public final DeleteResponse delete(Function> fn) throws IOException, + OpenSearchException { + return delete(fn.apply(new DeleteRequest.Builder()).build()); + } + + // ----- Endpoint: delete_point_in_time + + /** + * Delete Point In Time + * + * + */ + + public DeletePitResponse deletePit(DeletePitRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeletePitRequest, + DeletePitResponse, + ErrorResponse>) DeletePitRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Delete Point In Time + * + * @param fn + * a function that initializes a builder to create the + * {@link DeletePitRequest} + * + */ + + public final DeletePitResponse deletePit(Function> fn) throws IOException, + OpenSearchException { + return deletePit(fn.apply(new DeletePitRequest.Builder()).build()); + } + + // ----- Endpoint: delete_by_query + + /** + * Deletes documents matching the provided query. + * + * + */ + + public DeleteByQueryResponse deleteByQuery(DeleteByQueryRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteByQueryRequest, + DeleteByQueryResponse, + ErrorResponse>) DeleteByQueryRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Deletes documents matching the provided query. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteByQueryRequest} + * + */ + + public final DeleteByQueryResponse deleteByQuery(Function> fn) + throws IOException, OpenSearchException { + return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build()); + } + + // ----- Endpoint: delete_by_query_rethrottle + + /** + * Changes the number of requests per second for a particular Delete By Query + * operation. + * + * + */ + + public DeleteByQueryRethrottleResponse deleteByQueryRethrottle(DeleteByQueryRethrottleRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteByQueryRethrottleRequest, + DeleteByQueryRethrottleResponse, + ErrorResponse>) DeleteByQueryRethrottleRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Delete By Query + * operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteByQueryRethrottleRequest} + * + */ + + public final DeleteByQueryRethrottleResponse deleteByQueryRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return deleteByQueryRethrottle(fn.apply(new DeleteByQueryRethrottleRequest.Builder()).build()); + } + + // ----- Endpoint: delete_script + + /** + * Deletes a script. + * + * + */ + + public DeleteScriptResponse deleteScript(DeleteScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + DeleteScriptRequest, + DeleteScriptResponse, + ErrorResponse>) DeleteScriptRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Deletes a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link DeleteScriptRequest} + * + */ + + public final DeleteScriptResponse deleteScript(Function> fn) + throws IOException, OpenSearchException { + return deleteScript(fn.apply(new DeleteScriptRequest.Builder()).build()); + } + + // ----- Endpoint: exists + + /** + * Returns information about whether a document exists in an index. + * + * + */ + + public BooleanResponse exists(ExistsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ExistsRequest, + BooleanResponse, + ErrorResponse>) ExistsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information about whether a document exists in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExistsRequest} + * + */ + + public final BooleanResponse exists(Function> fn) throws IOException, + OpenSearchException { + return exists(fn.apply(new ExistsRequest.Builder()).build()); + } + + // ----- Endpoint: exists_source + + /** + * Returns information about whether a document source exists in an index. + * + * + */ + + public BooleanResponse existsSource(ExistsSourceRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ExistsSourceRequest, + BooleanResponse, + ErrorResponse>) ExistsSourceRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information about whether a document source exists in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExistsSourceRequest} + * + */ + + public final BooleanResponse existsSource(Function> fn) + throws IOException, OpenSearchException { + return existsSource(fn.apply(new ExistsSourceRequest.Builder()).build()); + } + + // ----- Endpoint: explain + + /** + * Returns information about why a specific matches (or doesn't match) a query. + * + * + */ + + public ExplainResponse explain(ExplainRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ExplainRequest, + ExplainResponse, + ErrorResponse>) ExplainRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.explain.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information about why a specific matches (or doesn't match) a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link ExplainRequest} + * + */ + + public final ExplainResponse explain( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return explain(fn.apply(new ExplainRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: field_caps + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * + */ + + public FieldCapsResponse fieldCaps(FieldCapsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + FieldCapsRequest, + FieldCapsResponse, + ErrorResponse>) FieldCapsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * @param fn + * a function that initializes a builder to create the + * {@link FieldCapsRequest} + * + */ + + public final FieldCapsResponse fieldCaps(Function> fn) throws IOException, + OpenSearchException { + return fieldCaps(fn.apply(new FieldCapsRequest.Builder()).build()); + } + + /** + * Returns the information about the capabilities of fields among multiple + * indices. + * + * + */ + + public FieldCapsResponse fieldCaps() throws IOException, OpenSearchException { + return this.transport.performRequest(new FieldCapsRequest.Builder().build(), FieldCapsRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: get + + /** + * Returns a document. + * + * + */ + + public GetResponse get(GetRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + GetRequest, + GetResponse, + ErrorResponse>) GetRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.get.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns a document. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetRequest} + * + */ + + public final GetResponse get( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return get(fn.apply(new GetRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: get_script + + /** + * Returns a script. + * + * + */ + + public GetScriptResponse getScript(GetScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + GetScriptRequest, + GetScriptResponse, + ErrorResponse>) GetScriptRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetScriptRequest} + * + */ + + public final GetScriptResponse getScript(Function> fn) throws IOException, + OpenSearchException { + return getScript(fn.apply(new GetScriptRequest.Builder()).build()); + } + + // ----- Endpoint: get_script_context + + /** + * Returns all script contexts. + * + * + */ + public GetScriptContextResponse getScriptContext() throws IOException, OpenSearchException { + return this.transport.performRequest(GetScriptContextRequest._INSTANCE, GetScriptContextRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: get_script_languages + + /** + * Returns available script types, languages and contexts + * + * + */ + public GetScriptLanguagesResponse getScriptLanguages() throws IOException, OpenSearchException { + return this.transport.performRequest( + GetScriptLanguagesRequest._INSTANCE, + GetScriptLanguagesRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: get_source + + /** + * Returns the source of a document. + * + * + */ + + public GetSourceResponse getSource(GetSourceRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + GetSourceRequest, + GetSourceResponse, + ErrorResponse>) GetSourceRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.get_source.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns the source of a document. + * + * @param fn + * a function that initializes a builder to create the + * {@link GetSourceRequest} + * + */ + + public final GetSourceResponse getSource( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return getSource(fn.apply(new GetSourceRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: index + + /** + * Creates or updates a document in an index. + * + * + */ + + public IndexResponse index(IndexRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, IndexResponse, ErrorResponse> endpoint = (JsonEndpoint< + IndexRequest, + IndexResponse, + ErrorResponse>) IndexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Creates or updates a document in an index. + * + * @param fn + * a function that initializes a builder to create the + * {@link IndexRequest} + * + */ + + public final IndexResponse index(Function, ObjectBuilder>> fn) + throws IOException, OpenSearchException { + return index(fn.apply(new IndexRequest.Builder()).build()); + } + + // ----- Endpoint: info + + /** + * Returns basic information about the cluster. + * + * + */ + public InfoResponse info() throws IOException, OpenSearchException { + return this.transport.performRequest(InfoRequest._INSTANCE, InfoRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: list_point_in_time + + /** + * List all Point In Time + * + * + */ + + public ListAllPitResponse listAllPit() throws IOException, OpenSearchException { + return this.transport.performRequest(ListAllPitRequest._INSTANCE, ListAllPitRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: mget + + /** + * Allows to get multiple documents in one request. + * + * + */ + + public MgetResponse mget(MgetRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MgetRequest, + MgetResponse, + ErrorResponse>) MgetRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.mget.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to get multiple documents in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MgetRequest} + * + */ + + public final MgetResponse mget( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return mget(fn.apply(new MgetRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: msearch + + /** + * Allows to execute several search operations in one request. + * + * + */ + + public MsearchResponse msearch(MsearchRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MsearchRequest, + MsearchResponse, + ErrorResponse>) MsearchRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.msearch.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to execute several search operations in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MsearchRequest} + * + */ + + public final MsearchResponse msearch( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return msearch(fn.apply(new MsearchRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: msearch_template + + /** + * Allows to execute several search template operations in one request. + * + * + */ + + public MsearchTemplateResponse msearchTemplate(MsearchTemplateRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + MsearchTemplateRequest, + MsearchTemplateResponse, + ErrorResponse>) MsearchTemplateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.msearch_template.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to execute several search template operations in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MsearchTemplateRequest} + * + */ + + public final MsearchTemplateResponse msearchTemplate( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return msearchTemplate(fn.apply(new MsearchTemplateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: mtermvectors + + /** + * Returns multiple termvectors in one request. + * + * + */ + + public MtermvectorsResponse mtermvectors(MtermvectorsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + MtermvectorsRequest, + MtermvectorsResponse, + ErrorResponse>) MtermvectorsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns multiple termvectors in one request. + * + * @param fn + * a function that initializes a builder to create the + * {@link MtermvectorsRequest} + * + */ + + public final MtermvectorsResponse mtermvectors(Function> fn) + throws IOException, OpenSearchException { + return mtermvectors(fn.apply(new MtermvectorsRequest.Builder()).build()); + } + + /** + * Returns multiple termvectors in one request. + * + * + */ + + public MtermvectorsResponse mtermvectors() throws IOException, OpenSearchException { + return this.transport.performRequest( + new MtermvectorsRequest.Builder().build(), + MtermvectorsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: ping + + /** + * Returns whether the cluster is running. + * + * + */ + public BooleanResponse ping() throws IOException, OpenSearchException { + return this.transport.performRequest(PingRequest._INSTANCE, PingRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: put_script + + /** + * Creates or updates a script. + * + * + */ + + public PutScriptResponse putScript(PutScriptRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + PutScriptRequest, + PutScriptResponse, + ErrorResponse>) PutScriptRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Creates or updates a script. + * + * @param fn + * a function that initializes a builder to create the + * {@link PutScriptRequest} + * + */ + + public final PutScriptResponse putScript(Function> fn) throws IOException, + OpenSearchException { + return putScript(fn.apply(new PutScriptRequest.Builder()).build()); + } + + // ----- Endpoint: rank_eval + + /** + * Allows to evaluate the quality of ranked search results over a set of typical + * search queries + * + * + */ + + public RankEvalResponse rankEval(RankEvalRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + RankEvalRequest, + RankEvalResponse, + ErrorResponse>) RankEvalRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to evaluate the quality of ranked search results over a set of typical + * search queries + * + * @param fn + * a function that initializes a builder to create the + * {@link RankEvalRequest} + * + */ + + public final RankEvalResponse rankEval(Function> fn) throws IOException, + OpenSearchException { + return rankEval(fn.apply(new RankEvalRequest.Builder()).build()); + } + + // ----- Endpoint: reindex + + /** + * 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. + * + * + */ + + public ReindexResponse reindex(ReindexRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ReindexRequest, + ReindexResponse, + ErrorResponse>) ReindexRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * 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. + * + * @param fn + * a function that initializes a builder to create the + * {@link ReindexRequest} + * + */ + + public final ReindexResponse reindex(Function> fn) throws IOException, + OpenSearchException { + return reindex(fn.apply(new ReindexRequest.Builder()).build()); + } + + /** + * 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. + * + * + */ + + public ReindexResponse reindex() throws IOException, OpenSearchException { + return this.transport.performRequest(new ReindexRequest.Builder().build(), ReindexRequest._ENDPOINT, this.transportOptions); + } + + // ----- Endpoint: reindex_rethrottle + + /** + * Changes the number of requests per second for a particular Reindex operation. + * + * + */ + + public ReindexRethrottleResponse reindexRethrottle(ReindexRethrottleRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + ReindexRethrottleRequest, + ReindexRethrottleResponse, + ErrorResponse>) ReindexRethrottleRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Reindex operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link ReindexRethrottleRequest} + * + */ + + public final ReindexRethrottleResponse reindexRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return reindexRethrottle(fn.apply(new ReindexRethrottleRequest.Builder()).build()); + } + + // ----- Endpoint: render_search_template + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public RenderSearchTemplateResponse renderSearchTemplate(RenderSearchTemplateRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + RenderSearchTemplateRequest, + RenderSearchTemplateResponse, + ErrorResponse>) RenderSearchTemplateRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * @param fn + * a function that initializes a builder to create the + * {@link RenderSearchTemplateRequest} + * + */ + + public final RenderSearchTemplateResponse renderSearchTemplate( + Function> fn + ) throws IOException, OpenSearchException { + return renderSearchTemplate(fn.apply(new RenderSearchTemplateRequest.Builder()).build()); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public RenderSearchTemplateResponse renderSearchTemplate() throws IOException, OpenSearchException { + return this.transport.performRequest( + new RenderSearchTemplateRequest.Builder().build(), + RenderSearchTemplateRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: scripts_painless_execute + + /** + * Allows an arbitrary script to be executed and a result to be returned + * + * + */ + + public ScriptsPainlessExecuteResponse scriptsPainlessExecute( + ScriptsPainlessExecuteRequest request, + Class tResultClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ScriptsPainlessExecuteRequest, + ScriptsPainlessExecuteResponse, + ErrorResponse>) ScriptsPainlessExecuteRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.scripts_painless_execute.TResult", + getDeserializer(tResultClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows an arbitrary script to be executed and a result to be returned + * + * @param fn + * a function that initializes a builder to create the + * {@link ScriptsPainlessExecuteRequest} + * + */ + + public final ScriptsPainlessExecuteResponse scriptsPainlessExecute( + Function> fn, + Class tResultClass + ) throws IOException, OpenSearchException { + return scriptsPainlessExecute(fn.apply(new ScriptsPainlessExecuteRequest.Builder()).build(), tResultClass); + } + + // ----- Endpoint: scroll + + /** + * Allows to retrieve a large numbers of results from a single search request. + * + */ + + public ScrollResponse scroll(ScrollRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + ScrollRequest, + ScrollResponse, + ErrorResponse>) ScrollRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.scroll.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to retrieve a large numbers of results from a single search request. + * + * @param fn + * a function that initializes a builder to create the + * {@link ScrollRequest} + */ + + public final ScrollResponse scroll( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return scroll(fn.apply(new ScrollRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: search + + /** + * Returns results matching a query. + * + * + */ + + public SearchResponse search(SearchRequest request, Class tDocumentClass) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + SearchRequest, + SearchResponse, + ErrorResponse>) SearchRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.search.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns results matching a query. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchRequest} + * + */ + + public final SearchResponse search( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return search(fn.apply(new SearchRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: search_shards + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * + */ + + public SearchShardsResponse searchShards(SearchShardsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + SearchShardsRequest, + SearchShardsResponse, + ErrorResponse>) SearchShardsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchShardsRequest} + * + */ + + public final SearchShardsResponse searchShards(Function> fn) + throws IOException, OpenSearchException { + return searchShards(fn.apply(new SearchShardsRequest.Builder()).build()); + } + + /** + * Returns information about the indices and shards that a search request would + * be executed against. + * + * + */ + + public SearchShardsResponse searchShards() throws IOException, OpenSearchException { + return this.transport.performRequest( + new SearchShardsRequest.Builder().build(), + SearchShardsRequest._ENDPOINT, + this.transportOptions + ); + } + + // ----- Endpoint: search_template + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * + */ + + public SearchTemplateResponse searchTemplate(SearchTemplateRequest request, Class tDocumentClass) + throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, ErrorResponse> endpoint = (JsonEndpoint< + SearchTemplateRequest, + SearchTemplateResponse, + ErrorResponse>) SearchTemplateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.search_template.TDocument", + getDeserializer(tDocumentClass) + ); + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Allows to use the Mustache language to pre-render a search definition. + * + * @param fn + * a function that initializes a builder to create the + * {@link SearchTemplateRequest} + * + */ + + public final SearchTemplateResponse searchTemplate( + Function> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: terms_enum + + /** + * 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. + * + * + */ + + public TermsEnumResponse termsEnum(TermsEnumRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + TermsEnumRequest, + TermsEnumResponse, + ErrorResponse>) TermsEnumRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * 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. + * + * @param fn + * a function that initializes a builder to create the + * {@link TermsEnumRequest} + * + */ + + public final TermsEnumResponse termsEnum(Function> fn) throws IOException, + OpenSearchException { + return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); + } + + // ----- Endpoint: termvectors + + /** + * Returns information and statistics about terms in the fields of a particular + * document. + * + * + */ + + public TermvectorsResponse termvectors(TermvectorsRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, TermvectorsResponse, ErrorResponse> endpoint = (JsonEndpoint< + TermvectorsRequest, + TermvectorsResponse, + ErrorResponse>) TermvectorsRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Returns information and statistics about terms in the fields of a particular + * document. + * + * @param fn + * a function that initializes a builder to create the + * {@link TermvectorsRequest} + * + */ + + public final TermvectorsResponse termvectors( + Function, ObjectBuilder>> fn + ) throws IOException, OpenSearchException { + return termvectors(fn.apply(new TermvectorsRequest.Builder()).build()); + } + + // ----- Endpoint: update + + /** + * Updates a document with a script or partial document. + * + * + */ + + public UpdateResponse update( + UpdateRequest request, + Class tDocumentClass + ) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint, UpdateResponse, ErrorResponse> endpoint = (JsonEndpoint< + UpdateRequest, + UpdateResponse, + ErrorResponse>) UpdateRequest._ENDPOINT; + endpoint = new EndpointWithResponseMapperAttr<>( + endpoint, + "org.opensearch.client:Deserializer:_global.update.TDocument", + getDeserializer(tDocumentClass) + ); + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Updates a document with a script or partial document. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateRequest} + * + */ + + public final UpdateResponse update( + + Function, ObjectBuilder>> fn, + Class tDocumentClass + ) throws IOException, OpenSearchException { + return update(fn.apply(new UpdateRequest.Builder()).build(), tDocumentClass); + } + + // ----- Endpoint: update_by_query + + /** + * Performs an update on every document in the index without changing the + * source, for example to pick up a mapping change. + * + * + */ + + public UpdateByQueryResponse updateByQuery(UpdateByQueryRequest request) throws IOException, OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + UpdateByQueryRequest, + UpdateByQueryResponse, + ErrorResponse>) UpdateByQueryRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Performs an update on every document in the index without changing the + * source, for example to pick up a mapping change. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateByQueryRequest} + * + */ + + public final UpdateByQueryResponse updateByQuery(Function> fn) + throws IOException, OpenSearchException { + return updateByQuery(fn.apply(new UpdateByQueryRequest.Builder()).build()); + } + + // ----- Endpoint: update_by_query_rethrottle + + /** + * Changes the number of requests per second for a particular Update By Query + * operation. + * + * + */ + + public UpdateByQueryRethrottleResponse updateByQueryRethrottle(UpdateByQueryRethrottleRequest request) throws IOException, + OpenSearchException { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint = (JsonEndpoint< + UpdateByQueryRethrottleRequest, + UpdateByQueryRethrottleResponse, + ErrorResponse>) UpdateByQueryRethrottleRequest._ENDPOINT; + + return this.transport.performRequest(request, endpoint, this.transportOptions); + } + + /** + * Changes the number of requests per second for a particular Update By Query + * operation. + * + * @param fn + * a function that initializes a builder to create the + * {@link UpdateByQueryRethrottleRequest} + * + */ + + public final UpdateByQueryRethrottleResponse updateByQueryRethrottle( + Function> fn + ) throws IOException, OpenSearchException { + return updateByQueryRethrottle(fn.apply(new UpdateByQueryRethrottleRequest.Builder()).build()); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java index bd96f62932..96afe7515c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/AcknowledgedResponseBase.java @@ -30,86 +30,80 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; // typedef: _types.AcknowledgedResponseBase - public abstract class AcknowledgedResponseBase implements JsonpSerializable { - private final boolean acknowledged; + private final boolean acknowledged; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - protected AcknowledgedResponseBase(AbstractBuilder builder) { + protected AcknowledgedResponseBase(AbstractBuilder builder) { - this.acknowledged = ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged"); + this.acknowledged = ApiTypeHelper.requireNonNull(builder.acknowledged, this, "acknowledged"); - } + } - /** - * Required - For a successful response, this value is always true. On failure, - * an exception is returned instead. - *

- * API name: {@code acknowledged} - */ - public final boolean acknowledged() { - return this.acknowledged; - } + /** + * Required - For a successful response, this value is always true. On failure, + * an exception is returned instead. + *

+ * API name: {@code acknowledged} + */ + public final boolean acknowledged() { + return this.acknowledged; + } - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("acknowledged"); - generator.write(this.acknowledged); + generator.writeKey("acknowledged"); + generator.write(this.acknowledged); - } + } - protected abstract static class AbstractBuilder> - extends - ObjectBuilderBase { - private Boolean acknowledged; + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { + private Boolean acknowledged; - /** - * Required - For a successful response, this value is always true. On failure, - * an exception is returned instead. - *

- * API name: {@code acknowledged} - */ - public final BuilderT acknowledged(boolean value) { - this.acknowledged = value; - return self(); - } + /** + * Required - For a successful response, this value is always true. On failure, + * an exception is returned instead. + *

+ * API name: {@code acknowledged} + */ + public final BuilderT acknowledged(boolean value) { + this.acknowledged = value; + return self(); + } - protected abstract BuilderT self(); + protected abstract BuilderT self(); - } + } - // --------------------------------------------------------------------------------------------- - protected static > void setupAcknowledgedResponseBaseDeserializer( - ObjectDeserializer op) { + // --------------------------------------------------------------------------------------------- + protected static > void setupAcknowledgedResponseBaseDeserializer( + ObjectDeserializer op + ) { - op.add(AbstractBuilder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); + op.add(AbstractBuilder::acknowledged, JsonpDeserializer.booleanDeserializer(), "acknowledged"); - } + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/BaseNode.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/BaseNode.java index ccf876ba38..abd2b4204e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/BaseNode.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/BaseNode.java @@ -30,243 +30,239 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; // typedef: _spec_utils.BaseNode - public abstract class BaseNode implements JsonpSerializable { - private final Map attributes; - - private final String host; - - private final String ip; - - private final String name; - - private final List roles; - - private final String transportAddress; - - // --------------------------------------------------------------------------------------------- - - protected BaseNode(AbstractBuilder builder) { - - this.attributes = ApiTypeHelper.unmodifiableRequired(builder.attributes, this, "attributes"); - this.host = ApiTypeHelper.requireNonNull(builder.host, this, "host"); - this.ip = ApiTypeHelper.requireNonNull(builder.ip, this, "ip"); - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); - this.roles = ApiTypeHelper.unmodifiable(builder.roles); - this.transportAddress = ApiTypeHelper.requireNonNull(builder.transportAddress, this, "transportAddress"); - - } - - /** - * Required - API name: {@code attributes} - */ - public final Map attributes() { - return this.attributes; - } - - /** - * Required - API name: {@code host} - */ - public final String host() { - return this.host; - } - - /** - * Required - API name: {@code ip} - */ - public final String ip() { - return this.ip; - } - - /** - * Required - API name: {@code name} - */ - public final String name() { - return this.name; - } - - /** - * API name: {@code roles} - */ - public final List roles() { - return this.roles; - } - - /** - * Required - API name: {@code transport_address} - */ - public final String transportAddress() { - return this.transportAddress; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.attributes)) { - generator.writeKey("attributes"); - generator.writeStartObject(); - for (Map.Entry item0 : this.attributes.entrySet()) { - generator.writeKey(item0.getKey()); - generator.write(item0.getValue()); - - } - generator.writeEnd(); - - } - generator.writeKey("host"); - generator.write(this.host); - - generator.writeKey("ip"); - generator.write(this.ip); - - generator.writeKey("name"); - generator.write(this.name); - - if (ApiTypeHelper.isDefined(this.roles)) { - generator.writeKey("roles"); - generator.writeStartArray(); - for (NodeRole item0 : this.roles) { - item0.serialize(generator, mapper); - } - generator.writeEnd(); - - } - generator.writeKey("transport_address"); - generator.write(this.transportAddress); - - } - - protected abstract static class AbstractBuilder> - extends - ObjectBuilderBase { - private Map attributes; - - private String host; - - private String ip; - - private String name; - - @Nullable - private List roles; - - private String transportAddress; - - /** - * Required - API name: {@code attributes} - *

- * Adds all entries of map to attributes. - */ - public final BuilderT attributes(Map map) { - this.attributes = _mapPutAll(this.attributes, map); - return self(); - } - - /** - * Required - API name: {@code attributes} - *

- * Adds an entry to attributes. - */ - public final BuilderT attributes(String key, String value) { - this.attributes = _mapPut(this.attributes, key, value); - return self(); - } - - /** - * Required - API name: {@code host} - */ - public final BuilderT host(String value) { - this.host = value; - return self(); - } - - /** - * Required - API name: {@code ip} - */ - public final BuilderT ip(String value) { - this.ip = value; - return self(); - } - - /** - * Required - API name: {@code name} - */ - public final BuilderT name(String value) { - this.name = value; - return self(); - } - - /** - * API name: {@code roles} - *

- * Adds all elements of list to roles. - */ - public final BuilderT roles(List list) { - this.roles = _listAddAll(this.roles, list); - return self(); - } - - /** - * API name: {@code roles} - *

- * Adds one or more values to roles. - */ - public final BuilderT roles(NodeRole value, NodeRole... values) { - this.roles = _listAdd(this.roles, value, values); - return self(); - } - - /** - * Required - API name: {@code transport_address} - */ - public final BuilderT transportAddress(String value) { - this.transportAddress = value; - return self(); - } - - protected abstract BuilderT self(); - - } - - // --------------------------------------------------------------------------------------------- - protected static > void setupBaseNodeDeserializer( - ObjectDeserializer op) { - - op.add(AbstractBuilder::attributes, - JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "attributes"); - op.add(AbstractBuilder::host, JsonpDeserializer.stringDeserializer(), "host"); - op.add(AbstractBuilder::ip, JsonpDeserializer.stringDeserializer(), "ip"); - op.add(AbstractBuilder::name, JsonpDeserializer.stringDeserializer(), "name"); - op.add(AbstractBuilder::roles, JsonpDeserializer.arrayDeserializer(NodeRole._DESERIALIZER), "roles"); - op.add(AbstractBuilder::transportAddress, JsonpDeserializer.stringDeserializer(), "transport_address"); - - } + private final Map attributes; + + private final String host; + + private final String ip; + + private final String name; + + private final List roles; + + private final String transportAddress; + + // --------------------------------------------------------------------------------------------- + + protected BaseNode(AbstractBuilder builder) { + + this.attributes = ApiTypeHelper.unmodifiable(builder.attributes); + this.host = builder.host; + this.ip = builder.ip; + this.name = builder.name; + this.roles = ApiTypeHelper.unmodifiable(builder.roles); + this.transportAddress = builder.transportAddress; + + } + + /** + * API name: {@code attributes} + */ + public final Map attributes() { + return this.attributes; + } + + /** + * API name: {@code host} + */ + public final String host() { + return this.host; + } + + /** + * API name: {@code ip} + */ + public final String ip() { + return this.ip; + } + + /** + * API name: {@code name} + */ + public final String name() { + return this.name; + } + + /** + * API name: {@code roles} + */ + public final List roles() { + return this.roles; + } + + /** + * API name: {@code transport_address} + */ + public final String transportAddress() { + return this.transportAddress; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (ApiTypeHelper.isDefined(this.attributes)) { + generator.writeKey("attributes"); + generator.writeStartObject(); + for (Map.Entry item0 : this.attributes.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + + } + generator.writeKey("host"); + generator.write(this.host); + + generator.writeKey("ip"); + generator.write(this.ip); + + generator.writeKey("name"); + generator.write(this.name); + + if (ApiTypeHelper.isDefined(this.roles)) { + generator.writeKey("roles"); + generator.writeStartArray(); + for (NodeRole item0 : this.roles) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + + } + generator.writeKey("transport_address"); + generator.write(this.transportAddress); + + } + + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { + @Nullable + private Map attributes; + + @Nullable + private String host; + + @Nullable + private String ip; + + @Nullable + private String name; + + @Nullable + private List roles; + + @Nullable + private String transportAddress; + + /** + * API name: {@code attributes} + *

+ * Adds all entries of map to attributes. + */ + public final BuilderT attributes(Map map) { + this.attributes = _mapPutAll(this.attributes, map); + return self(); + } + + /** + * API name: {@code attributes} + *

+ * Adds an entry to attributes. + */ + public final BuilderT attributes(String key, String value) { + this.attributes = _mapPut(this.attributes, key, value); + return self(); + } + + /** + * API name: {@code host} + */ + public final BuilderT host(String value) { + this.host = value; + return self(); + } + + /** + * API name: {@code ip} + */ + public final BuilderT ip(String value) { + this.ip = value; + return self(); + } + + /** + * API name: {@code name} + */ + public final BuilderT name(String value) { + this.name = value; + return self(); + } + + /** + * API name: {@code roles} + *

+ * Adds all elements of list to roles. + */ + public final BuilderT roles(List list) { + this.roles = _listAddAll(this.roles, list); + return self(); + } + + /** + * API name: {@code roles} + *

+ * Adds one or more values to roles. + */ + public final BuilderT roles(NodeRole value, NodeRole... values) { + this.roles = _listAdd(this.roles, value, values); + return self(); + } + + /** + * API name: {@code transport_address} + */ + public final BuilderT transportAddress(String value) { + this.transportAddress = value; + return self(); + } + + protected abstract BuilderT self(); + + } + + // --------------------------------------------------------------------------------------------- + protected static > void setupBaseNodeDeserializer(ObjectDeserializer op) { + + op.add(AbstractBuilder::attributes, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "attributes"); + op.add(AbstractBuilder::host, JsonpDeserializer.stringDeserializer(), "host"); + op.add(AbstractBuilder::ip, JsonpDeserializer.stringDeserializer(), "ip"); + op.add(AbstractBuilder::name, JsonpDeserializer.stringDeserializer(), "name"); + op.add(AbstractBuilder::roles, JsonpDeserializer.arrayDeserializer(NodeRole._DESERIALIZER), "roles"); + op.add(AbstractBuilder::transportAddress, JsonpDeserializer.stringDeserializer(), "transport_address"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/BulkIndexByScrollFailure.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/BulkIndexByScrollFailure.java index 3b0844005f..4718d336ab 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/BulkIndexByScrollFailure.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/BulkIndexByScrollFailure.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,196 +43,195 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.BulkIndexByScrollFailure @JsonpDeserializable public class BulkIndexByScrollFailure implements JsonpSerializable { - private final ErrorCause cause; + private final ErrorCause cause; - private final String id; + private final String id; - private final String index; + private final String index; - private final int status; + private final int status; - private final String type; + private final String type; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - private BulkIndexByScrollFailure(Builder builder) { + private BulkIndexByScrollFailure(Builder builder) { - this.cause = ApiTypeHelper.requireNonNull(builder.cause, this, "cause"); - this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.cause = ApiTypeHelper.requireNonNull(builder.cause, this, "cause"); + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); + this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - } + } - public static BulkIndexByScrollFailure of(Function> fn) { - return fn.apply(new Builder()).build(); - } + public static BulkIndexByScrollFailure of(Function> fn) { + return fn.apply(new Builder()).build(); + } - /** - * Required - API name: {@code cause} - */ - public final ErrorCause cause() { - return this.cause; - } + /** + * Required - API name: {@code cause} + */ + public final ErrorCause cause() { + return this.cause; + } - /** - * Required - API name: {@code id} - */ - public final String id() { - return this.id; - } - - /** - * Required - API name: {@code index} - */ - public final String index() { - return this.index; - } - - /** - * Required - API name: {@code status} - */ - public final int status() { - return this.status; - } - - /** - * Required - API name: {@code type} - */ - public final String type() { - return this.type; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("cause"); - this.cause.serialize(generator, mapper); - - generator.writeKey("id"); - generator.write(this.id); - - generator.writeKey("index"); - generator.write(this.index); - - generator.writeKey("status"); - generator.write(this.status); - - generator.writeKey("type"); - generator.write(this.type); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link BulkIndexByScrollFailure}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private ErrorCause cause; - - private String id; - - private String index; - - private Integer status; - - private String type; - - /** - * Required - API name: {@code cause} - */ - public final Builder cause(ErrorCause value) { - this.cause = value; - return this; - } - - /** - * Required - API name: {@code cause} - */ - public final Builder cause(Function> fn) { - return this.cause(fn.apply(new ErrorCause.Builder()).build()); - } - - /** - * Required - API name: {@code id} - */ - public final Builder id(String value) { - this.id = value; - return this; - } - - /** - * Required - API name: {@code index} - */ - public final Builder index(String value) { - this.index = value; - return this; - } - - /** - * Required - API name: {@code status} - */ - public final Builder status(int value) { - this.status = value; - return this; - } - - /** - * Required - API name: {@code type} - */ - public final Builder type(String value) { - this.type = value; - return this; - } - - /** - * Builds a {@link BulkIndexByScrollFailure}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public BulkIndexByScrollFailure build() { - _checkSingleUse(); - - return new BulkIndexByScrollFailure(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link BulkIndexByScrollFailure} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, BulkIndexByScrollFailure::setupBulkIndexByScrollFailureDeserializer); - - protected static void setupBulkIndexByScrollFailureDeserializer( - ObjectDeserializer op) { - - op.add(Builder::cause, ErrorCause._DESERIALIZER, "cause"); - op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); - op.add(Builder::status, JsonpDeserializer.integerDeserializer(), "status"); - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - - } + /** + * Required - API name: {@code id} + */ + public final String id() { + return this.id; + } + + /** + * Required - API name: {@code index} + */ + public final String index() { + return this.index; + } + + /** + * Required - API name: {@code status} + */ + public final int status() { + return this.status; + } + + /** + * Required - API name: {@code type} + */ + public final String type() { + return this.type; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("cause"); + this.cause.serialize(generator, mapper); + + generator.writeKey("id"); + generator.write(this.id); + + generator.writeKey("index"); + generator.write(this.index); + + generator.writeKey("status"); + generator.write(this.status); + + generator.writeKey("type"); + generator.write(this.type); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link BulkIndexByScrollFailure}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private ErrorCause cause; + + private String id; + + private String index; + + private Integer status; + + private String type; + + /** + * Required - API name: {@code cause} + */ + public final Builder cause(ErrorCause value) { + this.cause = value; + return this; + } + + /** + * Required - API name: {@code cause} + */ + public final Builder cause(Function> fn) { + return this.cause(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * Required - API name: {@code id} + */ + public final Builder id(String value) { + this.id = value; + return this; + } + + /** + * Required - API name: {@code index} + */ + public final Builder index(String value) { + this.index = value; + return this; + } + + /** + * Required - API name: {@code status} + */ + public final Builder status(int value) { + this.status = value; + return this; + } + + /** + * Required - API name: {@code type} + */ + public final Builder type(String value) { + this.type = value; + return this; + } + + /** + * Builds a {@link BulkIndexByScrollFailure}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public BulkIndexByScrollFailure build() { + _checkSingleUse(); + + return new BulkIndexByScrollFailure(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link BulkIndexByScrollFailure} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + BulkIndexByScrollFailure::setupBulkIndexByScrollFailureDeserializer + ); + + protected static void setupBulkIndexByScrollFailureDeserializer(ObjectDeserializer op) { + + op.add(Builder::cause, ErrorCause._DESERIALIZER, "cause"); + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); + op.add(Builder::status, JsonpDeserializer.integerDeserializer(), "status"); + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/BulkStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/BulkStats.java index 5e3fb0d913..ab174f1dcf 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/BulkStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/BulkStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,306 +44,304 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; - -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.BulkStats @JsonpDeserializable public class BulkStats implements JsonpSerializable { - private final long totalOperations; - - @Nullable - private final String totalTime; - - private final long totalTimeInMillis; - - @Nullable - private final String totalSize; - - private final long totalSizeInBytes; - - @Nullable - private final String avgTime; - - private final long avgTimeInMillis; - - @Nullable - private final String avgSize; - - private final long avgSizeInBytes; - - // --------------------------------------------------------------------------------------------- - - private BulkStats(Builder builder) { - - this.totalOperations = ApiTypeHelper.requireNonNull(builder.totalOperations, this, "totalOperations"); - this.totalTime = builder.totalTime; - this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); - this.totalSize = builder.totalSize; - this.totalSizeInBytes = ApiTypeHelper.requireNonNull(builder.totalSizeInBytes, this, "totalSizeInBytes"); - this.avgTime = builder.avgTime; - this.avgTimeInMillis = ApiTypeHelper.requireNonNull(builder.avgTimeInMillis, this, "avgTimeInMillis"); - this.avgSize = builder.avgSize; - this.avgSizeInBytes = ApiTypeHelper.requireNonNull(builder.avgSizeInBytes, this, "avgSizeInBytes"); - - } - - public static BulkStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code total_operations} - */ - public final long totalOperations() { - return this.totalOperations; - } - - /** - * API name: {@code total_time} - */ - @Nullable - public final String totalTime() { - return this.totalTime; - } - - /** - * Required - API name: {@code total_time_in_millis} - */ - public final long totalTimeInMillis() { - return this.totalTimeInMillis; - } - - /** - * API name: {@code total_size} - */ - @Nullable - public final String totalSize() { - return this.totalSize; - } - - /** - * Required - API name: {@code total_size_in_bytes} - */ - public final long totalSizeInBytes() { - return this.totalSizeInBytes; - } - - /** - * API name: {@code avg_time} - */ - @Nullable - public final String avgTime() { - return this.avgTime; - } + private final long totalOperations; + + @Nullable + private final String totalTime; + + private final long totalTimeInMillis; + + @Nullable + private final String totalSize; + + private final long totalSizeInBytes; + + @Nullable + private final String avgTime; + + private final long avgTimeInMillis; + + @Nullable + private final String avgSize; + + private final long avgSizeInBytes; + + // --------------------------------------------------------------------------------------------- + + private BulkStats(Builder builder) { + + this.totalOperations = ApiTypeHelper.requireNonNull(builder.totalOperations, this, "totalOperations"); + this.totalTime = builder.totalTime; + this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); + this.totalSize = builder.totalSize; + this.totalSizeInBytes = ApiTypeHelper.requireNonNull(builder.totalSizeInBytes, this, "totalSizeInBytes"); + this.avgTime = builder.avgTime; + this.avgTimeInMillis = ApiTypeHelper.requireNonNull(builder.avgTimeInMillis, this, "avgTimeInMillis"); + this.avgSize = builder.avgSize; + this.avgSizeInBytes = ApiTypeHelper.requireNonNull(builder.avgSizeInBytes, this, "avgSizeInBytes"); + + } + + public static BulkStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code total_operations} + */ + public final long totalOperations() { + return this.totalOperations; + } + + /** + * API name: {@code total_time} + */ + @Nullable + public final String totalTime() { + return this.totalTime; + } + + /** + * Required - API name: {@code total_time_in_millis} + */ + public final long totalTimeInMillis() { + return this.totalTimeInMillis; + } + + /** + * API name: {@code total_size} + */ + @Nullable + public final String totalSize() { + return this.totalSize; + } + + /** + * Required - API name: {@code total_size_in_bytes} + */ + public final long totalSizeInBytes() { + return this.totalSizeInBytes; + } + + /** + * API name: {@code avg_time} + */ + @Nullable + public final String avgTime() { + return this.avgTime; + } - /** - * Required - API name: {@code avg_time_in_millis} - */ - public final long avgTimeInMillis() { - return this.avgTimeInMillis; - } - - /** - * API name: {@code avg_size} - */ - @Nullable - public final String avgSize() { - return this.avgSize; - } - - /** - * Required - API name: {@code avg_size_in_bytes} - */ - public final long avgSizeInBytes() { - return this.avgSizeInBytes; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("total_operations"); - generator.write(this.totalOperations); - - if (this.totalTime != null) { - generator.writeKey("total_time"); - generator.write(this.totalTime); - - } - generator.writeKey("total_time_in_millis"); - generator.write(this.totalTimeInMillis); - - if (this.totalSize != null) { - generator.writeKey("total_size"); - generator.write(this.totalSize); - - } - generator.writeKey("total_size_in_bytes"); - generator.write(this.totalSizeInBytes); - - if (this.avgTime != null) { - generator.writeKey("avg_time"); - generator.write(this.avgTime); - - } - generator.writeKey("avg_time_in_millis"); - generator.write(this.avgTimeInMillis); - - if (this.avgSize != null) { - generator.writeKey("avg_size"); - generator.write(this.avgSize); - - } - generator.writeKey("avg_size_in_bytes"); - generator.write(this.avgSizeInBytes); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link BulkStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long totalOperations; - - @Nullable - private String totalTime; - - private Long totalTimeInMillis; - - @Nullable - private String totalSize; - - private Long totalSizeInBytes; - - @Nullable - private String avgTime; - - private Long avgTimeInMillis; - - @Nullable - private String avgSize; - - private Long avgSizeInBytes; - - /** - * Required - API name: {@code total_operations} - */ - public final Builder totalOperations(long value) { - this.totalOperations = value; - return this; - } - - /** - * API name: {@code total_time} - */ - public final Builder totalTime(@Nullable String value) { - this.totalTime = value; - return this; - } - - /** - * Required - API name: {@code total_time_in_millis} - */ - public final Builder totalTimeInMillis(long value) { - this.totalTimeInMillis = value; - return this; - } - - /** - * API name: {@code total_size} - */ - public final Builder totalSize(@Nullable String value) { - this.totalSize = value; - return this; - } - - /** - * Required - API name: {@code total_size_in_bytes} - */ - public final Builder totalSizeInBytes(long value) { - this.totalSizeInBytes = value; - return this; - } - - /** - * API name: {@code avg_time} - */ - public final Builder avgTime(@Nullable String value) { - this.avgTime = value; - return this; - } - - /** - * Required - API name: {@code avg_time_in_millis} - */ - public final Builder avgTimeInMillis(long value) { - this.avgTimeInMillis = value; - return this; - } - - /** - * API name: {@code avg_size} - */ - public final Builder avgSize(@Nullable String value) { - this.avgSize = value; - return this; - } - - /** - * Required - API name: {@code avg_size_in_bytes} - */ - public final Builder avgSizeInBytes(long value) { - this.avgSizeInBytes = value; - return this; - } - - /** - * Builds a {@link BulkStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public BulkStats build() { - _checkSingleUse(); - - return new BulkStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link BulkStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - BulkStats::setupBulkStatsDeserializer); - - protected static void setupBulkStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::totalOperations, JsonpDeserializer.longDeserializer(), "total_operations"); - op.add(Builder::totalTime, JsonpDeserializer.stringDeserializer(), "total_time"); - op.add(Builder::totalTimeInMillis, JsonpDeserializer.longDeserializer(), "total_time_in_millis"); - op.add(Builder::totalSize, JsonpDeserializer.stringDeserializer(), "total_size"); - op.add(Builder::totalSizeInBytes, JsonpDeserializer.longDeserializer(), "total_size_in_bytes"); - op.add(Builder::avgTime, JsonpDeserializer.stringDeserializer(), "avg_time"); - op.add(Builder::avgTimeInMillis, JsonpDeserializer.longDeserializer(), "avg_time_in_millis"); - op.add(Builder::avgSize, JsonpDeserializer.stringDeserializer(), "avg_size"); - op.add(Builder::avgSizeInBytes, JsonpDeserializer.longDeserializer(), "avg_size_in_bytes"); - - } + /** + * Required - API name: {@code avg_time_in_millis} + */ + public final long avgTimeInMillis() { + return this.avgTimeInMillis; + } + + /** + * API name: {@code avg_size} + */ + @Nullable + public final String avgSize() { + return this.avgSize; + } + + /** + * Required - API name: {@code avg_size_in_bytes} + */ + public final long avgSizeInBytes() { + return this.avgSizeInBytes; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("total_operations"); + generator.write(this.totalOperations); + + if (this.totalTime != null) { + generator.writeKey("total_time"); + generator.write(this.totalTime); + + } + generator.writeKey("total_time_in_millis"); + generator.write(this.totalTimeInMillis); + + if (this.totalSize != null) { + generator.writeKey("total_size"); + generator.write(this.totalSize); + + } + generator.writeKey("total_size_in_bytes"); + generator.write(this.totalSizeInBytes); + + if (this.avgTime != null) { + generator.writeKey("avg_time"); + generator.write(this.avgTime); + + } + generator.writeKey("avg_time_in_millis"); + generator.write(this.avgTimeInMillis); + + if (this.avgSize != null) { + generator.writeKey("avg_size"); + generator.write(this.avgSize); + + } + generator.writeKey("avg_size_in_bytes"); + generator.write(this.avgSizeInBytes); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link BulkStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long totalOperations; + + @Nullable + private String totalTime; + + private Long totalTimeInMillis; + + @Nullable + private String totalSize; + + private Long totalSizeInBytes; + + @Nullable + private String avgTime; + + private Long avgTimeInMillis; + + @Nullable + private String avgSize; + + private Long avgSizeInBytes; + + /** + * Required - API name: {@code total_operations} + */ + public final Builder totalOperations(long value) { + this.totalOperations = value; + return this; + } + + /** + * API name: {@code total_time} + */ + public final Builder totalTime(@Nullable String value) { + this.totalTime = value; + return this; + } + + /** + * Required - API name: {@code total_time_in_millis} + */ + public final Builder totalTimeInMillis(long value) { + this.totalTimeInMillis = value; + return this; + } + + /** + * API name: {@code total_size} + */ + public final Builder totalSize(@Nullable String value) { + this.totalSize = value; + return this; + } + + /** + * Required - API name: {@code total_size_in_bytes} + */ + public final Builder totalSizeInBytes(long value) { + this.totalSizeInBytes = value; + return this; + } + + /** + * API name: {@code avg_time} + */ + public final Builder avgTime(@Nullable String value) { + this.avgTime = value; + return this; + } + + /** + * Required - API name: {@code avg_time_in_millis} + */ + public final Builder avgTimeInMillis(long value) { + this.avgTimeInMillis = value; + return this; + } + + /** + * API name: {@code avg_size} + */ + public final Builder avgSize(@Nullable String value) { + this.avgSize = value; + return this; + } + + /** + * Required - API name: {@code avg_size_in_bytes} + */ + public final Builder avgSizeInBytes(long value) { + this.avgSizeInBytes = value; + return this; + } + + /** + * Builds a {@link BulkStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public BulkStats build() { + _checkSingleUse(); + + return new BulkStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link BulkStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + BulkStats::setupBulkStatsDeserializer + ); + + protected static void setupBulkStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::totalOperations, JsonpDeserializer.longDeserializer(), "total_operations"); + op.add(Builder::totalTime, JsonpDeserializer.stringDeserializer(), "total_time"); + op.add(Builder::totalTimeInMillis, JsonpDeserializer.longDeserializer(), "total_time_in_millis"); + op.add(Builder::totalSize, JsonpDeserializer.stringDeserializer(), "total_size"); + op.add(Builder::totalSizeInBytes, JsonpDeserializer.longDeserializer(), "total_size_in_bytes"); + op.add(Builder::avgTime, JsonpDeserializer.stringDeserializer(), "avg_time"); + op.add(Builder::avgTimeInMillis, JsonpDeserializer.longDeserializer(), "avg_time_in_millis"); + op.add(Builder::avgSize, JsonpDeserializer.stringDeserializer(), "avg_size"); + op.add(Builder::avgSizeInBytes, JsonpDeserializer.longDeserializer(), "avg_size_in_bytes"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Bytes.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Bytes.java index bb8301df89..0d6077e653 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Bytes.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Bytes.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,29 +37,29 @@ @JsonpDeserializable public enum Bytes implements JsonEnum { - Bytes("b"), + Bytes("b"), - KiloBytes("kb"), + KiloBytes("kb"), - MegaBytes("mb"), + MegaBytes("mb"), - GigaBytes("gb"), + GigaBytes("gb"), - TeraBytes("tb"), + TeraBytes("tb"), - PetaBytes("pb"), + PetaBytes("pb"), - ; + ; - private final String jsonValue; + private final String jsonValue; - Bytes(String jsonValue) { - this.jsonValue = jsonValue; - } + Bytes(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Bytes.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Bytes.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ClusterStatistics.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ClusterStatistics.java index f18e23e939..025ebbe097 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ClusterStatistics.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ClusterStatistics.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,140 +43,140 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.ClusterStatistics @JsonpDeserializable public class ClusterStatistics implements JsonpSerializable { - private final int skipped; - - private final int successful; - - private final int total; - - // --------------------------------------------------------------------------------------------- - - private ClusterStatistics(Builder builder) { - - this.skipped = ApiTypeHelper.requireNonNull(builder.skipped, this, "skipped"); - this.successful = ApiTypeHelper.requireNonNull(builder.successful, this, "successful"); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - - } - - public static ClusterStatistics of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code skipped} - */ - public final int skipped() { - return this.skipped; - } + private final int skipped; - /** - * Required - API name: {@code successful} - */ - public final int successful() { - return this.successful; - } - - /** - * Required - API name: {@code total} - */ - public final int total() { - return this.total; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("skipped"); - generator.write(this.skipped); - - generator.writeKey("successful"); - generator.write(this.successful); - - generator.writeKey("total"); - generator.write(this.total); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link ClusterStatistics}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Integer skipped; - - private Integer successful; - - private Integer total; - - /** - * Required - API name: {@code skipped} - */ - public final Builder skipped(int value) { - this.skipped = value; - return this; - } - - /** - * Required - API name: {@code successful} - */ - public final Builder successful(int value) { - this.successful = value; - return this; - } - - /** - * Required - API name: {@code total} - */ - public final Builder total(int value) { - this.total = value; - return this; - } - - /** - * Builds a {@link ClusterStatistics}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public ClusterStatistics build() { - _checkSingleUse(); - - return new ClusterStatistics(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link ClusterStatistics} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, ClusterStatistics::setupClusterStatisticsDeserializer); - - protected static void setupClusterStatisticsDeserializer(ObjectDeserializer op) { - - op.add(Builder::skipped, JsonpDeserializer.integerDeserializer(), "skipped"); - op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); - op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); - - } + private final int successful; + + private final int total; + + // --------------------------------------------------------------------------------------------- + + private ClusterStatistics(Builder builder) { + + this.skipped = ApiTypeHelper.requireNonNull(builder.skipped, this, "skipped"); + this.successful = ApiTypeHelper.requireNonNull(builder.successful, this, "successful"); + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); + + } + + public static ClusterStatistics of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code skipped} + */ + public final int skipped() { + return this.skipped; + } + + /** + * Required - API name: {@code successful} + */ + public final int successful() { + return this.successful; + } + + /** + * Required - API name: {@code total} + */ + public final int total() { + return this.total; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("skipped"); + generator.write(this.skipped); + + generator.writeKey("successful"); + generator.write(this.successful); + + generator.writeKey("total"); + generator.write(this.total); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ClusterStatistics}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Integer skipped; + + private Integer successful; + + private Integer total; + + /** + * Required - API name: {@code skipped} + */ + public final Builder skipped(int value) { + this.skipped = value; + return this; + } + + /** + * Required - API name: {@code successful} + */ + public final Builder successful(int value) { + this.successful = value; + return this; + } + + /** + * Required - API name: {@code total} + */ + public final Builder total(int value) { + this.total = value; + return this; + } + + /** + * Builds a {@link ClusterStatistics}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ClusterStatistics build() { + _checkSingleUse(); + + return new ClusterStatistics(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ClusterStatistics} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + ClusterStatistics::setupClusterStatisticsDeserializer + ); + + protected static void setupClusterStatisticsDeserializer(ObjectDeserializer op) { + + op.add(Builder::skipped, JsonpDeserializer.integerDeserializer(), "skipped"); + op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); + op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/CompletionStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/CompletionStats.java index 736cc49822..85a4f4c1d3 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/CompletionStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/CompletionStats.java @@ -30,12 +30,12 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,178 +45,176 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.CompletionStats @JsonpDeserializable public class CompletionStats implements JsonpSerializable { - private final long sizeInBytes; + private final long sizeInBytes; - @Nullable - private final String size; - - private final Map fields; + @Nullable + private final String size; + + private final Map fields; - // --------------------------------------------------------------------------------------------- - - private CompletionStats(Builder builder) { - - this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes"); - this.size = builder.size; - this.fields = ApiTypeHelper.unmodifiable(builder.fields); - - } - - public static CompletionStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code size_in_bytes} - */ - public final long sizeInBytes() { - return this.sizeInBytes; - } - - /** - * API name: {@code size} - */ - @Nullable - public final String size() { - return this.size; - } - - /** - * API name: {@code fields} - */ - public final Map fields() { - return this.fields; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("size_in_bytes"); - generator.write(this.sizeInBytes); - - if (this.size != null) { - generator.writeKey("size"); - generator.write(this.size); - - } - if (ApiTypeHelper.isDefined(this.fields)) { - generator.writeKey("fields"); - generator.writeStartObject(); - for (Map.Entry item0 : this.fields.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link CompletionStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long sizeInBytes; - - @Nullable - private String size; - - @Nullable - private Map fields; - - /** - * Required - API name: {@code size_in_bytes} - */ - public final Builder sizeInBytes(long value) { - this.sizeInBytes = value; - return this; - } - - /** - * API name: {@code size} - */ - public final Builder size(@Nullable String value) { - this.size = value; - return this; - } - - /** - * API name: {@code fields} - *

- * Adds all entries of map to fields. - */ - public final Builder fields(Map map) { - this.fields = _mapPutAll(this.fields, map); - return this; - } - - /** - * API name: {@code fields} - *

- * Adds an entry to fields. - */ - public final Builder fields(String key, FieldSizeUsage value) { - this.fields = _mapPut(this.fields, key, value); - return this; - } - - /** - * API name: {@code fields} - *

- * Adds an entry to fields using a builder lambda. - */ - public final Builder fields(String key, Function> fn) { - return fields(key, fn.apply(new FieldSizeUsage.Builder()).build()); - } - - /** - * Builds a {@link CompletionStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public CompletionStats build() { - _checkSingleUse(); - - return new CompletionStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link CompletionStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - CompletionStats::setupCompletionStatsDeserializer); - - protected static void setupCompletionStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); - op.add(Builder::size, JsonpDeserializer.stringDeserializer(), "size"); - op.add(Builder::fields, JsonpDeserializer.stringMapDeserializer(FieldSizeUsage._DESERIALIZER), "fields"); - - } + // --------------------------------------------------------------------------------------------- + + private CompletionStats(Builder builder) { + + this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes"); + this.size = builder.size; + this.fields = ApiTypeHelper.unmodifiable(builder.fields); + + } + + public static CompletionStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code size_in_bytes} + */ + public final long sizeInBytes() { + return this.sizeInBytes; + } + + /** + * API name: {@code size} + */ + @Nullable + public final String size() { + return this.size; + } + + /** + * API name: {@code fields} + */ + public final Map fields() { + return this.fields; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("size_in_bytes"); + generator.write(this.sizeInBytes); + + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + + } + if (ApiTypeHelper.isDefined(this.fields)) { + generator.writeKey("fields"); + generator.writeStartObject(); + for (Map.Entry item0 : this.fields.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link CompletionStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long sizeInBytes; + + @Nullable + private String size; + + @Nullable + private Map fields; + + /** + * Required - API name: {@code size_in_bytes} + */ + public final Builder sizeInBytes(long value) { + this.sizeInBytes = value; + return this; + } + + /** + * API name: {@code size} + */ + public final Builder size(@Nullable String value) { + this.size = value; + return this; + } + + /** + * API name: {@code fields} + *

+ * Adds all entries of map to fields. + */ + public final Builder fields(Map map) { + this.fields = _mapPutAll(this.fields, map); + return this; + } + + /** + * API name: {@code fields} + *

+ * Adds an entry to fields. + */ + public final Builder fields(String key, FieldSizeUsage value) { + this.fields = _mapPut(this.fields, key, value); + return this; + } + + /** + * API name: {@code fields} + *

+ * Adds an entry to fields using a builder lambda. + */ + public final Builder fields(String key, Function> fn) { + return fields(key, fn.apply(new FieldSizeUsage.Builder()).build()); + } + + /** + * Builds a {@link CompletionStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public CompletionStats build() { + _checkSingleUse(); + + return new CompletionStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link CompletionStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + CompletionStats::setupCompletionStatsDeserializer + ); + + protected static void setupCompletionStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); + op.add(Builder::size, JsonpDeserializer.stringDeserializer(), "size"); + op.add(Builder::fields, JsonpDeserializer.stringMapDeserializer(FieldSizeUsage._DESERIALIZER), "fields"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Conflicts.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Conflicts.java index 18e1308dc4..dc551c5d2a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Conflicts.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Conflicts.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,22 +37,21 @@ @JsonpDeserializable public enum Conflicts implements JsonEnum { - Abort("abort"), + Abort("abort"), - Proceed("proceed"), + Proceed("proceed"), - ; + ; - private final String jsonValue; + private final String jsonValue; - Conflicts(String jsonValue) { - this.jsonValue = jsonValue; - } + Conflicts(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( - Conflicts.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Conflicts.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/CoordsGeoBounds.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/CoordsGeoBounds.java index d67b4de5e5..0551e8642c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/CoordsGeoBounds.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/CoordsGeoBounds.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,164 +43,164 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.CoordsGeoBounds @JsonpDeserializable public class CoordsGeoBounds implements JsonpSerializable { - private final double top; + private final double top; - private final double bottom; + private final double bottom; - private final double left; + private final double left; - private final double right; + private final double right; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - private CoordsGeoBounds(Builder builder) { + private CoordsGeoBounds(Builder builder) { - this.top = ApiTypeHelper.requireNonNull(builder.top, this, "top"); - this.bottom = ApiTypeHelper.requireNonNull(builder.bottom, this, "bottom"); - this.left = ApiTypeHelper.requireNonNull(builder.left, this, "left"); - this.right = ApiTypeHelper.requireNonNull(builder.right, this, "right"); + this.top = ApiTypeHelper.requireNonNull(builder.top, this, "top"); + this.bottom = ApiTypeHelper.requireNonNull(builder.bottom, this, "bottom"); + this.left = ApiTypeHelper.requireNonNull(builder.left, this, "left"); + this.right = ApiTypeHelper.requireNonNull(builder.right, this, "right"); - } + } - public static CoordsGeoBounds of(Function> fn) { - return fn.apply(new Builder()).build(); - } + public static CoordsGeoBounds of(Function> fn) { + return fn.apply(new Builder()).build(); + } - /** - * Required - API name: {@code top} - */ - public final double top() { - return this.top; - } - - /** - * Required - API name: {@code bottom} - */ - public final double bottom() { - return this.bottom; - } - - /** - * Required - API name: {@code left} - */ - public final double left() { - return this.left; - } - - /** - * Required - API name: {@code right} - */ - public final double right() { - return this.right; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("top"); - generator.write(this.top); - - generator.writeKey("bottom"); - generator.write(this.bottom); - - generator.writeKey("left"); - generator.write(this.left); - - generator.writeKey("right"); - generator.write(this.right); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link CoordsGeoBounds}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Double top; - - private Double bottom; - - private Double left; - - private Double right; - - /** - * Required - API name: {@code top} - */ - public final Builder top(double value) { - this.top = value; - return this; - } - - /** - * Required - API name: {@code bottom} - */ - public final Builder bottom(double value) { - this.bottom = value; - return this; - } - - /** - * Required - API name: {@code left} - */ - public final Builder left(double value) { - this.left = value; - return this; - } - - /** - * Required - API name: {@code right} - */ - public final Builder right(double value) { - this.right = value; - return this; - } - - /** - * Builds a {@link CoordsGeoBounds}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public CoordsGeoBounds build() { - _checkSingleUse(); - - return new CoordsGeoBounds(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link CoordsGeoBounds} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - CoordsGeoBounds::setupCoordsGeoBoundsDeserializer); - - protected static void setupCoordsGeoBoundsDeserializer(ObjectDeserializer op) { - - op.add(Builder::top, JsonpDeserializer.doubleDeserializer(), "top"); - op.add(Builder::bottom, JsonpDeserializer.doubleDeserializer(), "bottom"); - op.add(Builder::left, JsonpDeserializer.doubleDeserializer(), "left"); - op.add(Builder::right, JsonpDeserializer.doubleDeserializer(), "right"); - - } + /** + * Required - API name: {@code top} + */ + public final double top() { + return this.top; + } + + /** + * Required - API name: {@code bottom} + */ + public final double bottom() { + return this.bottom; + } + + /** + * Required - API name: {@code left} + */ + public final double left() { + return this.left; + } + + /** + * Required - API name: {@code right} + */ + public final double right() { + return this.right; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("top"); + generator.write(this.top); + + generator.writeKey("bottom"); + generator.write(this.bottom); + + generator.writeKey("left"); + generator.write(this.left); + + generator.writeKey("right"); + generator.write(this.right); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link CoordsGeoBounds}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Double top; + + private Double bottom; + + private Double left; + + private Double right; + + /** + * Required - API name: {@code top} + */ + public final Builder top(double value) { + this.top = value; + return this; + } + + /** + * Required - API name: {@code bottom} + */ + public final Builder bottom(double value) { + this.bottom = value; + return this; + } + + /** + * Required - API name: {@code left} + */ + public final Builder left(double value) { + this.left = value; + return this; + } + + /** + * Required - API name: {@code right} + */ + public final Builder right(double value) { + this.right = value; + return this; + } + + /** + * Builds a {@link CoordsGeoBounds}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public CoordsGeoBounds build() { + _checkSingleUse(); + + return new CoordsGeoBounds(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link CoordsGeoBounds} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + CoordsGeoBounds::setupCoordsGeoBoundsDeserializer + ); + + protected static void setupCoordsGeoBoundsDeserializer(ObjectDeserializer op) { + + op.add(Builder::top, JsonpDeserializer.doubleDeserializer(), "top"); + op.add(Builder::bottom, JsonpDeserializer.doubleDeserializer(), "bottom"); + op.add(Builder::left, JsonpDeserializer.doubleDeserializer(), "left"); + op.add(Builder::right, JsonpDeserializer.doubleDeserializer(), "right"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/DistanceUnit.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/DistanceUnit.java index 71f67a45e5..fa3511a98c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/DistanceUnit.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/DistanceUnit.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,36 +37,35 @@ @JsonpDeserializable public enum DistanceUnit implements JsonEnum { - Inches("in"), + Inches("in"), - Feet("ft"), + Feet("ft"), - Yards("yd"), + Yards("yd"), - Miles("mi"), + Miles("mi"), - NauticMiles("nmi"), + NauticMiles("nmi"), - Kilometers("km"), + Kilometers("km"), - Meters("m"), + Meters("m"), - Centimeters("cm"), + Centimeters("cm"), - Millimeters("mm"), + Millimeters("mm"), - ; + ; - private final String jsonValue; + private final String jsonValue; - DistanceUnit(String jsonValue) { - this.jsonValue = jsonValue; - } + DistanceUnit(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( - DistanceUnit.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(DistanceUnit.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/DocStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/DocStats.java index d6a13fac28..25f5f8a39f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/DocStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/DocStats.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,116 +43,116 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.DocStats @JsonpDeserializable public class DocStats implements JsonpSerializable { - private final long count; - - private final long deleted; - - // --------------------------------------------------------------------------------------------- + private final long count; - private DocStats(Builder builder) { + private final long deleted; + + // --------------------------------------------------------------------------------------------- - this.count = ApiTypeHelper.requireNonNull(builder.count, this, "count"); - this.deleted = ApiTypeHelper.requireNonNull(builder.deleted, this, "deleted"); + private DocStats(Builder builder) { - } + this.count = ApiTypeHelper.requireNonNull(builder.count, this, "count"); + this.deleted = ApiTypeHelper.requireNonNull(builder.deleted, this, "deleted"); - public static DocStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } + } - /** - * Required - API name: {@code count} - */ - public final long count() { - return this.count; - } + public static DocStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } - /** - * Required - API name: {@code deleted} - */ - public final long deleted() { - return this.deleted; - } + /** + * Required - API name: {@code count} + */ + public final long count() { + return this.count; + } - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } + /** + * Required - API name: {@code deleted} + */ + public final long deleted() { + return this.deleted; + } - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } - generator.writeKey("count"); - generator.write(this.count); + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("deleted"); - generator.write(this.deleted); + generator.writeKey("count"); + generator.write(this.count); - } + generator.writeKey("deleted"); + generator.write(this.deleted); - // --------------------------------------------------------------------------------------------- + } - /** - * Builder for {@link DocStats}. - */ + // --------------------------------------------------------------------------------------------- - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long count; + /** + * Builder for {@link DocStats}. + */ - private Long deleted; + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long count; - /** - * Required - API name: {@code count} - */ - public final Builder count(long value) { - this.count = value; - return this; - } + private Long deleted; - /** - * Required - API name: {@code deleted} - */ - public final Builder deleted(long value) { - this.deleted = value; - return this; - } + /** + * Required - API name: {@code count} + */ + public final Builder count(long value) { + this.count = value; + return this; + } - /** - * Builds a {@link DocStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public DocStats build() { - _checkSingleUse(); + /** + * Required - API name: {@code deleted} + */ + public final Builder deleted(long value) { + this.deleted = value; + return this; + } - return new DocStats(this); - } - } + /** + * Builds a {@link DocStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public DocStats build() { + _checkSingleUse(); - // --------------------------------------------------------------------------------------------- + return new DocStats(this); + } + } - /** - * Json deserializer for {@link DocStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - DocStats::setupDocStatsDeserializer); + // --------------------------------------------------------------------------------------------- - protected static void setupDocStatsDeserializer(ObjectDeserializer op) { + /** + * Json deserializer for {@link DocStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + DocStats::setupDocStatsDeserializer + ); - op.add(Builder::count, JsonpDeserializer.longDeserializer(), "count"); - op.add(Builder::deleted, JsonpDeserializer.longDeserializer(), "deleted"); + protected static void setupDocStatsDeserializer(ObjectDeserializer op) { - } + op.add(Builder::count, JsonpDeserializer.longDeserializer(), "count"); + op.add(Builder::deleted, JsonpDeserializer.longDeserializer(), "deleted"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/EmptyObject.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/EmptyObject.java index 4294d63db2..2bac7df617 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/EmptyObject.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/EmptyObject.java @@ -30,47 +30,42 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.util.ObjectBuilder; -import jakarta.json.stream.JsonGenerator; /** * For empty Class assignments - * + * */ @JsonpDeserializable public class EmptyObject implements JsonpSerializable { - public static final class Builder implements ObjectBuilder { - @Override - public EmptyObject build() { - return EmptyObject._INSTANCE; - } - } + public static final class Builder implements ObjectBuilder { + @Override + public EmptyObject build() { + return EmptyObject._INSTANCE; + } + } - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - generator.writeEnd(); - } + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + generator.writeEnd(); + } - /** - * Singleton instance for empty class {@link EmptyObject}. - */ - public static final EmptyObject _INSTANCE = new EmptyObject(); + /** + * Singleton instance for empty class {@link EmptyObject}. + */ + public static final EmptyObject _INSTANCE = new EmptyObject(); - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer - .emptyObject(EmptyObject._INSTANCE); + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.emptyObject(EmptyObject._INSTANCE); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/EmptyTransform.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/EmptyTransform.java index 50be20a5e3..6d298b5a7c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/EmptyTransform.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/EmptyTransform.java @@ -30,43 +30,38 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.util.ObjectBuilder; -import jakarta.json.stream.JsonGenerator; @JsonpDeserializable public class EmptyTransform implements JsonpSerializable { - public static final class Builder implements ObjectBuilder { - @Override - public EmptyTransform build() { - return EmptyTransform._INSTANCE; - } - } + public static final class Builder implements ObjectBuilder { + @Override + public EmptyTransform build() { + return EmptyTransform._INSTANCE; + } + } - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - generator.writeEnd(); - } + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + generator.writeEnd(); + } - /** - * Singleton instance for empty class {@link EmptyTransform}. - */ - public static final EmptyTransform _INSTANCE = new EmptyTransform(); + /** + * Singleton instance for empty class {@link EmptyTransform}. + */ + public static final EmptyTransform _INSTANCE = new EmptyTransform(); - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer - .emptyObject(EmptyTransform._INSTANCE); + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.emptyObject(EmptyTransform._INSTANCE); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorCause.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorCause.java index 8b4513cf82..469134d325 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorCause.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorCause.java @@ -30,12 +30,14 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; @@ -46,12 +48,6 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.ErrorCause @@ -62,342 +58,344 @@ */ @JsonpDeserializable public class ErrorCause implements JsonpSerializable { - private final Map metadata; - - private final String type; - - private final String reason; - - @Nullable - private final String stackTrace; - - @Nullable - private final ErrorCause causedBy; - - private final List rootCause; - - private final List suppressed; - - // --------------------------------------------------------------------------------------------- - - private ErrorCause(Builder builder) { - - this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); - - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason"); - this.stackTrace = builder.stackTrace; - this.causedBy = builder.causedBy; - this.rootCause = ApiTypeHelper.unmodifiable(builder.rootCause); - this.suppressed = ApiTypeHelper.unmodifiable(builder.suppressed); - - } - - public static ErrorCause of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Additional details about the error - */ - public final Map metadata() { - return this.metadata; - } - - /** - * Required - The type of error - *

- * API name: {@code type} - */ - public final String type() { - return this.type; - } - - /** - * Required - A human-readable explanation of the error, in english - *

- * API name: {@code reason} - */ - public final String reason() { - return this.reason; - } - - /** - * The server stack trace. Present only if the error_trace=true - * parameter was sent with the request. - *

- * API name: {@code stack_trace} - */ - @Nullable - public final String stackTrace() { - return this.stackTrace; - } - - /** - * API name: {@code caused_by} - */ - @Nullable - public final ErrorCause causedBy() { - return this.causedBy; - } - - /** - * API name: {@code root_cause} - */ - public final List rootCause() { - return this.rootCause; - } - - /** - * API name: {@code suppressed} - */ - public final List suppressed() { - return this.suppressed; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - for (Map.Entry item0 : this.metadata.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - - generator.writeKey("type"); - generator.write(this.type); - - generator.writeKey("reason"); - generator.write(this.reason); - - if (this.stackTrace != null) { - generator.writeKey("stack_trace"); - generator.write(this.stackTrace); - - } - if (this.causedBy != null) { - generator.writeKey("caused_by"); - this.causedBy.serialize(generator, mapper); - - } - if (ApiTypeHelper.isDefined(this.rootCause)) { - generator.writeKey("root_cause"); - generator.writeStartArray(); - for (ErrorCause item0 : this.rootCause) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } - if (ApiTypeHelper.isDefined(this.suppressed)) { - generator.writeKey("suppressed"); - generator.writeStartArray(); - for (ErrorCause item0 : this.suppressed) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link ErrorCause}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private Map metadata = new HashMap<>(); - - /** - * Additional details about the error - *

- * Adds all entries of map to metadata. - */ - public final Builder metadata(Map map) { - this.metadata = _mapPutAll(this.metadata, map); - return this; - } - - /** - * Additional details about the error - *

- * Adds an entry to metadata. - */ - public final Builder metadata(String key, JsonData value) { - this.metadata = _mapPut(this.metadata, key, value); - return this; - } - - private String type; - - private String reason; - - @Nullable - private String stackTrace; - - @Nullable - private ErrorCause causedBy; - - @Nullable - private List rootCause; - - @Nullable - private List suppressed; - - /** - * Required - The type of error - *

- * API name: {@code type} - */ - public final Builder type(String value) { - this.type = value; - return this; - } - - /** - * Required - A human-readable explanation of the error, in english - *

- * API name: {@code reason} - */ - public final Builder reason(String value) { - this.reason = value; - return this; - } - - /** - * The server stack trace. Present only if the error_trace=true - * parameter was sent with the request. - *

- * API name: {@code stack_trace} - */ - public final Builder stackTrace(@Nullable String value) { - this.stackTrace = value; - return this; - } - - /** - * API name: {@code caused_by} - */ - public final Builder causedBy(@Nullable ErrorCause value) { - this.causedBy = value; - return this; - } - - /** - * API name: {@code caused_by} - */ - public final Builder causedBy(Function> fn) { - return this.causedBy(fn.apply(new ErrorCause.Builder()).build()); - } - - /** - * API name: {@code root_cause} - *

- * Adds all elements of list to rootCause. - */ - public final Builder rootCause(List list) { - this.rootCause = _listAddAll(this.rootCause, list); - return this; - } - - /** - * API name: {@code root_cause} - *

- * Adds one or more values to rootCause. - */ - public final Builder rootCause(ErrorCause value, ErrorCause... values) { - this.rootCause = _listAdd(this.rootCause, value, values); - return this; - } - - /** - * API name: {@code root_cause} - *

- * Adds a value to rootCause using a builder lambda. - */ - public final Builder rootCause(Function> fn) { - return rootCause(fn.apply(new ErrorCause.Builder()).build()); - } - - /** - * API name: {@code suppressed} - *

- * Adds all elements of list to suppressed. - */ - public final Builder suppressed(List list) { - this.suppressed = _listAddAll(this.suppressed, list); - return this; - } - - /** - * API name: {@code suppressed} - *

- * Adds one or more values to suppressed. - */ - public final Builder suppressed(ErrorCause value, ErrorCause... values) { - this.suppressed = _listAdd(this.suppressed, value, values); - return this; - } - - /** - * API name: {@code suppressed} - *

- * Adds a value to suppressed using a builder lambda. - */ - public final Builder suppressed(Function> fn) { - return suppressed(fn.apply(new ErrorCause.Builder()).build()); - } - - /** - * Builds a {@link ErrorCause}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public ErrorCause build() { - _checkSingleUse(); - - return new ErrorCause(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link ErrorCause} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - ErrorCause::setupErrorCauseDeserializer); - - protected static void setupErrorCauseDeserializer(ObjectDeserializer op) { - - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - op.add(Builder::reason, JsonpDeserializer.stringDeserializer(), "reason"); - op.add(Builder::stackTrace, JsonpDeserializer.stringDeserializer(), "stack_trace"); - op.add(Builder::causedBy, ErrorCause._DESERIALIZER, "caused_by"); - op.add(Builder::rootCause, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "root_cause"); - op.add(Builder::suppressed, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "suppressed"); - - op.setUnknownFieldHandler((builder, name, parser, mapper) -> { - if (builder.metadata == null) { - builder.metadata = new HashMap<>(); - } - builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); - }); - - } + private final Map metadata; + + private final String type; + + private final String reason; + + @Nullable + private final String stackTrace; + + @Nullable + private final ErrorCause causedBy; + + private final List rootCause; + + private final List suppressed; + + // --------------------------------------------------------------------------------------------- + + private ErrorCause(Builder builder) { + + this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); + + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason"); + this.stackTrace = builder.stackTrace; + this.causedBy = builder.causedBy; + this.rootCause = ApiTypeHelper.unmodifiable(builder.rootCause); + this.suppressed = ApiTypeHelper.unmodifiable(builder.suppressed); + + } + + public static ErrorCause of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Additional details about the error + */ + public final Map metadata() { + return this.metadata; + } + + /** + * Required - The type of error + *

+ * API name: {@code type} + */ + public final String type() { + return this.type; + } + + /** + * Required - A human-readable explanation of the error, in english + *

+ * API name: {@code reason} + */ + public final String reason() { + return this.reason; + } + + /** + * The server stack trace. Present only if the error_trace=true + * parameter was sent with the request. + *

+ * API name: {@code stack_trace} + */ + @Nullable + public final String stackTrace() { + return this.stackTrace; + } + + /** + * API name: {@code caused_by} + */ + @Nullable + public final ErrorCause causedBy() { + return this.causedBy; + } + + /** + * API name: {@code root_cause} + */ + public final List rootCause() { + return this.rootCause; + } + + /** + * API name: {@code suppressed} + */ + public final List suppressed() { + return this.suppressed; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + for (Map.Entry item0 : this.metadata.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + + generator.writeKey("type"); + generator.write(this.type); + + generator.writeKey("reason"); + generator.write(this.reason); + + if (this.stackTrace != null) { + generator.writeKey("stack_trace"); + generator.write(this.stackTrace); + + } + if (this.causedBy != null) { + generator.writeKey("caused_by"); + this.causedBy.serialize(generator, mapper); + + } + if (ApiTypeHelper.isDefined(this.rootCause)) { + generator.writeKey("root_cause"); + generator.writeStartArray(); + for (ErrorCause item0 : this.rootCause) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.suppressed)) { + generator.writeKey("suppressed"); + generator.writeStartArray(); + for (ErrorCause item0 : this.suppressed) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ErrorCause}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private Map metadata = new HashMap<>(); + + /** + * Additional details about the error + *

+ * Adds all entries of map to metadata. + */ + public final Builder metadata(Map map) { + this.metadata = _mapPutAll(this.metadata, map); + return this; + } + + /** + * Additional details about the error + *

+ * Adds an entry to metadata. + */ + public final Builder metadata(String key, JsonData value) { + this.metadata = _mapPut(this.metadata, key, value); + return this; + } + + private String type; + + private String reason; + + @Nullable + private String stackTrace; + + @Nullable + private ErrorCause causedBy; + + @Nullable + private List rootCause; + + @Nullable + private List suppressed; + + /** + * Required - The type of error + *

+ * API name: {@code type} + */ + public final Builder type(String value) { + this.type = value; + return this; + } + + /** + * Required - A human-readable explanation of the error, in english + *

+ * API name: {@code reason} + */ + public final Builder reason(String value) { + this.reason = value; + return this; + } + + /** + * The server stack trace. Present only if the error_trace=true + * parameter was sent with the request. + *

+ * API name: {@code stack_trace} + */ + public final Builder stackTrace(@Nullable String value) { + this.stackTrace = value; + return this; + } + + /** + * API name: {@code caused_by} + */ + public final Builder causedBy(@Nullable ErrorCause value) { + this.causedBy = value; + return this; + } + + /** + * API name: {@code caused_by} + */ + public final Builder causedBy(Function> fn) { + return this.causedBy(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * API name: {@code root_cause} + *

+ * Adds all elements of list to rootCause. + */ + public final Builder rootCause(List list) { + this.rootCause = _listAddAll(this.rootCause, list); + return this; + } + + /** + * API name: {@code root_cause} + *

+ * Adds one or more values to rootCause. + */ + public final Builder rootCause(ErrorCause value, ErrorCause... values) { + this.rootCause = _listAdd(this.rootCause, value, values); + return this; + } + + /** + * API name: {@code root_cause} + *

+ * Adds a value to rootCause using a builder lambda. + */ + public final Builder rootCause(Function> fn) { + return rootCause(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * API name: {@code suppressed} + *

+ * Adds all elements of list to suppressed. + */ + public final Builder suppressed(List list) { + this.suppressed = _listAddAll(this.suppressed, list); + return this; + } + + /** + * API name: {@code suppressed} + *

+ * Adds one or more values to suppressed. + */ + public final Builder suppressed(ErrorCause value, ErrorCause... values) { + this.suppressed = _listAdd(this.suppressed, value, values); + return this; + } + + /** + * API name: {@code suppressed} + *

+ * Adds a value to suppressed using a builder lambda. + */ + public final Builder suppressed(Function> fn) { + return suppressed(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * Builds a {@link ErrorCause}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ErrorCause build() { + _checkSingleUse(); + + return new ErrorCause(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ErrorCause} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + ErrorCause::setupErrorCauseDeserializer + ); + + protected static void setupErrorCauseDeserializer(ObjectDeserializer op) { + + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + op.add(Builder::reason, JsonpDeserializer.stringDeserializer(), "reason"); + op.add(Builder::stackTrace, JsonpDeserializer.stringDeserializer(), "stack_trace"); + op.add(Builder::causedBy, ErrorCause._DESERIALIZER, "caused_by"); + op.add(Builder::rootCause, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "root_cause"); + op.add(Builder::suppressed, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "suppressed"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + if (builder.metadata == null) { + builder.metadata = new HashMap<>(); + } + builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorResponse.java index 2f71c65905..995c9afd89 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorResponse.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ErrorResponse.java @@ -30,143 +30,162 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.UnionDeserializer; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.ErrorResponseBase /** - * The response returned by Elasticsearch when request execution did not + * The response returned by OpenSearch when request execution did not * succeed. - * + * */ @JsonpDeserializable public class ErrorResponse implements JsonpSerializable { - private final ErrorCause error; - - private final int status; - - // --------------------------------------------------------------------------------------------- - - private ErrorResponse(Builder builder) { - - this.error = ApiTypeHelper.requireNonNull(builder.error, this, "error"); - this.status = ApiTypeHelper.requireNonNull(builder.status, this, "status"); - - } - - public static ErrorResponse of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code error} - */ - public final ErrorCause error() { - return this.error; - } - - /** - * Required - API name: {@code status} - */ - public final int status() { - return this.status; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("error"); - this.error.serialize(generator, mapper); - - generator.writeKey("status"); - generator.write(this.status); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link ErrorResponse}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private ErrorCause error; - - private Integer status; - - /** - * Required - API name: {@code error} - */ - public final Builder error(ErrorCause value) { - this.error = value; - return this; - } - - /** - * Required - API name: {@code error} - */ - public final Builder error(Function> fn) { - return this.error(fn.apply(new ErrorCause.Builder()).build()); - } - - /** - * Required - API name: {@code status} - */ - public final Builder status(int value) { - this.status = value; - return this; - } - - /** - * Builds a {@link ErrorResponse}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public ErrorResponse build() { - _checkSingleUse(); - - return new ErrorResponse(this); - } - } - // --------------------------------------------------------------------------------------------- + private enum Kind { + OBJECT, + STRING + } + + private final ErrorCause error; + + private final Integer status; + + // --------------------------------------------------------------------------------------------- + + private ErrorResponse(Builder builder) { + + this.error = ApiTypeHelper.requireNonNull(builder.error, this, "error"); + this.status = builder.status; + + } + + public static ErrorResponse of(Function> fn) { + return fn.apply(new Builder()).build(); + } - /** - * Json deserializer for {@link ErrorResponse} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - ErrorResponse::setupErrorResponseDeserializer); - - protected static void setupErrorResponseDeserializer(ObjectDeserializer op) { - - op.add(Builder::error, ErrorCause._DESERIALIZER, "error"); - op.add(Builder::status, JsonpDeserializer.integerDeserializer(), "status"); - - } + /** + * Required - API name: {@code error} + */ + public final ErrorCause error() { + return this.error; + } + + /** + * Required - API name: {@code status} + */ + public final Integer status() { + return this.status; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("error"); + this.error.serialize(generator, mapper); + + if (this.status != null) { + generator.writeKey("status"); + generator.write(this.status); + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ErrorResponse}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private ErrorCause error; + + private Integer status; + + /** + * Required - API name: {@code error} + */ + public final Builder error(ErrorCause value) { + this.error = value; + return this; + } + + /** + * Required - API name: {@code error} + */ + public final Builder error(Function> fn) { + return this.error(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * Required - API name: {@code status} + */ + public final Builder status(int value) { + this.status = value; + return this; + } + + /** + * Builds a {@link ErrorResponse}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ErrorResponse build() { + _checkSingleUse(); + + return new ErrorResponse(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ErrorResponse} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + ErrorResponse::setupErrorResponseDeserializer + ); + + protected static void setupErrorResponseDeserializer(ObjectDeserializer op) { + + op.add(Builder::error, buildErrorCauseDeserializers(), "error"); + op.add(Builder::status, JsonpDeserializer.integerDeserializer(), "status"); + + } + + protected static JsonpDeserializer buildErrorCauseDeserializers() { + return new UnionDeserializer.Builder<>(ErrorResponse::getErrorCause, false).addMember(Kind.OBJECT, ErrorCause._DESERIALIZER) + .addMember(Kind.STRING, JsonpDeserializer.stringDeserializer()) + .build(); + } + + private static ErrorCause getErrorCause(Kind kind, Object errorCause) { + return Kind.STRING.equals(kind) + ? ErrorCause.of(builder -> builder.type("string_error").reason((String) errorCause)) + : (ErrorCause) errorCause; + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java index 200b8f1e6b..5b66a33bd2 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ExpandWildcard.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,45 +37,44 @@ @JsonpDeserializable public enum ExpandWildcard implements JsonEnum { - /** - * Match any data stream or index, including hidden ones. - */ - All("all"), + /** + * Match any data stream or index, including hidden ones. + */ + All("all"), - /** - * Match open, non-hidden indices. Also matches any non-hidden data stream. - */ - Open("open"), + /** + * Match open, non-hidden indices. Also matches any non-hidden data stream. + */ + Open("open"), - /** - * Match closed, non-hidden indices. Also matches any non-hidden data stream. - * Data streams cannot be closed. - */ - Closed("closed"), + /** + * Match closed, non-hidden indices. Also matches any non-hidden data stream. + * Data streams cannot be closed. + */ + Closed("closed"), - /** - * Match hidden data streams and hidden indices. Must be combined with open, - * closed, or both. - */ - Hidden("hidden"), + /** + * Match hidden data streams and hidden indices. Must be combined with open, + * closed, or both. + */ + Hidden("hidden"), - /** - * Wildcard expressions are not accepted. - */ - None("none"), + /** + * Wildcard expressions are not accepted. + */ + None("none"), - ; + ; - private final String jsonValue; + private final String jsonValue; - ExpandWildcard(String jsonValue) { - this.jsonValue = jsonValue; - } + ExpandWildcard(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( - ExpandWildcard.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(ExpandWildcard.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldMemoryUsage.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldMemoryUsage.java index 6e4b11f0bc..b202739387 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldMemoryUsage.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldMemoryUsage.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,122 +44,121 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.FieldMemoryUsage @JsonpDeserializable public class FieldMemoryUsage implements JsonpSerializable { - @Nullable - private final String memorySize; - - private final long memorySizeInBytes; - - // --------------------------------------------------------------------------------------------- - - private FieldMemoryUsage(Builder builder) { - - this.memorySize = builder.memorySize; - this.memorySizeInBytes = ApiTypeHelper.requireNonNull(builder.memorySizeInBytes, this, "memorySizeInBytes"); - - } - - public static FieldMemoryUsage of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code memory_size} - */ - @Nullable - public final String memorySize() { - return this.memorySize; - } - - /** - * Required - API name: {@code memory_size_in_bytes} - */ - public final long memorySizeInBytes() { - return this.memorySizeInBytes; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (this.memorySize != null) { - generator.writeKey("memory_size"); - generator.write(this.memorySize); - - } - generator.writeKey("memory_size_in_bytes"); - generator.write(this.memorySizeInBytes); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link FieldMemoryUsage}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private String memorySize; - - private Long memorySizeInBytes; - - /** - * API name: {@code memory_size} - */ - public final Builder memorySize(@Nullable String value) { - this.memorySize = value; - return this; - } - - /** - * Required - API name: {@code memory_size_in_bytes} - */ - public final Builder memorySizeInBytes(long value) { - this.memorySizeInBytes = value; - return this; - } - - /** - * Builds a {@link FieldMemoryUsage}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public FieldMemoryUsage build() { - _checkSingleUse(); - - return new FieldMemoryUsage(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link FieldMemoryUsage} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - FieldMemoryUsage::setupFieldMemoryUsageDeserializer); - - protected static void setupFieldMemoryUsageDeserializer(ObjectDeserializer op) { - - op.add(Builder::memorySize, JsonpDeserializer.stringDeserializer(), "memory_size"); - op.add(Builder::memorySizeInBytes, JsonpDeserializer.longDeserializer(), "memory_size_in_bytes"); - - } + @Nullable + private final String memorySize; + + private final long memorySizeInBytes; + + // --------------------------------------------------------------------------------------------- + + private FieldMemoryUsage(Builder builder) { + + this.memorySize = builder.memorySize; + this.memorySizeInBytes = ApiTypeHelper.requireNonNull(builder.memorySizeInBytes, this, "memorySizeInBytes"); + + } + + public static FieldMemoryUsage of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code memory_size} + */ + @Nullable + public final String memorySize() { + return this.memorySize; + } + + /** + * Required - API name: {@code memory_size_in_bytes} + */ + public final long memorySizeInBytes() { + return this.memorySizeInBytes; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.memorySize != null) { + generator.writeKey("memory_size"); + generator.write(this.memorySize); + + } + generator.writeKey("memory_size_in_bytes"); + generator.write(this.memorySizeInBytes); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link FieldMemoryUsage}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private String memorySize; + + private Long memorySizeInBytes; + + /** + * API name: {@code memory_size} + */ + public final Builder memorySize(@Nullable String value) { + this.memorySize = value; + return this; + } + + /** + * Required - API name: {@code memory_size_in_bytes} + */ + public final Builder memorySizeInBytes(long value) { + this.memorySizeInBytes = value; + return this; + } + + /** + * Builds a {@link FieldMemoryUsage}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public FieldMemoryUsage build() { + _checkSingleUse(); + + return new FieldMemoryUsage(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link FieldMemoryUsage} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + FieldMemoryUsage::setupFieldMemoryUsageDeserializer + ); + + protected static void setupFieldMemoryUsageDeserializer(ObjectDeserializer op) { + + op.add(Builder::memorySize, JsonpDeserializer.stringDeserializer(), "memory_size"); + op.add(Builder::memorySizeInBytes, JsonpDeserializer.longDeserializer(), "memory_size_in_bytes"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSizeUsage.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSizeUsage.java index 1712daae34..9d90e1e566 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSizeUsage.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSizeUsage.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,122 +44,121 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.FieldSizeUsage @JsonpDeserializable public class FieldSizeUsage implements JsonpSerializable { - @Nullable - private final String size; - - private final long sizeInBytes; - - // --------------------------------------------------------------------------------------------- - - private FieldSizeUsage(Builder builder) { - - this.size = builder.size; - this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes"); - - } - - public static FieldSizeUsage of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code size} - */ - @Nullable - public final String size() { - return this.size; - } - - /** - * Required - API name: {@code size_in_bytes} - */ - public final long sizeInBytes() { - return this.sizeInBytes; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (this.size != null) { - generator.writeKey("size"); - generator.write(this.size); - - } - generator.writeKey("size_in_bytes"); - generator.write(this.sizeInBytes); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link FieldSizeUsage}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private String size; - - private Long sizeInBytes; - - /** - * API name: {@code size} - */ - public final Builder size(@Nullable String value) { - this.size = value; - return this; - } - - /** - * Required - API name: {@code size_in_bytes} - */ - public final Builder sizeInBytes(long value) { - this.sizeInBytes = value; - return this; - } - - /** - * Builds a {@link FieldSizeUsage}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public FieldSizeUsage build() { - _checkSingleUse(); - - return new FieldSizeUsage(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link FieldSizeUsage} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - FieldSizeUsage::setupFieldSizeUsageDeserializer); - - protected static void setupFieldSizeUsageDeserializer(ObjectDeserializer op) { - - op.add(Builder::size, JsonpDeserializer.stringDeserializer(), "size"); - op.add(Builder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); - - } + @Nullable + private final String size; + + private final long sizeInBytes; + + // --------------------------------------------------------------------------------------------- + + private FieldSizeUsage(Builder builder) { + + this.size = builder.size; + this.sizeInBytes = ApiTypeHelper.requireNonNull(builder.sizeInBytes, this, "sizeInBytes"); + + } + + public static FieldSizeUsage of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code size} + */ + @Nullable + public final String size() { + return this.size; + } + + /** + * Required - API name: {@code size_in_bytes} + */ + public final long sizeInBytes() { + return this.sizeInBytes; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + + } + generator.writeKey("size_in_bytes"); + generator.write(this.sizeInBytes); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link FieldSizeUsage}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private String size; + + private Long sizeInBytes; + + /** + * API name: {@code size} + */ + public final Builder size(@Nullable String value) { + this.size = value; + return this; + } + + /** + * Required - API name: {@code size_in_bytes} + */ + public final Builder sizeInBytes(long value) { + this.sizeInBytes = value; + return this; + } + + /** + * Builds a {@link FieldSizeUsage}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public FieldSizeUsage build() { + _checkSingleUse(); + + return new FieldSizeUsage(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link FieldSizeUsage} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + FieldSizeUsage::setupFieldSizeUsageDeserializer + ); + + protected static void setupFieldSizeUsageDeserializer(ObjectDeserializer op) { + + op.add(Builder::size, JsonpDeserializer.stringDeserializer(), "size"); + op.add(Builder::sizeInBytes, JsonpDeserializer.longDeserializer(), "size_in_bytes"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSort.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSort.java index dde62124ef..08806a7cc8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSort.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSort.java @@ -30,328 +30,325 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; -import org.opensearch.client.opensearch._types.mapping.FieldType; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.opensearch._types.mapping.FieldType; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; - -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.FieldSort @JsonpDeserializable public class FieldSort implements JsonpSerializable { - // Single key dictionary - private final String field; - - @Nullable - private final FieldValue missing; - - @Nullable - private final SortMode mode; - - @Nullable - private final NestedSortValue nested; - - @Nullable - private final SortOrder order; - - @Nullable - private final FieldType unmappedType; - - @Nullable - private final FieldSortNumericType numericType; - - @Nullable - private final String format; - - // --------------------------------------------------------------------------------------------- - - private FieldSort(Builder builder) { - - this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); - - this.missing = builder.missing; - this.mode = builder.mode; - this.nested = builder.nested; - this.order = builder.order; - this.unmappedType = builder.unmappedType; - this.numericType = builder.numericType; - this.format = builder.format; - - } - - public static FieldSort of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - The target field - */ - public final String field() { - return this.field; - } - - /** - * API name: {@code missing} - */ - @Nullable - public final FieldValue missing() { - return this.missing; - } - - /** - * API name: {@code mode} - */ - @Nullable - public final SortMode mode() { - return this.mode; - } - - /** - * API name: {@code nested} - */ - @Nullable - public final NestedSortValue nested() { - return this.nested; - } - - /** - * API name: {@code order} - */ - @Nullable - public final SortOrder order() { - return this.order; - } - - /** - * API name: {@code unmapped_type} - */ - @Nullable - public final FieldType unmappedType() { - return this.unmappedType; - } - - /** - * API name: {@code numeric_type} - */ - @Nullable - public final FieldSortNumericType numericType() { - return this.numericType; - } - - /** - * API name: {@code format} - */ - @Nullable - public final String format() { - return this.format; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(this.field); - - if (this.missing != null) { - generator.writeKey("missing"); - this.missing.serialize(generator, mapper); - - } - if (this.mode != null) { - generator.writeKey("mode"); - this.mode.serialize(generator, mapper); - } - if (this.nested != null) { - generator.writeKey("nested"); - this.nested.serialize(generator, mapper); - - } - if (this.order != null) { - generator.writeKey("order"); - this.order.serialize(generator, mapper); - } - if (this.unmappedType != null) { - generator.writeKey("unmapped_type"); - this.unmappedType.serialize(generator, mapper); - } - if (this.numericType != null) { - generator.writeKey("numeric_type"); - this.numericType.serialize(generator, mapper); - } - if (this.format != null) { - generator.writeKey("format"); - generator.write(this.format); - - } - - generator.writeEnd(); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link FieldSort}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String field; - - /** - * Required - The target field - */ - public final Builder field(String value) { - this.field = value; - return this; - } - - @Nullable - private FieldValue missing; - - @Nullable - private SortMode mode; - - @Nullable - private NestedSortValue nested; - - @Nullable - private SortOrder order; - - @Nullable - private FieldType unmappedType; - - @Nullable - private FieldSortNumericType numericType; - - @Nullable - private String format; - - /** - * API name: {@code missing} - */ - public final Builder missing(@Nullable FieldValue value) { - this.missing = value; - return this; - } - - /** - * API name: {@code missing} - */ - public final Builder missing(Function> fn) { - return this.missing(fn.apply(new FieldValue.Builder()).build()); - } - - /** - * API name: {@code mode} - */ - public final Builder mode(@Nullable SortMode value) { - this.mode = value; - return this; - } - - /** - * API name: {@code nested} - */ - public final Builder nested(@Nullable NestedSortValue value) { - this.nested = value; - return this; - } - - /** - * API name: {@code nested} - */ - public final Builder nested(Function> fn) { - return this.nested(fn.apply(new NestedSortValue.Builder()).build()); - } - - /** - * API name: {@code order} - */ - public final Builder order(@Nullable SortOrder value) { - this.order = value; - return this; - } - - /** - * API name: {@code unmapped_type} - */ - public final Builder unmappedType(@Nullable FieldType value) { - this.unmappedType = value; - return this; - } - - /** - * API name: {@code numeric_type} - */ - public final Builder numericType(@Nullable FieldSortNumericType value) { - this.numericType = value; - return this; - } - - /** - * API name: {@code format} - */ - public final Builder format(@Nullable String value) { - this.format = value; - return this; - } - - /** - * Builds a {@link FieldSort}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public FieldSort build() { - _checkSingleUse(); - - return new FieldSort(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link FieldSort} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - FieldSort::setupFieldSortDeserializer); - - protected static void setupFieldSortDeserializer(ObjectDeserializer op) { - - op.add(Builder::missing, FieldValue._DESERIALIZER, "missing"); - op.add(Builder::mode, SortMode._DESERIALIZER, "mode"); - op.add(Builder::nested, NestedSortValue._DESERIALIZER, "nested"); - op.add(Builder::order, SortOrder._DESERIALIZER, "order"); - op.add(Builder::unmappedType, FieldType._DESERIALIZER, "unmapped_type"); - op.add(Builder::numericType, FieldSortNumericType._DESERIALIZER, "numeric_type"); - op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format"); - - op.setKey(Builder::field, JsonpDeserializer.stringDeserializer()); - op.shortcutProperty("order"); - - } + // Single key dictionary + private final String field; + + @Nullable + private final FieldValue missing; + + @Nullable + private final SortMode mode; + + @Nullable + private final NestedSortValue nested; + + @Nullable + private final SortOrder order; + + @Nullable + private final FieldType unmappedType; + + @Nullable + private final FieldSortNumericType numericType; + + @Nullable + private final String format; + + // --------------------------------------------------------------------------------------------- + + private FieldSort(Builder builder) { + + this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); + + this.missing = builder.missing; + this.mode = builder.mode; + this.nested = builder.nested; + this.order = builder.order; + this.unmappedType = builder.unmappedType; + this.numericType = builder.numericType; + this.format = builder.format; + + } + + public static FieldSort of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - The target field + */ + public final String field() { + return this.field; + } + + /** + * API name: {@code missing} + */ + @Nullable + public final FieldValue missing() { + return this.missing; + } + + /** + * API name: {@code mode} + */ + @Nullable + public final SortMode mode() { + return this.mode; + } + + /** + * API name: {@code nested} + */ + @Nullable + public final NestedSortValue nested() { + return this.nested; + } + + /** + * API name: {@code order} + */ + @Nullable + public final SortOrder order() { + return this.order; + } + + /** + * API name: {@code unmapped_type} + */ + @Nullable + public final FieldType unmappedType() { + return this.unmappedType; + } + + /** + * API name: {@code numeric_type} + */ + @Nullable + public final FieldSortNumericType numericType() { + return this.numericType; + } + + /** + * API name: {@code format} + */ + @Nullable + public final String format() { + return this.format; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(this.field); + + if (this.missing != null) { + generator.writeKey("missing"); + this.missing.serialize(generator, mapper); + + } + if (this.mode != null) { + generator.writeKey("mode"); + this.mode.serialize(generator, mapper); + } + if (this.nested != null) { + generator.writeKey("nested"); + this.nested.serialize(generator, mapper); + + } + if (this.order != null) { + generator.writeKey("order"); + this.order.serialize(generator, mapper); + } + if (this.unmappedType != null) { + generator.writeKey("unmapped_type"); + this.unmappedType.serialize(generator, mapper); + } + if (this.numericType != null) { + generator.writeKey("numeric_type"); + this.numericType.serialize(generator, mapper); + } + if (this.format != null) { + generator.writeKey("format"); + generator.write(this.format); + + } + + generator.writeEnd(); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link FieldSort}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String field; + + /** + * Required - The target field + */ + public final Builder field(String value) { + this.field = value; + return this; + } + + @Nullable + private FieldValue missing; + + @Nullable + private SortMode mode; + + @Nullable + private NestedSortValue nested; + + @Nullable + private SortOrder order; + + @Nullable + private FieldType unmappedType; + + @Nullable + private FieldSortNumericType numericType; + + @Nullable + private String format; + + /** + * API name: {@code missing} + */ + public final Builder missing(@Nullable FieldValue value) { + this.missing = value; + return this; + } + + /** + * API name: {@code missing} + */ + public final Builder missing(Function> fn) { + return this.missing(fn.apply(new FieldValue.Builder()).build()); + } + + /** + * API name: {@code mode} + */ + public final Builder mode(@Nullable SortMode value) { + this.mode = value; + return this; + } + + /** + * API name: {@code nested} + */ + public final Builder nested(@Nullable NestedSortValue value) { + this.nested = value; + return this; + } + + /** + * API name: {@code nested} + */ + public final Builder nested(Function> fn) { + return this.nested(fn.apply(new NestedSortValue.Builder()).build()); + } + + /** + * API name: {@code order} + */ + public final Builder order(@Nullable SortOrder value) { + this.order = value; + return this; + } + + /** + * API name: {@code unmapped_type} + */ + public final Builder unmappedType(@Nullable FieldType value) { + this.unmappedType = value; + return this; + } + + /** + * API name: {@code numeric_type} + */ + public final Builder numericType(@Nullable FieldSortNumericType value) { + this.numericType = value; + return this; + } + + /** + * API name: {@code format} + */ + public final Builder format(@Nullable String value) { + this.format = value; + return this; + } + + /** + * Builds a {@link FieldSort}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public FieldSort build() { + _checkSingleUse(); + + return new FieldSort(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link FieldSort} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + FieldSort::setupFieldSortDeserializer + ); + + protected static void setupFieldSortDeserializer(ObjectDeserializer op) { + + op.add(Builder::missing, FieldValue._DESERIALIZER, "missing"); + op.add(Builder::mode, SortMode._DESERIALIZER, "mode"); + op.add(Builder::nested, NestedSortValue._DESERIALIZER, "nested"); + op.add(Builder::order, SortOrder._DESERIALIZER, "order"); + op.add(Builder::unmappedType, FieldType._DESERIALIZER, "unmapped_type"); + op.add(Builder::numericType, FieldSortNumericType._DESERIALIZER, "numeric_type"); + op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format"); + + op.setKey(Builder::field, JsonpDeserializer.stringDeserializer()); + op.shortcutProperty("order"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSortNumericType.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSortNumericType.java index 6bd4a708af..faf7f9d667 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSortNumericType.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldSortNumericType.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,26 +37,27 @@ @JsonpDeserializable public enum FieldSortNumericType implements JsonEnum { - Long("long"), + Long("long"), - Double("double"), + Double("double"), - Date("date"), + Date("date"), - DateNanos("date_nanos"), + DateNanos("date_nanos"), - ; + ; - private final String jsonValue; + private final String jsonValue; - FieldSortNumericType(String jsonValue) { - this.jsonValue = jsonValue; - } + FieldSortNumericType(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( - FieldSortNumericType.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + FieldSortNumericType.values() + ); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldValue.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldValue.java index 5768be9576..fbf6808921 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldValue.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FieldValue.java @@ -30,12 +30,12 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import jakarta.json.stream.JsonParser; +import java.util.EnumSet; +import java.util.function.Consumer; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,245 +45,250 @@ import org.opensearch.client.util.ObjectBuilderBase; import org.opensearch.client.util.TaggedUnion; import org.opensearch.client.util.TaggedUnionUtils; -import jakarta.json.stream.JsonGenerator; -import jakarta.json.stream.JsonParser; - -import java.util.EnumSet; -import java.util.function.Consumer; // typedef: _types.FieldValue @JsonpDeserializable public class FieldValue implements TaggedUnion, JsonpSerializable { - public static FieldValue of(long value) { - return new FieldValue(Kind.Long, value); - } - - public static FieldValue of(double value) { - return new FieldValue(Kind.Double, value); - } - - public static FieldValue of(boolean value) { - return value ? TRUE : FALSE; - } - - public static FieldValue of(String value) { - return new FieldValue(Kind.String, value); - } - - public static final FieldValue NULL = new FieldValue(Kind.Null, null); - public static final FieldValue TRUE = new FieldValue(Kind.Boolean, Boolean.TRUE); - public static final FieldValue FALSE = new FieldValue(Kind.Boolean, Boolean.FALSE); - - public enum Kind { - Double, Long, Boolean, String, Null - } - - private final Kind _kind; - private final Object _value; - - @Override - public final Kind _kind() { - return _kind; - } - - @Override - public final Object _get() { - return _value; - } - - public String _toJsonString() { - switch (_kind) { - case Double : - return String.valueOf(this.doubleValue()); - case Long : - return String.valueOf(this.longValue()); - case Boolean : - return String.valueOf(this.booleanValue()); - case String : - return this.stringValue(); - case Null : - return "null"; - - default : - throw new IllegalStateException("Unknown kind " + _kind); - } - } - - private FieldValue(Builder builder) { - this(builder._kind, builder._value); - } - - private FieldValue(Kind kind, Object value) { - this._kind = ApiTypeHelper.requireNonNull(kind, this, ""); - this._value = kind == Kind.Null ? null : ApiTypeHelper.requireNonNull(value, this, ""); - } - - public static FieldValue of(Consumer fn) { - Builder builder = new Builder(); - fn.accept(builder); - return builder.build(); - } - - /** - * Is this variant instance of kind {@code double}? - */ - public boolean isDouble() { - return _kind == Kind.Double; - } - - /** - * Get the {@code double} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code double} kind. - */ - public double doubleValue() { - return TaggedUnionUtils.get(this, Kind.Double); - } - - /** - * Is this variant instance of kind {@code long}? - */ - public boolean isLong() { - return _kind == Kind.Long; - } - - /** - * Get the {@code long} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code long} kind. - */ - public long longValue() { - return TaggedUnionUtils.get(this, Kind.Long); - } - - /** - * Is this variant instance of kind {@code boolean}? - */ - public boolean isBoolean() { - return _kind == Kind.Boolean; - } - - /** - * Get the {@code boolean} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code boolean} kind. - */ - public boolean booleanValue() { - return TaggedUnionUtils.get(this, Kind.Boolean); - } - - /** - * Is this variant instance of kind {@code string}? - */ - public boolean isString() { - return _kind == Kind.String; - } - - /** - * Get the {@code string} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code string} kind. - */ - public String stringValue() { - return TaggedUnionUtils.get(this, Kind.String); - } - - /** - * Is this variant instance of kind {@code null}? - */ - public boolean isNull() { - return _kind == Kind.Null; - } - - @Override - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - switch (_kind) { - case Double : - generator.write(((Double) this._value)); - break; - case Long : - generator.write(((Long) this._value)); - break; - case Boolean : - generator.write(((Boolean) this._value)); - break; - case String : - generator.write(((String) this._value)); - break; - case Null : - generator.writeNull(); - break; - } - } - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Kind _kind; - private Object _value; - - public ObjectBuilder doubleValue(double v) { - this._kind = Kind.Double; - this._value = v; - return this; - } - - public ObjectBuilder longValue(long v) { - this._kind = Kind.Long; - this._value = v; - return this; - } - - public ObjectBuilder booleanValue(boolean v) { - this._kind = Kind.Boolean; - this._value = v; - return this; - } - - public ObjectBuilder stringValue(String v) { - this._kind = Kind.String; - this._value = v; - return this; - } - - public ObjectBuilder nullValue() { - this._kind = Kind.Null; - this._value = null; - return this; - } - - public FieldValue build() { - _checkSingleUse(); - return new FieldValue(this); - } - } - - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer - .lazy(() -> JsonpDeserializer.of( - EnumSet.of(JsonParser.Event.VALUE_STRING, JsonParser.Event.VALUE_NUMBER, - JsonParser.Event.VALUE_NULL, - JsonParser.Event.VALUE_TRUE, JsonParser.Event.VALUE_FALSE), - (parser, mapper, event) -> { - switch (event) { - case VALUE_NULL : - return NULL; - case VALUE_STRING : - return FieldValue.of(parser.getString()); - case VALUE_TRUE : - return FieldValue.of(true); - case VALUE_FALSE : - return FieldValue.of(false); - case VALUE_NUMBER : - if (parser.isIntegralNumber()) { - return FieldValue.of(parser.getLong()); - } else { - return FieldValue.of(parser.getBigDecimal().doubleValue()); - } - } - return null; - })); + public static FieldValue of(long value) { + return new FieldValue(Kind.Long, value); + } + + public static FieldValue of(double value) { + return new FieldValue(Kind.Double, value); + } + + public static FieldValue of(boolean value) { + return value ? TRUE : FALSE; + } + + public static FieldValue of(String value) { + return new FieldValue(Kind.String, value); + } + + public static final FieldValue NULL = new FieldValue(Kind.Null, null); + public static final FieldValue TRUE = new FieldValue(Kind.Boolean, Boolean.TRUE); + public static final FieldValue FALSE = new FieldValue(Kind.Boolean, Boolean.FALSE); + + public enum Kind { + Double, + Long, + Boolean, + String, + Null + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + public String _toJsonString() { + switch (_kind) { + case Double: + return String.valueOf(this.doubleValue()); + case Long: + return String.valueOf(this.longValue()); + case Boolean: + return String.valueOf(this.booleanValue()); + case String: + return this.stringValue(); + case Null: + return "null"; + + default: + throw new IllegalStateException("Unknown kind " + _kind); + } + } + + private FieldValue(Builder builder) { + this(builder._kind, builder._value); + } + + private FieldValue(Kind kind, Object value) { + this._kind = ApiTypeHelper.requireNonNull(kind, this, ""); + this._value = kind == Kind.Null ? null : ApiTypeHelper.requireNonNull(value, this, ""); + } + + public static FieldValue of(Consumer fn) { + Builder builder = new Builder(); + fn.accept(builder); + return builder.build(); + } + + /** + * Is this variant instance of kind {@code double}? + */ + public boolean isDouble() { + return _kind == Kind.Double; + } + + /** + * Get the {@code double} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code double} kind. + */ + public double doubleValue() { + return TaggedUnionUtils.get(this, Kind.Double); + } + + /** + * Is this variant instance of kind {@code long}? + */ + public boolean isLong() { + return _kind == Kind.Long; + } + + /** + * Get the {@code long} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code long} kind. + */ + public long longValue() { + return TaggedUnionUtils.get(this, Kind.Long); + } + + /** + * Is this variant instance of kind {@code boolean}? + */ + public boolean isBoolean() { + return _kind == Kind.Boolean; + } + + /** + * Get the {@code boolean} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code boolean} kind. + */ + public boolean booleanValue() { + return TaggedUnionUtils.get(this, Kind.Boolean); + } + + /** + * Is this variant instance of kind {@code string}? + */ + public boolean isString() { + return _kind == Kind.String; + } + + /** + * Get the {@code string} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code string} kind. + */ + public String stringValue() { + return TaggedUnionUtils.get(this, Kind.String); + } + + /** + * Is this variant instance of kind {@code null}? + */ + public boolean isNull() { + return _kind == Kind.Null; + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + switch (_kind) { + case Double: + generator.write(((Double) this._value)); + break; + case Long: + generator.write(((Long) this._value)); + break; + case Boolean: + generator.write(((Boolean) this._value)); + break; + case String: + generator.write(((String) this._value)); + break; + case Null: + generator.writeNull(); + break; + } + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder doubleValue(double v) { + this._kind = Kind.Double; + this._value = v; + return this; + } + + public ObjectBuilder longValue(long v) { + this._kind = Kind.Long; + this._value = v; + return this; + } + + public ObjectBuilder booleanValue(boolean v) { + this._kind = Kind.Boolean; + this._value = v; + return this; + } + + public ObjectBuilder stringValue(String v) { + this._kind = Kind.String; + this._value = v; + return this; + } + + public ObjectBuilder nullValue() { + this._kind = Kind.Null; + this._value = null; + return this; + } + + public FieldValue build() { + _checkSingleUse(); + return new FieldValue(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy( + () -> JsonpDeserializer.of( + EnumSet.of( + JsonParser.Event.VALUE_STRING, + JsonParser.Event.VALUE_NUMBER, + JsonParser.Event.VALUE_NULL, + JsonParser.Event.VALUE_TRUE, + JsonParser.Event.VALUE_FALSE + ), + (parser, mapper, event) -> { + switch (event) { + case VALUE_NULL: + return NULL; + case VALUE_STRING: + return FieldValue.of(parser.getString()); + case VALUE_TRUE: + return FieldValue.of(true); + case VALUE_FALSE: + return FieldValue.of(false); + case VALUE_NUMBER: + if (parser.isIntegralNumber()) { + return FieldValue.of(parser.getLong()); + } else { + return FieldValue.of(parser.getBigDecimal().doubleValue()); + } + } + return null; + } + ) + ); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FielddataStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FielddataStats.java index 9a281d4463..ece673c2b5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FielddataStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FielddataStats.java @@ -30,12 +30,12 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,208 +45,205 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.FielddataStats @JsonpDeserializable public class FielddataStats implements JsonpSerializable { - @Nullable - private final Long evictions; + @Nullable + private final Long evictions; - @Nullable - private final String memorySize; + @Nullable + private final String memorySize; - private final long memorySizeInBytes; + private final long memorySizeInBytes; - private final Map fields; + private final Map fields; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - private FielddataStats(Builder builder) { + private FielddataStats(Builder builder) { - this.evictions = builder.evictions; - this.memorySize = builder.memorySize; - this.memorySizeInBytes = ApiTypeHelper.requireNonNull(builder.memorySizeInBytes, this, "memorySizeInBytes"); - this.fields = ApiTypeHelper.unmodifiable(builder.fields); + this.evictions = builder.evictions; + this.memorySize = builder.memorySize; + this.memorySizeInBytes = ApiTypeHelper.requireNonNull(builder.memorySizeInBytes, this, "memorySizeInBytes"); + this.fields = ApiTypeHelper.unmodifiable(builder.fields); - } - - public static FielddataStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code evictions} - */ - @Nullable - public final Long evictions() { - return this.evictions; - } - - /** - * API name: {@code memory_size} - */ - @Nullable - public final String memorySize() { - return this.memorySize; - } - - /** - * Required - API name: {@code memory_size_in_bytes} - */ - public final long memorySizeInBytes() { - return this.memorySizeInBytes; - } - - /** - * API name: {@code fields} - */ - public final Map fields() { - return this.fields; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (this.evictions != null) { - generator.writeKey("evictions"); - generator.write(this.evictions); - - } - if (this.memorySize != null) { - generator.writeKey("memory_size"); - generator.write(this.memorySize); - - } - generator.writeKey("memory_size_in_bytes"); - generator.write(this.memorySizeInBytes); - - if (ApiTypeHelper.isDefined(this.fields)) { - generator.writeKey("fields"); - generator.writeStartObject(); - for (Map.Entry item0 : this.fields.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link FielddataStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private Long evictions; - - @Nullable - private String memorySize; - - private Long memorySizeInBytes; - - @Nullable - private Map fields; - - /** - * API name: {@code evictions} - */ - public final Builder evictions(@Nullable Long value) { - this.evictions = value; - return this; - } - - /** - * API name: {@code memory_size} - */ - public final Builder memorySize(@Nullable String value) { - this.memorySize = value; - return this; - } - - /** - * Required - API name: {@code memory_size_in_bytes} - */ - public final Builder memorySizeInBytes(long value) { - this.memorySizeInBytes = value; - return this; - } - - /** - * API name: {@code fields} - *

- * Adds all entries of map to fields. - */ - public final Builder fields(Map map) { - this.fields = _mapPutAll(this.fields, map); - return this; - } - - /** - * API name: {@code fields} - *

- * Adds an entry to fields. - */ - public final Builder fields(String key, FieldMemoryUsage value) { - this.fields = _mapPut(this.fields, key, value); - return this; - } - - /** - * API name: {@code fields} - *

- * Adds an entry to fields using a builder lambda. - */ - public final Builder fields(String key, - Function> fn) { - return fields(key, fn.apply(new FieldMemoryUsage.Builder()).build()); - } - - /** - * Builds a {@link FielddataStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public FielddataStats build() { - _checkSingleUse(); - - return new FielddataStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link FielddataStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - FielddataStats::setupFielddataStatsDeserializer); - - protected static void setupFielddataStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::evictions, JsonpDeserializer.longDeserializer(), "evictions"); - op.add(Builder::memorySize, JsonpDeserializer.stringDeserializer(), "memory_size"); - op.add(Builder::memorySizeInBytes, JsonpDeserializer.longDeserializer(), "memory_size_in_bytes"); - op.add(Builder::fields, JsonpDeserializer.stringMapDeserializer(FieldMemoryUsage._DESERIALIZER), "fields"); - - } + } + + public static FielddataStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code evictions} + */ + @Nullable + public final Long evictions() { + return this.evictions; + } + + /** + * API name: {@code memory_size} + */ + @Nullable + public final String memorySize() { + return this.memorySize; + } + + /** + * Required - API name: {@code memory_size_in_bytes} + */ + public final long memorySizeInBytes() { + return this.memorySizeInBytes; + } + + /** + * API name: {@code fields} + */ + public final Map fields() { + return this.fields; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.evictions != null) { + generator.writeKey("evictions"); + generator.write(this.evictions); + + } + if (this.memorySize != null) { + generator.writeKey("memory_size"); + generator.write(this.memorySize); + + } + generator.writeKey("memory_size_in_bytes"); + generator.write(this.memorySizeInBytes); + + if (ApiTypeHelper.isDefined(this.fields)) { + generator.writeKey("fields"); + generator.writeStartObject(); + for (Map.Entry item0 : this.fields.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link FielddataStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private Long evictions; + + @Nullable + private String memorySize; + + private Long memorySizeInBytes; + + @Nullable + private Map fields; + + /** + * API name: {@code evictions} + */ + public final Builder evictions(@Nullable Long value) { + this.evictions = value; + return this; + } + + /** + * API name: {@code memory_size} + */ + public final Builder memorySize(@Nullable String value) { + this.memorySize = value; + return this; + } + + /** + * Required - API name: {@code memory_size_in_bytes} + */ + public final Builder memorySizeInBytes(long value) { + this.memorySizeInBytes = value; + return this; + } + + /** + * API name: {@code fields} + *

+ * Adds all entries of map to fields. + */ + public final Builder fields(Map map) { + this.fields = _mapPutAll(this.fields, map); + return this; + } + + /** + * API name: {@code fields} + *

+ * Adds an entry to fields. + */ + public final Builder fields(String key, FieldMemoryUsage value) { + this.fields = _mapPut(this.fields, key, value); + return this; + } + + /** + * API name: {@code fields} + *

+ * Adds an entry to fields using a builder lambda. + */ + public final Builder fields(String key, Function> fn) { + return fields(key, fn.apply(new FieldMemoryUsage.Builder()).build()); + } + + /** + * Builds a {@link FielddataStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public FielddataStats build() { + _checkSingleUse(); + + return new FielddataStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link FielddataStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + FielddataStats::setupFielddataStatsDeserializer + ); + + protected static void setupFielddataStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::evictions, JsonpDeserializer.longDeserializer(), "evictions"); + op.add(Builder::memorySize, JsonpDeserializer.stringDeserializer(), "memory_size"); + op.add(Builder::memorySizeInBytes, JsonpDeserializer.longDeserializer(), "memory_size_in_bytes"); + op.add(Builder::fields, JsonpDeserializer.stringMapDeserializer(FieldMemoryUsage._DESERIALIZER), "fields"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FlushStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FlushStats.java index 1121776140..709cc8f81e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/FlushStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/FlushStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,170 +44,169 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.FlushStats @JsonpDeserializable public class FlushStats implements JsonpSerializable { - private final long periodic; + private final long periodic; - private final long total; + private final long total; - @Nullable - private final String totalTime; + @Nullable + private final String totalTime; - private final long totalTimeInMillis; + private final long totalTimeInMillis; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - private FlushStats(Builder builder) { + private FlushStats(Builder builder) { - this.periodic = ApiTypeHelper.requireNonNull(builder.periodic, this, "periodic"); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - this.totalTime = builder.totalTime; - this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); - - } - - public static FlushStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code periodic} - */ - public final long periodic() { - return this.periodic; - } - - /** - * Required - API name: {@code total} - */ - public final long total() { - return this.total; - } - - /** - * API name: {@code total_time} - */ - @Nullable - public final String totalTime() { - return this.totalTime; - } - - /** - * Required - API name: {@code total_time_in_millis} - */ - public final long totalTimeInMillis() { - return this.totalTimeInMillis; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("periodic"); - generator.write(this.periodic); - - generator.writeKey("total"); - generator.write(this.total); - - if (this.totalTime != null) { - generator.writeKey("total_time"); - generator.write(this.totalTime); - - } - generator.writeKey("total_time_in_millis"); - generator.write(this.totalTimeInMillis); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link FlushStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long periodic; - - private Long total; - - @Nullable - private String totalTime; - - private Long totalTimeInMillis; - - /** - * Required - API name: {@code periodic} - */ - public final Builder periodic(long value) { - this.periodic = value; - return this; - } - - /** - * Required - API name: {@code total} - */ - public final Builder total(long value) { - this.total = value; - return this; - } - - /** - * API name: {@code total_time} - */ - public final Builder totalTime(@Nullable String value) { - this.totalTime = value; - return this; - } - - /** - * Required - API name: {@code total_time_in_millis} - */ - public final Builder totalTimeInMillis(long value) { - this.totalTimeInMillis = value; - return this; - } - - /** - * Builds a {@link FlushStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public FlushStats build() { - _checkSingleUse(); - - return new FlushStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link FlushStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - FlushStats::setupFlushStatsDeserializer); - - protected static void setupFlushStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::periodic, JsonpDeserializer.longDeserializer(), "periodic"); - op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); - op.add(Builder::totalTime, JsonpDeserializer.stringDeserializer(), "total_time"); - op.add(Builder::totalTimeInMillis, JsonpDeserializer.longDeserializer(), "total_time_in_millis"); - - } + this.periodic = ApiTypeHelper.requireNonNull(builder.periodic, this, "periodic"); + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); + this.totalTime = builder.totalTime; + this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); + + } + + public static FlushStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code periodic} + */ + public final long periodic() { + return this.periodic; + } + + /** + * Required - API name: {@code total} + */ + public final long total() { + return this.total; + } + + /** + * API name: {@code total_time} + */ + @Nullable + public final String totalTime() { + return this.totalTime; + } + + /** + * Required - API name: {@code total_time_in_millis} + */ + public final long totalTimeInMillis() { + return this.totalTimeInMillis; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("periodic"); + generator.write(this.periodic); + + generator.writeKey("total"); + generator.write(this.total); + + if (this.totalTime != null) { + generator.writeKey("total_time"); + generator.write(this.totalTime); + + } + generator.writeKey("total_time_in_millis"); + generator.write(this.totalTimeInMillis); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link FlushStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long periodic; + + private Long total; + + @Nullable + private String totalTime; + + private Long totalTimeInMillis; + + /** + * Required - API name: {@code periodic} + */ + public final Builder periodic(long value) { + this.periodic = value; + return this; + } + + /** + * Required - API name: {@code total} + */ + public final Builder total(long value) { + this.total = value; + return this; + } + + /** + * API name: {@code total_time} + */ + public final Builder totalTime(@Nullable String value) { + this.totalTime = value; + return this; + } + + /** + * Required - API name: {@code total_time_in_millis} + */ + public final Builder totalTimeInMillis(long value) { + this.totalTimeInMillis = value; + return this; + } + + /** + * Builds a {@link FlushStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public FlushStats build() { + _checkSingleUse(); + + return new FlushStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link FlushStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + FlushStats::setupFlushStatsDeserializer + ); + + protected static void setupFlushStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::periodic, JsonpDeserializer.longDeserializer(), "periodic"); + op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); + op.add(Builder::totalTime, JsonpDeserializer.stringDeserializer(), "total_time"); + op.add(Builder::totalTimeInMillis, JsonpDeserializer.longDeserializer(), "total_time_in_millis"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoBounds.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoBounds.java index d3b430c712..56f23b35d9 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoBounds.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoBounds.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -46,8 +44,6 @@ import org.opensearch.client.util.ObjectBuilderBase; import org.opensearch.client.util.TaggedUnion; import org.opensearch.client.util.TaggedUnionUtils; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.GeoBounds @@ -64,177 +60,180 @@ @JsonpDeserializable public class GeoBounds implements TaggedUnion, JsonpSerializable { - public enum Kind { - Coords, Tlbr, Trbl, Wkt - - } - - private final Kind _kind; - private final Object _value; - - @Override - public final Kind _kind() { - return _kind; - } - - @Override - public final Object _get() { - return _value; - } - - private GeoBounds(Kind kind, Object value) { - this._kind = kind; - this._value = value; - } - - private GeoBounds(Builder builder) { - - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); - this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - - } - - public static GeoBounds of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Is this variant instance of kind {@code coords}? - */ - public boolean isCoords() { - return _kind == Kind.Coords; - } - - /** - * Get the {@code coords} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code coords} kind. - */ - public CoordsGeoBounds coords() { - return TaggedUnionUtils.get(this, Kind.Coords); - } - - /** - * Is this variant instance of kind {@code tlbr}? - */ - public boolean isTlbr() { - return _kind == Kind.Tlbr; - } - - /** - * Get the {@code tlbr} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code tlbr} kind. - */ - public TopLeftBottomRightGeoBounds tlbr() { - return TaggedUnionUtils.get(this, Kind.Tlbr); - } - - /** - * Is this variant instance of kind {@code trbl}? - */ - public boolean isTrbl() { - return _kind == Kind.Trbl; - } - - /** - * Get the {@code trbl} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code trbl} kind. - */ - public TopRightBottomLeftGeoBounds trbl() { - return TaggedUnionUtils.get(this, Kind.Trbl); - } - - /** - * Is this variant instance of kind {@code wkt}? - */ - public boolean isWkt() { - return _kind == Kind.Wkt; - } - - /** - * Get the {@code wkt} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code wkt} kind. - */ - public WktGeoBounds wkt() { - return TaggedUnionUtils.get(this, Kind.Wkt); - } - - @Override - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - if (_value instanceof JsonpSerializable) { - ((JsonpSerializable) _value).serialize(generator, mapper); - } - - } - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Kind _kind; - private Object _value; - - public ObjectBuilder coords(CoordsGeoBounds v) { - this._kind = Kind.Coords; - this._value = v; - return this; - } - - public ObjectBuilder coords(Function> fn) { - return this.coords(fn.apply(new CoordsGeoBounds.Builder()).build()); - } - - public ObjectBuilder tlbr(TopLeftBottomRightGeoBounds v) { - this._kind = Kind.Tlbr; - this._value = v; - return this; - } - - public ObjectBuilder tlbr( - Function> fn) { - return this.tlbr(fn.apply(new TopLeftBottomRightGeoBounds.Builder()).build()); - } - - public ObjectBuilder trbl(TopRightBottomLeftGeoBounds v) { - this._kind = Kind.Trbl; - this._value = v; - return this; - } - - public ObjectBuilder trbl( - Function> fn) { - return this.trbl(fn.apply(new TopRightBottomLeftGeoBounds.Builder()).build()); - } - - public ObjectBuilder wkt(WktGeoBounds v) { - this._kind = Kind.Wkt; - this._value = v; - return this; - } - - public ObjectBuilder wkt(Function> fn) { - return this.wkt(fn.apply(new WktGeoBounds.Builder()).build()); - } - - public GeoBounds build() { - _checkSingleUse(); - return new GeoBounds(this); - } - - } - - private static JsonpDeserializer buildGeoBoundsDeserializer() { - return new UnionDeserializer.Builder(GeoBounds::new, false) - .addMember(Kind.Coords, CoordsGeoBounds._DESERIALIZER) - .addMember(Kind.Tlbr, TopLeftBottomRightGeoBounds._DESERIALIZER) - .addMember(Kind.Trbl, TopRightBottomLeftGeoBounds._DESERIALIZER) - .addMember(Kind.Wkt, WktGeoBounds._DESERIALIZER).build(); - } - - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer - .lazy(GeoBounds::buildGeoBoundsDeserializer); + public enum Kind { + Coords, + Tlbr, + Trbl, + Wkt + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private GeoBounds(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + private GeoBounds(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static GeoBounds of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code coords}? + */ + public boolean isCoords() { + return _kind == Kind.Coords; + } + + /** + * Get the {@code coords} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code coords} kind. + */ + public CoordsGeoBounds coords() { + return TaggedUnionUtils.get(this, Kind.Coords); + } + + /** + * Is this variant instance of kind {@code tlbr}? + */ + public boolean isTlbr() { + return _kind == Kind.Tlbr; + } + + /** + * Get the {@code tlbr} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code tlbr} kind. + */ + public TopLeftBottomRightGeoBounds tlbr() { + return TaggedUnionUtils.get(this, Kind.Tlbr); + } + + /** + * Is this variant instance of kind {@code trbl}? + */ + public boolean isTrbl() { + return _kind == Kind.Trbl; + } + + /** + * Get the {@code trbl} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code trbl} kind. + */ + public TopRightBottomLeftGeoBounds trbl() { + return TaggedUnionUtils.get(this, Kind.Trbl); + } + + /** + * Is this variant instance of kind {@code wkt}? + */ + public boolean isWkt() { + return _kind == Kind.Wkt; + } + + /** + * Get the {@code wkt} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code wkt} kind. + */ + public WktGeoBounds wkt() { + return TaggedUnionUtils.get(this, Kind.Wkt); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } + + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder coords(CoordsGeoBounds v) { + this._kind = Kind.Coords; + this._value = v; + return this; + } + + public ObjectBuilder coords(Function> fn) { + return this.coords(fn.apply(new CoordsGeoBounds.Builder()).build()); + } + + public ObjectBuilder tlbr(TopLeftBottomRightGeoBounds v) { + this._kind = Kind.Tlbr; + this._value = v; + return this; + } + + public ObjectBuilder tlbr(Function> fn) { + return this.tlbr(fn.apply(new TopLeftBottomRightGeoBounds.Builder()).build()); + } + + public ObjectBuilder trbl(TopRightBottomLeftGeoBounds v) { + this._kind = Kind.Trbl; + this._value = v; + return this; + } + + public ObjectBuilder trbl(Function> fn) { + return this.trbl(fn.apply(new TopRightBottomLeftGeoBounds.Builder()).build()); + } + + public ObjectBuilder wkt(WktGeoBounds v) { + this._kind = Kind.Wkt; + this._value = v; + return this; + } + + public ObjectBuilder wkt(Function> fn) { + return this.wkt(fn.apply(new WktGeoBounds.Builder()).build()); + } + + public GeoBounds build() { + _checkSingleUse(); + return new GeoBounds(this); + } + + } + + private static JsonpDeserializer buildGeoBoundsDeserializer() { + return new UnionDeserializer.Builder(GeoBounds::new, false).addMember( + Kind.Coords, + CoordsGeoBounds._DESERIALIZER + ) + .addMember(Kind.Tlbr, TopLeftBottomRightGeoBounds._DESERIALIZER) + .addMember(Kind.Trbl, TopRightBottomLeftGeoBounds._DESERIALIZER) + .addMember(Kind.Wkt, WktGeoBounds._DESERIALIZER) + .build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy(GeoBounds::buildGeoBoundsDeserializer); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoBoundsBuilders.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoBoundsBuilders.java index d88419df30..614522f557 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoBoundsBuilders.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoBoundsBuilders.java @@ -30,48 +30,43 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; /** * Builders for {@link GeoBounds} variants. */ public class GeoBoundsBuilders { - private GeoBoundsBuilders() { - } + private GeoBoundsBuilders() {} - /** - * Creates a builder for the {@link CoordsGeoBounds coords} {@code GeoBounds} - * variant. - */ - public static CoordsGeoBounds.Builder coords() { - return new CoordsGeoBounds.Builder(); - } + /** + * Creates a builder for the {@link CoordsGeoBounds coords} {@code GeoBounds} + * variant. + */ + public static CoordsGeoBounds.Builder coords() { + return new CoordsGeoBounds.Builder(); + } - /** - * Creates a builder for the {@link TopLeftBottomRightGeoBounds tlbr} - * {@code GeoBounds} variant. - */ - public static TopLeftBottomRightGeoBounds.Builder tlbr() { - return new TopLeftBottomRightGeoBounds.Builder(); - } + /** + * Creates a builder for the {@link TopLeftBottomRightGeoBounds tlbr} + * {@code GeoBounds} variant. + */ + public static TopLeftBottomRightGeoBounds.Builder tlbr() { + return new TopLeftBottomRightGeoBounds.Builder(); + } - /** - * Creates a builder for the {@link TopRightBottomLeftGeoBounds trbl} - * {@code GeoBounds} variant. - */ - public static TopRightBottomLeftGeoBounds.Builder trbl() { - return new TopRightBottomLeftGeoBounds.Builder(); - } + /** + * Creates a builder for the {@link TopRightBottomLeftGeoBounds trbl} + * {@code GeoBounds} variant. + */ + public static TopRightBottomLeftGeoBounds.Builder trbl() { + return new TopRightBottomLeftGeoBounds.Builder(); + } - /** - * Creates a builder for the {@link WktGeoBounds wkt} {@code GeoBounds} variant. - */ - public static WktGeoBounds.Builder wkt() { - return new WktGeoBounds.Builder(); - } + /** + * Creates a builder for the {@link WktGeoBounds wkt} {@code GeoBounds} variant. + */ + public static WktGeoBounds.Builder wkt() { + return new WktGeoBounds.Builder(); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceSort.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceSort.java index 1921118748..6aaa338fb3 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceSort.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceSort.java @@ -30,12 +30,12 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,289 +45,286 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.GeoDistanceSort @JsonpDeserializable public class GeoDistanceSort implements SortOptionsVariant, JsonpSerializable { - private final String field; - - private final List location; - - @Nullable - private final SortMode mode; - - @Nullable - private final GeoDistanceType distanceType; - - @Nullable - private final Boolean ignoreUnmapped; - - @Nullable - private final SortOrder order; - - @Nullable - private final DistanceUnit unit; - - // --------------------------------------------------------------------------------------------- - - private GeoDistanceSort(Builder builder) { - - this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); - this.location = ApiTypeHelper.unmodifiableRequired(builder.location, this, "location"); - - this.mode = builder.mode; - this.distanceType = builder.distanceType; - this.ignoreUnmapped = builder.ignoreUnmapped; - this.order = builder.order; - this.unit = builder.unit; - - } - - public static GeoDistanceSort of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * SortOptions variant kind. - */ - @Override - public SortOptions.Kind _sortOptionsKind() { - return SortOptions.Kind.GeoDistance; - } - - /** - * Required - - */ - public final String field() { - return this.field; - } - - /** - * Required - - */ - public final List location() { - return this.location; - } - - /** - * API name: {@code mode} - */ - @Nullable - public final SortMode mode() { - return this.mode; - } - - /** - * API name: {@code distance_type} - */ - @Nullable - public final GeoDistanceType distanceType() { - return this.distanceType; - } - - /** - * API name: {@code ignore_unmapped} - */ - @Nullable - public final Boolean ignoreUnmapped() { - return this.ignoreUnmapped; - } - - /** - * API name: {@code order} - */ - @Nullable - public final SortOrder order() { - return this.order; - } - - /** - * API name: {@code unit} - */ - @Nullable - public final DistanceUnit unit() { - return this.unit; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey(this.field); - generator.writeStartArray(); - for (GeoLocation item0 : this.location) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - if (this.mode != null) { - generator.writeKey("mode"); - this.mode.serialize(generator, mapper); - } - if (this.distanceType != null) { - generator.writeKey("distance_type"); - this.distanceType.serialize(generator, mapper); - } - if (this.ignoreUnmapped != null) { - generator.writeKey("ignore_unmapped"); - generator.write(this.ignoreUnmapped); - - } - if (this.order != null) { - generator.writeKey("order"); - this.order.serialize(generator, mapper); - } - if (this.unit != null) { - generator.writeKey("unit"); - this.unit.serialize(generator, mapper); - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link GeoDistanceSort}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String field; - - private List location; - - /** - * Required - - */ - public final Builder field(String value) { - this.field = value; - return this; - } - - /** - * Required - Adds all elements of list to location. - */ - public final Builder location(List list) { - this.location = _listAddAll(this.location, list); - return this; - } - - /** - * Required - Adds one or more values to location. - */ - public final Builder location(GeoLocation value, GeoLocation... values) { - this.location = _listAdd(this.location, value, values); - return this; - } - - /** - * Required - Adds a value to location using a builder lambda. - */ - public final Builder location(Function> fn) { - return location(fn.apply(new GeoLocation.Builder()).build()); - } - - @Nullable - private SortMode mode; - - @Nullable - private GeoDistanceType distanceType; - - @Nullable - private Boolean ignoreUnmapped; - - @Nullable - private SortOrder order; - - @Nullable - private DistanceUnit unit; - - /** - * API name: {@code mode} - */ - public final Builder mode(@Nullable SortMode value) { - this.mode = value; - return this; - } - - /** - * API name: {@code distance_type} - */ - public final Builder distanceType(@Nullable GeoDistanceType value) { - this.distanceType = value; - return this; - } - - /** - * API name: {@code ignore_unmapped} - */ - public final Builder ignoreUnmapped(@Nullable Boolean value) { - this.ignoreUnmapped = value; - return this; - } - - /** - * API name: {@code order} - */ - public final Builder order(@Nullable SortOrder value) { - this.order = value; - return this; - } - - /** - * API name: {@code unit} - */ - public final Builder unit(@Nullable DistanceUnit value) { - this.unit = value; - return this; - } - - /** - * Builds a {@link GeoDistanceSort}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public GeoDistanceSort build() { - _checkSingleUse(); - - return new GeoDistanceSort(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link GeoDistanceSort} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - GeoDistanceSort::setupGeoDistanceSortDeserializer); - - protected static void setupGeoDistanceSortDeserializer(ObjectDeserializer op) { - - op.add(Builder::mode, SortMode._DESERIALIZER, "mode"); - op.add(Builder::distanceType, GeoDistanceType._DESERIALIZER, "distance_type"); - op.add(Builder::ignoreUnmapped, JsonpDeserializer.booleanDeserializer(), "ignore_unmapped"); - op.add(Builder::order, SortOrder._DESERIALIZER, "order"); - op.add(Builder::unit, DistanceUnit._DESERIALIZER, "unit"); - - op.setUnknownFieldHandler((builder, name, parser, mapper) -> { - builder.field(name); - builder.location( - JsonpDeserializer.arrayDeserializer(GeoLocation._DESERIALIZER).deserialize(parser, mapper)); - }); - - } + private final String field; + + private final List location; + + @Nullable + private final SortMode mode; + + @Nullable + private final GeoDistanceType distanceType; + + @Nullable + private final Boolean ignoreUnmapped; + + @Nullable + private final SortOrder order; + + @Nullable + private final DistanceUnit unit; + + // --------------------------------------------------------------------------------------------- + + private GeoDistanceSort(Builder builder) { + + this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); + this.location = ApiTypeHelper.unmodifiableRequired(builder.location, this, "location"); + + this.mode = builder.mode; + this.distanceType = builder.distanceType; + this.ignoreUnmapped = builder.ignoreUnmapped; + this.order = builder.order; + this.unit = builder.unit; + + } + + public static GeoDistanceSort of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * SortOptions variant kind. + */ + @Override + public SortOptions.Kind _sortOptionsKind() { + return SortOptions.Kind.GeoDistance; + } + + /** + * Required - + */ + public final String field() { + return this.field; + } + + /** + * Required - + */ + public final List location() { + return this.location; + } + + /** + * API name: {@code mode} + */ + @Nullable + public final SortMode mode() { + return this.mode; + } + + /** + * API name: {@code distance_type} + */ + @Nullable + public final GeoDistanceType distanceType() { + return this.distanceType; + } + + /** + * API name: {@code ignore_unmapped} + */ + @Nullable + public final Boolean ignoreUnmapped() { + return this.ignoreUnmapped; + } + + /** + * API name: {@code order} + */ + @Nullable + public final SortOrder order() { + return this.order; + } + + /** + * API name: {@code unit} + */ + @Nullable + public final DistanceUnit unit() { + return this.unit; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.writeKey(this.field); + generator.writeStartArray(); + for (GeoLocation item0 : this.location) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + if (this.mode != null) { + generator.writeKey("mode"); + this.mode.serialize(generator, mapper); + } + if (this.distanceType != null) { + generator.writeKey("distance_type"); + this.distanceType.serialize(generator, mapper); + } + if (this.ignoreUnmapped != null) { + generator.writeKey("ignore_unmapped"); + generator.write(this.ignoreUnmapped); + + } + if (this.order != null) { + generator.writeKey("order"); + this.order.serialize(generator, mapper); + } + if (this.unit != null) { + generator.writeKey("unit"); + this.unit.serialize(generator, mapper); + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GeoDistanceSort}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String field; + + private List location; + + /** + * Required - + */ + public final Builder field(String value) { + this.field = value; + return this; + } + + /** + * Required - Adds all elements of list to location. + */ + public final Builder location(List list) { + this.location = _listAddAll(this.location, list); + return this; + } + + /** + * Required - Adds one or more values to location. + */ + public final Builder location(GeoLocation value, GeoLocation... values) { + this.location = _listAdd(this.location, value, values); + return this; + } + + /** + * Required - Adds a value to location using a builder lambda. + */ + public final Builder location(Function> fn) { + return location(fn.apply(new GeoLocation.Builder()).build()); + } + + @Nullable + private SortMode mode; + + @Nullable + private GeoDistanceType distanceType; + + @Nullable + private Boolean ignoreUnmapped; + + @Nullable + private SortOrder order; + + @Nullable + private DistanceUnit unit; + + /** + * API name: {@code mode} + */ + public final Builder mode(@Nullable SortMode value) { + this.mode = value; + return this; + } + + /** + * API name: {@code distance_type} + */ + public final Builder distanceType(@Nullable GeoDistanceType value) { + this.distanceType = value; + return this; + } + + /** + * API name: {@code ignore_unmapped} + */ + public final Builder ignoreUnmapped(@Nullable Boolean value) { + this.ignoreUnmapped = value; + return this; + } + + /** + * API name: {@code order} + */ + public final Builder order(@Nullable SortOrder value) { + this.order = value; + return this; + } + + /** + * API name: {@code unit} + */ + public final Builder unit(@Nullable DistanceUnit value) { + this.unit = value; + return this; + } + + /** + * Builds a {@link GeoDistanceSort}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GeoDistanceSort build() { + _checkSingleUse(); + + return new GeoDistanceSort(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GeoDistanceSort} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + GeoDistanceSort::setupGeoDistanceSortDeserializer + ); + + protected static void setupGeoDistanceSortDeserializer(ObjectDeserializer op) { + + op.add(Builder::mode, SortMode._DESERIALIZER, "mode"); + op.add(Builder::distanceType, GeoDistanceType._DESERIALIZER, "distance_type"); + op.add(Builder::ignoreUnmapped, JsonpDeserializer.booleanDeserializer(), "ignore_unmapped"); + op.add(Builder::order, SortOrder._DESERIALIZER, "order"); + op.add(Builder::unit, DistanceUnit._DESERIALIZER, "unit"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + builder.field(name); + builder.location(JsonpDeserializer.arrayDeserializer(GeoLocation._DESERIALIZER).deserialize(parser, mapper)); + }); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceType.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceType.java index 2a209ae8e9..ff616f352f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceType.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceType.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,22 +37,21 @@ @JsonpDeserializable public enum GeoDistanceType implements JsonEnum { - Arc("arc"), + Arc("arc"), - Plane("plane"), + Plane("plane"), - ; + ; - private final String jsonValue; + private final String jsonValue; - GeoDistanceType(String jsonValue) { - this.jsonValue = jsonValue; - } + GeoDistanceType(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( - GeoDistanceType.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(GeoDistanceType.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashLocation.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashLocation.java index e611c2743e..ddb345f60d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashLocation.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashLocation.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,92 +43,92 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.GeoHashLocation @JsonpDeserializable public class GeoHashLocation implements JsonpSerializable { - private final String geohash; + private final String geohash; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - private GeoHashLocation(Builder builder) { + private GeoHashLocation(Builder builder) { - this.geohash = ApiTypeHelper.requireNonNull(builder.geohash, this, "geohash"); + this.geohash = ApiTypeHelper.requireNonNull(builder.geohash, this, "geohash"); - } + } - public static GeoHashLocation of(Function> fn) { - return fn.apply(new Builder()).build(); - } + public static GeoHashLocation of(Function> fn) { + return fn.apply(new Builder()).build(); + } - /** - * Required - API name: {@code geohash} - */ - public final String geohash() { - return this.geohash; - } + /** + * Required - API name: {@code geohash} + */ + public final String geohash() { + return this.geohash; + } - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("geohash"); - generator.write(this.geohash); + generator.writeKey("geohash"); + generator.write(this.geohash); - } + } - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - /** - * Builder for {@link GeoHashLocation}. - */ + /** + * Builder for {@link GeoHashLocation}. + */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String geohash; + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String geohash; - /** - * Required - API name: {@code geohash} - */ - public final Builder geohash(String value) { - this.geohash = value; - return this; - } + /** + * Required - API name: {@code geohash} + */ + public final Builder geohash(String value) { + this.geohash = value; + return this; + } - /** - * Builds a {@link GeoHashLocation}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public GeoHashLocation build() { - _checkSingleUse(); + /** + * Builds a {@link GeoHashLocation}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GeoHashLocation build() { + _checkSingleUse(); - return new GeoHashLocation(this); - } - } + return new GeoHashLocation(this); + } + } - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - /** - * Json deserializer for {@link GeoHashLocation} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - GeoHashLocation::setupGeoHashLocationDeserializer); + /** + * Json deserializer for {@link GeoHashLocation} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + GeoHashLocation::setupGeoHashLocationDeserializer + ); - protected static void setupGeoHashLocationDeserializer(ObjectDeserializer op) { + protected static void setupGeoHashLocationDeserializer(ObjectDeserializer op) { - op.add(Builder::geohash, JsonpDeserializer.stringDeserializer(), "geohash"); + op.add(Builder::geohash, JsonpDeserializer.stringDeserializer(), "geohash"); - } + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecision.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecision.java index 76bb272a68..0b25072c7e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecision.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecision.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -46,147 +44,148 @@ import org.opensearch.client.util.ObjectBuilderBase; import org.opensearch.client.util.TaggedUnion; import org.opensearch.client.util.TaggedUnionUtils; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.GeoHashPrecision /** * A precision that can be expressed as a geohash length between 1 and 12, or a * distance measure like "1km", "10m". - * + * */ @JsonpDeserializable public class GeoHashPrecision implements TaggedUnion, JsonpSerializable { - public enum Kind { - GeohashLength, Distance - - } - - private final Kind _kind; - private final Object _value; - - @Override - public final Kind _kind() { - return _kind; - } - - @Override - public final Object _get() { - return _value; - } - - private GeoHashPrecision(Kind kind, Object value) { - this._kind = kind; - this._value = value; - } - - public String _toJsonString() { - switch (_kind) { - case GeohashLength : - return this.geohashLength().toString(); - case Distance : - return this.distance(); - - default : - throw new IllegalStateException("Unknown kind " + _kind); - } - } - - private GeoHashPrecision(Builder builder) { - - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); - this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - - } - - public static GeoHashPrecision of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Is this variant instance of kind {@code geohash_length}? - */ - public boolean isGeohashLength() { - return _kind == Kind.GeohashLength; - } - - /** - * Get the {@code geohash_length} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code geohash_length} kind. - */ - public Number geohashLength() { - return TaggedUnionUtils.get(this, Kind.GeohashLength); - } - - /** - * Is this variant instance of kind {@code distance}? - */ - public boolean isDistance() { - return _kind == Kind.Distance; - } - - /** - * Get the {@code distance} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code distance} kind. - */ - public String distance() { - return TaggedUnionUtils.get(this, Kind.Distance); - } - - @Override - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - if (_value instanceof JsonpSerializable) { - ((JsonpSerializable) _value).serialize(generator, mapper); - } else { - switch (_kind) { - case GeohashLength : - generator.write(((Number) this._value).doubleValue()); - - break; - case Distance : - generator.write(((String) this._value)); - - break; - } - } - - } - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Kind _kind; - private Object _value; - - public ObjectBuilder geohashLength(Number v) { - this._kind = Kind.GeohashLength; - this._value = v; - return this; - } - - public ObjectBuilder distance(String v) { - this._kind = Kind.Distance; - this._value = v; - return this; - } - - public GeoHashPrecision build() { - _checkSingleUse(); - return new GeoHashPrecision(this); - } - - } - - private static JsonpDeserializer buildGeoHashPrecisionDeserializer() { - return new UnionDeserializer.Builder(GeoHashPrecision::new, false) - .addMember(Kind.GeohashLength, JsonpDeserializer.numberDeserializer()) - .addMember(Kind.Distance, JsonpDeserializer.stringDeserializer()).build(); - } - - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer - .lazy(GeoHashPrecision::buildGeoHashPrecisionDeserializer); + public enum Kind { + GeohashLength, + Distance + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private GeoHashPrecision(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + public String _toJsonString() { + switch (_kind) { + case GeohashLength: + return this.geohashLength().toString(); + case Distance: + return this.distance(); + + default: + throw new IllegalStateException("Unknown kind " + _kind); + } + } + + private GeoHashPrecision(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static GeoHashPrecision of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code geohash_length}? + */ + public boolean isGeohashLength() { + return _kind == Kind.GeohashLength; + } + + /** + * Get the {@code geohash_length} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code geohash_length} kind. + */ + public Number geohashLength() { + return TaggedUnionUtils.get(this, Kind.GeohashLength); + } + + /** + * Is this variant instance of kind {@code distance}? + */ + public boolean isDistance() { + return _kind == Kind.Distance; + } + + /** + * Get the {@code distance} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code distance} kind. + */ + public String distance() { + return TaggedUnionUtils.get(this, Kind.Distance); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } else { + switch (_kind) { + case GeohashLength: + generator.write(((Number) this._value).doubleValue()); + + break; + case Distance: + generator.write(((String) this._value)); + + break; + } + } + + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder geohashLength(Number v) { + this._kind = Kind.GeohashLength; + this._value = v; + return this; + } + + public ObjectBuilder distance(String v) { + this._kind = Kind.Distance; + this._value = v; + return this; + } + + public GeoHashPrecision build() { + _checkSingleUse(); + return new GeoHashPrecision(this); + } + + } + + private static JsonpDeserializer buildGeoHashPrecisionDeserializer() { + return new UnionDeserializer.Builder(GeoHashPrecision::new, false).addMember( + Kind.GeohashLength, + JsonpDeserializer.numberDeserializer() + ).addMember(Kind.Distance, JsonpDeserializer.stringDeserializer()).build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy( + GeoHashPrecision::buildGeoHashPrecisionDeserializer + ); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecisionBuilders.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecisionBuilders.java index db1421b611..be883f856f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecisionBuilders.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoHashPrecisionBuilders.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; /** @@ -42,10 +38,9 @@ * Variants geohash_length, distance are not available * here as they don't have a dedicated class. Use {@link GeoHashPrecision}'s * builder for these. - * + * */ public class GeoHashPrecisionBuilders { - private GeoHashPrecisionBuilders() { - } + private GeoHashPrecisionBuilders() {} } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLine.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLine.java index 6caa9c0b94..0b21c874f9 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLine.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLine.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,159 +44,161 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.function.Function; // typedef: _types.GeoLine /** * A GeoJson GeoLine. - * + * */ @JsonpDeserializable public class GeoLine implements JsonpSerializable { - private final String type; - - private final List> coordinates; - - // --------------------------------------------------------------------------------------------- - - private GeoLine(Builder builder) { - - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - this.coordinates = ApiTypeHelper.unmodifiableRequired(builder.coordinates, this, "coordinates"); - - } - - public static GeoLine of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - Always "LineString" - *

- * API name: {@code type} - */ - public final String type() { - return this.type; - } - - /** - * Required - Array of [lon, lat] coordinates - *

- * API name: {@code coordinates} - */ - public final List> coordinates() { - return this.coordinates; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("type"); - generator.write(this.type); - - if (ApiTypeHelper.isDefined(this.coordinates)) { - generator.writeKey("coordinates"); - generator.writeStartArray(); - for (List item0 : this.coordinates) { - generator.writeStartArray(); - if (item0 != null) { - for (Double item1 : item0) { - generator.write(item1); - - } - } - generator.writeEnd(); - - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link GeoLine}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String type; - - private List> coordinates; - - /** - * Required - Always "LineString" - *

- * API name: {@code type} - */ - public final Builder type(String value) { - this.type = value; - return this; - } - - /** - * Required - Array of [lon, lat] coordinates - *

- * API name: {@code coordinates} - *

- * Adds all elements of list to coordinates. - */ - public final Builder coordinates(List> list) { - this.coordinates = _listAddAll(this.coordinates, list); - return this; - } - - /** - * Required - Array of [lon, lat] coordinates - *

- * API name: {@code coordinates} - *

- * Adds one or more values to coordinates. - */ - public final Builder coordinates(List value, List... values) { - this.coordinates = _listAdd(this.coordinates, value, values); - return this; - } - - /** - * Builds a {@link GeoLine}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public GeoLine build() { - _checkSingleUse(); - - return new GeoLine(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link GeoLine} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - GeoLine::setupGeoLineDeserializer); - - protected static void setupGeoLineDeserializer(ObjectDeserializer op) { - - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - op.add(Builder::coordinates, JsonpDeserializer.arrayDeserializer( - JsonpDeserializer.arrayDeserializer(JsonpDeserializer.doubleDeserializer())), "coordinates"); - - } + private final String type; + + private final List> coordinates; + + // --------------------------------------------------------------------------------------------- + + private GeoLine(Builder builder) { + + this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); + this.coordinates = ApiTypeHelper.unmodifiableRequired(builder.coordinates, this, "coordinates"); + + } + + public static GeoLine of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - Always "LineString" + *

+ * API name: {@code type} + */ + public final String type() { + return this.type; + } + + /** + * Required - Array of [lon, lat] coordinates + *

+ * API name: {@code coordinates} + */ + public final List> coordinates() { + return this.coordinates; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("type"); + generator.write(this.type); + + if (ApiTypeHelper.isDefined(this.coordinates)) { + generator.writeKey("coordinates"); + generator.writeStartArray(); + for (List item0 : this.coordinates) { + generator.writeStartArray(); + if (item0 != null) { + for (Double item1 : item0) { + generator.write(item1); + + } + } + generator.writeEnd(); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GeoLine}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String type; + + private List> coordinates; + + /** + * Required - Always "LineString" + *

+ * API name: {@code type} + */ + public final Builder type(String value) { + this.type = value; + return this; + } + + /** + * Required - Array of [lon, lat] coordinates + *

+ * API name: {@code coordinates} + *

+ * Adds all elements of list to coordinates. + */ + public final Builder coordinates(List> list) { + this.coordinates = _listAddAll(this.coordinates, list); + return this; + } + + /** + * Required - Array of [lon, lat] coordinates + *

+ * API name: {@code coordinates} + *

+ * Adds one or more values to coordinates. + */ + public final Builder coordinates(List value, List... values) { + this.coordinates = _listAdd(this.coordinates, value, values); + return this; + } + + /** + * Builds a {@link GeoLine}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GeoLine build() { + _checkSingleUse(); + + return new GeoLine(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GeoLine} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + GeoLine::setupGeoLineDeserializer + ); + + protected static void setupGeoLineDeserializer(ObjectDeserializer op) { + + op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); + op.add( + Builder::coordinates, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.arrayDeserializer(JsonpDeserializer.doubleDeserializer())), + "coordinates" + ); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLocation.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLocation.java index 76fc712adc..f04f86d802 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLocation.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLocation.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -46,9 +45,6 @@ import org.opensearch.client.util.ObjectBuilderBase; import org.opensearch.client.util.TaggedUnion; import org.opensearch.client.util.TaggedUnionUtils; -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.function.Function; // typedef: _types.GeoLocation @@ -67,185 +63,188 @@ @JsonpDeserializable public class GeoLocation implements TaggedUnion, JsonpSerializable { - public enum Kind { - Coords, Geohash, Latlon, Text - - } - - private final Kind _kind; - private final Object _value; - - @Override - public final Kind _kind() { - return _kind; - } - - @Override - public final Object _get() { - return _value; - } - - private GeoLocation(Kind kind, Object value) { - this._kind = kind; - this._value = value; - } - - private GeoLocation(Builder builder) { - - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); - this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - - } - - public static GeoLocation of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Is this variant instance of kind {@code coords}? - */ - public boolean isCoords() { - return _kind == Kind.Coords; - } - - /** - * Get the {@code coords} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code coords} kind. - */ - public List coords() { - return TaggedUnionUtils.get(this, Kind.Coords); - } - - /** - * Is this variant instance of kind {@code geohash}? - */ - public boolean isGeohash() { - return _kind == Kind.Geohash; - } - - /** - * Get the {@code geohash} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code geohash} kind. - */ - public GeoHashLocation geohash() { - return TaggedUnionUtils.get(this, Kind.Geohash); - } - - /** - * Is this variant instance of kind {@code latlon}? - */ - public boolean isLatlon() { - return _kind == Kind.Latlon; - } - - /** - * Get the {@code latlon} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code latlon} kind. - */ - public LatLonGeoLocation latlon() { - return TaggedUnionUtils.get(this, Kind.Latlon); - } - - /** - * Is this variant instance of kind {@code text}? - */ - public boolean isText() { - return _kind == Kind.Text; - } - - /** - * Get the {@code text} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code text} kind. - */ - public String text() { - return TaggedUnionUtils.get(this, Kind.Text); - } - - @Override - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - if (_value instanceof JsonpSerializable) { - ((JsonpSerializable) _value).serialize(generator, mapper); - } else { - switch (_kind) { - case Coords : - generator.writeStartArray(); - for (Double item0 : ((List) this._value)) { - generator.write(item0); - - } - generator.writeEnd(); - - break; - case Text : - generator.write(((String) this._value)); - - break; - } - } - - } - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Kind _kind; - private Object _value; - - public ObjectBuilder coords(List v) { - this._kind = Kind.Coords; - this._value = v; - return this; - } - - public ObjectBuilder geohash(GeoHashLocation v) { - this._kind = Kind.Geohash; - this._value = v; - return this; - } - - public ObjectBuilder geohash( - Function> fn) { - return this.geohash(fn.apply(new GeoHashLocation.Builder()).build()); - } - - public ObjectBuilder latlon(LatLonGeoLocation v) { - this._kind = Kind.Latlon; - this._value = v; - return this; - } - - public ObjectBuilder latlon( - Function> fn) { - return this.latlon(fn.apply(new LatLonGeoLocation.Builder()).build()); - } - - public ObjectBuilder text(String v) { - this._kind = Kind.Text; - this._value = v; - return this; - } - - public GeoLocation build() { - _checkSingleUse(); - return new GeoLocation(this); - } - - } - - private static JsonpDeserializer buildGeoLocationDeserializer() { - return new UnionDeserializer.Builder(GeoLocation::new, false) - .addMember(Kind.Coords, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.doubleDeserializer())) - .addMember(Kind.Geohash, GeoHashLocation._DESERIALIZER) - .addMember(Kind.Latlon, LatLonGeoLocation._DESERIALIZER) - .addMember(Kind.Text, JsonpDeserializer.stringDeserializer()).build(); - } - - public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer - .lazy(GeoLocation::buildGeoLocationDeserializer); + public enum Kind { + Coords, + Geohash, + Latlon, + Text + + } + + private final Kind _kind; + private final Object _value; + + @Override + public final Kind _kind() { + return _kind; + } + + @Override + public final Object _get() { + return _value; + } + + private GeoLocation(Kind kind, Object value) { + this._kind = kind; + this._value = value; + } + + private GeoLocation(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static GeoLocation of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Is this variant instance of kind {@code coords}? + */ + public boolean isCoords() { + return _kind == Kind.Coords; + } + + /** + * Get the {@code coords} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code coords} kind. + */ + public List coords() { + return TaggedUnionUtils.get(this, Kind.Coords); + } + + /** + * Is this variant instance of kind {@code geohash}? + */ + public boolean isGeohash() { + return _kind == Kind.Geohash; + } + + /** + * Get the {@code geohash} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code geohash} kind. + */ + public GeoHashLocation geohash() { + return TaggedUnionUtils.get(this, Kind.Geohash); + } + + /** + * Is this variant instance of kind {@code latlon}? + */ + public boolean isLatlon() { + return _kind == Kind.Latlon; + } + + /** + * Get the {@code latlon} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code latlon} kind. + */ + public LatLonGeoLocation latlon() { + return TaggedUnionUtils.get(this, Kind.Latlon); + } + + /** + * Is this variant instance of kind {@code text}? + */ + public boolean isText() { + return _kind == Kind.Text; + } + + /** + * Get the {@code text} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code text} kind. + */ + public String text() { + return TaggedUnionUtils.get(this, Kind.Text); + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + if (_value instanceof JsonpSerializable) { + ((JsonpSerializable) _value).serialize(generator, mapper); + } else { + switch (_kind) { + case Coords: + generator.writeStartArray(); + for (Double item0 : ((List) this._value)) { + generator.write(item0); + + } + generator.writeEnd(); + + break; + case Text: + generator.write(((String) this._value)); + + break; + } + } + + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private Object _value; + + public ObjectBuilder coords(List v) { + this._kind = Kind.Coords; + this._value = v; + return this; + } + + public ObjectBuilder geohash(GeoHashLocation v) { + this._kind = Kind.Geohash; + this._value = v; + return this; + } + + public ObjectBuilder geohash(Function> fn) { + return this.geohash(fn.apply(new GeoHashLocation.Builder()).build()); + } + + public ObjectBuilder latlon(LatLonGeoLocation v) { + this._kind = Kind.Latlon; + this._value = v; + return this; + } + + public ObjectBuilder latlon(Function> fn) { + return this.latlon(fn.apply(new LatLonGeoLocation.Builder()).build()); + } + + public ObjectBuilder text(String v) { + this._kind = Kind.Text; + this._value = v; + return this; + } + + public GeoLocation build() { + _checkSingleUse(); + return new GeoLocation(this); + } + + } + + private static JsonpDeserializer buildGeoLocationDeserializer() { + return new UnionDeserializer.Builder(GeoLocation::new, false).addMember( + Kind.Coords, + JsonpDeserializer.arrayDeserializer(JsonpDeserializer.doubleDeserializer()) + ) + .addMember(Kind.Geohash, GeoHashLocation._DESERIALIZER) + .addMember(Kind.Latlon, LatLonGeoLocation._DESERIALIZER) + .addMember(Kind.Text, JsonpDeserializer.stringDeserializer()) + .build(); + } + + public static final JsonpDeserializer _DESERIALIZER = JsonpDeserializer.lazy(GeoLocation::buildGeoLocationDeserializer); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLocationBuilders.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLocationBuilders.java index 917115daf4..7568ad87a6 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLocationBuilders.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoLocationBuilders.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; /** @@ -42,26 +38,25 @@ * Variants coords, text are not available here as * they don't have a dedicated class. Use {@link GeoLocation}'s builder for * these. - * + * */ public class GeoLocationBuilders { - private GeoLocationBuilders() { - } - - /** - * Creates a builder for the {@link GeoHashLocation geohash} {@code GeoLocation} - * variant. - */ - public static GeoHashLocation.Builder geohash() { - return new GeoHashLocation.Builder(); - } - - /** - * Creates a builder for the {@link LatLonGeoLocation latlon} - * {@code GeoLocation} variant. - */ - public static LatLonGeoLocation.Builder latlon() { - return new LatLonGeoLocation.Builder(); - } + private GeoLocationBuilders() {} + + /** + * Creates a builder for the {@link GeoHashLocation geohash} {@code GeoLocation} + * variant. + */ + public static GeoHashLocation.Builder geohash() { + return new GeoHashLocation.Builder(); + } + + /** + * Creates a builder for the {@link LatLonGeoLocation latlon} + * {@code GeoLocation} variant. + */ + public static LatLonGeoLocation.Builder latlon() { + return new LatLonGeoLocation.Builder(); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoShapeRelation.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoShapeRelation.java index a504b7151a..f51d42a238 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoShapeRelation.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoShapeRelation.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,26 +37,25 @@ @JsonpDeserializable public enum GeoShapeRelation implements JsonEnum { - Intersects("intersects"), + Intersects("intersects"), - Disjoint("disjoint"), + Disjoint("disjoint"), - Within("within"), + Within("within"), - Contains("contains"), + Contains("contains"), - ; + ; - private final String jsonValue; + private final String jsonValue; - GeoShapeRelation(String jsonValue) { - this.jsonValue = jsonValue; - } + GeoShapeRelation(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( - GeoShapeRelation.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(GeoShapeRelation.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GetStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GetStats.java index 2a81ae66e2..4e53545c95 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/GetStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/GetStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,325 +44,323 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.GetStats @JsonpDeserializable public class GetStats implements JsonpSerializable { - private final long current; - - @Nullable - private final String existsTime; - - private final long existsTimeInMillis; - - private final long existsTotal; - - @Nullable - private final String missingTime; - - private final long missingTimeInMillis; - - private final long missingTotal; - - @Nullable - private final String time; - - private final long timeInMillis; - - private final long total; - - // --------------------------------------------------------------------------------------------- - - private GetStats(Builder builder) { - - this.current = ApiTypeHelper.requireNonNull(builder.current, this, "current"); - this.existsTime = builder.existsTime; - this.existsTimeInMillis = ApiTypeHelper.requireNonNull(builder.existsTimeInMillis, this, "existsTimeInMillis"); - this.existsTotal = ApiTypeHelper.requireNonNull(builder.existsTotal, this, "existsTotal"); - this.missingTime = builder.missingTime; - this.missingTimeInMillis = ApiTypeHelper.requireNonNull(builder.missingTimeInMillis, this, - "missingTimeInMillis"); - this.missingTotal = ApiTypeHelper.requireNonNull(builder.missingTotal, this, "missingTotal"); - this.time = builder.time; - this.timeInMillis = ApiTypeHelper.requireNonNull(builder.timeInMillis, this, "timeInMillis"); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - - } - - public static GetStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code current} - */ - public final long current() { - return this.current; - } - - /** - * API name: {@code exists_time} - */ - @Nullable - public final String existsTime() { - return this.existsTime; - } - - /** - * Required - API name: {@code exists_time_in_millis} - */ - public final long existsTimeInMillis() { - return this.existsTimeInMillis; - } - - /** - * Required - API name: {@code exists_total} - */ - public final long existsTotal() { - return this.existsTotal; - } - - /** - * API name: {@code missing_time} - */ - @Nullable - public final String missingTime() { - return this.missingTime; - } - - /** - * Required - API name: {@code missing_time_in_millis} - */ - public final long missingTimeInMillis() { - return this.missingTimeInMillis; - } - - /** - * Required - API name: {@code missing_total} - */ - public final long missingTotal() { - return this.missingTotal; - } + private final long current; + + @Nullable + private final String existsTime; + + private final long existsTimeInMillis; + + private final long existsTotal; + + @Nullable + private final String missingTime; + + private final long missingTimeInMillis; + + private final long missingTotal; + + @Nullable + private final String time; + + private final long timeInMillis; + + private final long total; + + // --------------------------------------------------------------------------------------------- + + private GetStats(Builder builder) { + + this.current = ApiTypeHelper.requireNonNull(builder.current, this, "current"); + this.existsTime = builder.existsTime; + this.existsTimeInMillis = ApiTypeHelper.requireNonNull(builder.existsTimeInMillis, this, "existsTimeInMillis"); + this.existsTotal = ApiTypeHelper.requireNonNull(builder.existsTotal, this, "existsTotal"); + this.missingTime = builder.missingTime; + this.missingTimeInMillis = ApiTypeHelper.requireNonNull(builder.missingTimeInMillis, this, "missingTimeInMillis"); + this.missingTotal = ApiTypeHelper.requireNonNull(builder.missingTotal, this, "missingTotal"); + this.time = builder.time; + this.timeInMillis = ApiTypeHelper.requireNonNull(builder.timeInMillis, this, "timeInMillis"); + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); + + } + + public static GetStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code current} + */ + public final long current() { + return this.current; + } + + /** + * API name: {@code exists_time} + */ + @Nullable + public final String existsTime() { + return this.existsTime; + } + + /** + * Required - API name: {@code exists_time_in_millis} + */ + public final long existsTimeInMillis() { + return this.existsTimeInMillis; + } + + /** + * Required - API name: {@code exists_total} + */ + public final long existsTotal() { + return this.existsTotal; + } + + /** + * API name: {@code missing_time} + */ + @Nullable + public final String missingTime() { + return this.missingTime; + } + + /** + * Required - API name: {@code missing_time_in_millis} + */ + public final long missingTimeInMillis() { + return this.missingTimeInMillis; + } + + /** + * Required - API name: {@code missing_total} + */ + public final long missingTotal() { + return this.missingTotal; + } - /** - * API name: {@code time} - */ - @Nullable - public final String time() { - return this.time; - } - - /** - * Required - API name: {@code time_in_millis} - */ - public final long timeInMillis() { - return this.timeInMillis; - } - - /** - * Required - API name: {@code total} - */ - public final long total() { - return this.total; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("current"); - generator.write(this.current); - - if (this.existsTime != null) { - generator.writeKey("exists_time"); - generator.write(this.existsTime); - - } - generator.writeKey("exists_time_in_millis"); - generator.write(this.existsTimeInMillis); - - generator.writeKey("exists_total"); - generator.write(this.existsTotal); - - if (this.missingTime != null) { - generator.writeKey("missing_time"); - generator.write(this.missingTime); - - } - generator.writeKey("missing_time_in_millis"); - generator.write(this.missingTimeInMillis); - - generator.writeKey("missing_total"); - generator.write(this.missingTotal); - - if (this.time != null) { - generator.writeKey("time"); - generator.write(this.time); - - } - generator.writeKey("time_in_millis"); - generator.write(this.timeInMillis); - - generator.writeKey("total"); - generator.write(this.total); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link GetStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long current; - - @Nullable - private String existsTime; - - private Long existsTimeInMillis; - - private Long existsTotal; - - @Nullable - private String missingTime; - - private Long missingTimeInMillis; - - private Long missingTotal; - - @Nullable - private String time; - - private Long timeInMillis; - - private Long total; - - /** - * Required - API name: {@code current} - */ - public final Builder current(long value) { - this.current = value; - return this; - } - - /** - * API name: {@code exists_time} - */ - public final Builder existsTime(@Nullable String value) { - this.existsTime = value; - return this; - } - - /** - * Required - API name: {@code exists_time_in_millis} - */ - public final Builder existsTimeInMillis(long value) { - this.existsTimeInMillis = value; - return this; - } - - /** - * Required - API name: {@code exists_total} - */ - public final Builder existsTotal(long value) { - this.existsTotal = value; - return this; - } - - /** - * API name: {@code missing_time} - */ - public final Builder missingTime(@Nullable String value) { - this.missingTime = value; - return this; - } - - /** - * Required - API name: {@code missing_time_in_millis} - */ - public final Builder missingTimeInMillis(long value) { - this.missingTimeInMillis = value; - return this; - } - - /** - * Required - API name: {@code missing_total} - */ - public final Builder missingTotal(long value) { - this.missingTotal = value; - return this; - } - - /** - * API name: {@code time} - */ - public final Builder time(@Nullable String value) { - this.time = value; - return this; - } - - /** - * Required - API name: {@code time_in_millis} - */ - public final Builder timeInMillis(long value) { - this.timeInMillis = value; - return this; - } - - /** - * Required - API name: {@code total} - */ - public final Builder total(long value) { - this.total = value; - return this; - } - - /** - * Builds a {@link GetStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public GetStats build() { - _checkSingleUse(); - - return new GetStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link GetStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - GetStats::setupGetStatsDeserializer); - - protected static void setupGetStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::current, JsonpDeserializer.longDeserializer(), "current"); - op.add(Builder::existsTime, JsonpDeserializer.stringDeserializer(), "exists_time"); - op.add(Builder::existsTimeInMillis, JsonpDeserializer.longDeserializer(), "exists_time_in_millis"); - op.add(Builder::existsTotal, JsonpDeserializer.longDeserializer(), "exists_total"); - op.add(Builder::missingTime, JsonpDeserializer.stringDeserializer(), "missing_time"); - op.add(Builder::missingTimeInMillis, JsonpDeserializer.longDeserializer(), "missing_time_in_millis"); - op.add(Builder::missingTotal, JsonpDeserializer.longDeserializer(), "missing_total"); - op.add(Builder::time, JsonpDeserializer.stringDeserializer(), "time"); - op.add(Builder::timeInMillis, JsonpDeserializer.longDeserializer(), "time_in_millis"); - op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); - - } + /** + * API name: {@code time} + */ + @Nullable + public final String time() { + return this.time; + } + + /** + * Required - API name: {@code time_in_millis} + */ + public final long timeInMillis() { + return this.timeInMillis; + } + + /** + * Required - API name: {@code total} + */ + public final long total() { + return this.total; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("current"); + generator.write(this.current); + + if (this.existsTime != null) { + generator.writeKey("exists_time"); + generator.write(this.existsTime); + + } + generator.writeKey("exists_time_in_millis"); + generator.write(this.existsTimeInMillis); + + generator.writeKey("exists_total"); + generator.write(this.existsTotal); + + if (this.missingTime != null) { + generator.writeKey("missing_time"); + generator.write(this.missingTime); + + } + generator.writeKey("missing_time_in_millis"); + generator.write(this.missingTimeInMillis); + + generator.writeKey("missing_total"); + generator.write(this.missingTotal); + + if (this.time != null) { + generator.writeKey("time"); + generator.write(this.time); + + } + generator.writeKey("time_in_millis"); + generator.write(this.timeInMillis); + + generator.writeKey("total"); + generator.write(this.total); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link GetStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long current; + + @Nullable + private String existsTime; + + private Long existsTimeInMillis; + + private Long existsTotal; + + @Nullable + private String missingTime; + + private Long missingTimeInMillis; + + private Long missingTotal; + + @Nullable + private String time; + + private Long timeInMillis; + + private Long total; + + /** + * Required - API name: {@code current} + */ + public final Builder current(long value) { + this.current = value; + return this; + } + + /** + * API name: {@code exists_time} + */ + public final Builder existsTime(@Nullable String value) { + this.existsTime = value; + return this; + } + + /** + * Required - API name: {@code exists_time_in_millis} + */ + public final Builder existsTimeInMillis(long value) { + this.existsTimeInMillis = value; + return this; + } + + /** + * Required - API name: {@code exists_total} + */ + public final Builder existsTotal(long value) { + this.existsTotal = value; + return this; + } + + /** + * API name: {@code missing_time} + */ + public final Builder missingTime(@Nullable String value) { + this.missingTime = value; + return this; + } + + /** + * Required - API name: {@code missing_time_in_millis} + */ + public final Builder missingTimeInMillis(long value) { + this.missingTimeInMillis = value; + return this; + } + + /** + * Required - API name: {@code missing_total} + */ + public final Builder missingTotal(long value) { + this.missingTotal = value; + return this; + } + + /** + * API name: {@code time} + */ + public final Builder time(@Nullable String value) { + this.time = value; + return this; + } + + /** + * Required - API name: {@code time_in_millis} + */ + public final Builder timeInMillis(long value) { + this.timeInMillis = value; + return this; + } + + /** + * Required - API name: {@code total} + */ + public final Builder total(long value) { + this.total = value; + return this; + } + + /** + * Builds a {@link GetStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public GetStats build() { + _checkSingleUse(); + + return new GetStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link GetStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + GetStats::setupGetStatsDeserializer + ); + + protected static void setupGetStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::current, JsonpDeserializer.longDeserializer(), "current"); + op.add(Builder::existsTime, JsonpDeserializer.stringDeserializer(), "exists_time"); + op.add(Builder::existsTimeInMillis, JsonpDeserializer.longDeserializer(), "exists_time_in_millis"); + op.add(Builder::existsTotal, JsonpDeserializer.longDeserializer(), "exists_total"); + op.add(Builder::missingTime, JsonpDeserializer.stringDeserializer(), "missing_time"); + op.add(Builder::missingTimeInMillis, JsonpDeserializer.longDeserializer(), "missing_time_in_millis"); + op.add(Builder::missingTotal, JsonpDeserializer.longDeserializer(), "missing_total"); + op.add(Builder::time, JsonpDeserializer.stringDeserializer(), "time"); + op.add(Builder::timeInMillis, JsonpDeserializer.longDeserializer(), "time_in_millis"); + op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/HealthStatus.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/HealthStatus.java index ce1154ddea..09a9914a63 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/HealthStatus.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/HealthStatus.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,42 +37,41 @@ @JsonpDeserializable public enum HealthStatus implements JsonEnum { - /** - * All shards are assigned. - */ - Green("green", "GREEN"), + /** + * All shards are assigned. + */ + Green("green", "GREEN"), - /** - * All primary shards are assigned, but one or more replica shards are - * unassigned. If a node in the cluster fails, some data could be unavailable - * until that node is repaired. - */ - Yellow("yellow", "YELLOW"), + /** + * All primary shards are assigned, but one or more replica shards are + * unassigned. If a node in the cluster fails, some data could be unavailable + * until that node is repaired. + */ + Yellow("yellow", "YELLOW"), - /** - * One or more primary shards are unassigned, so some data is unavailable. This - * can occur briefly during cluster startup as primary shards are assigned. - */ - Red("red", "RED"), + /** + * One or more primary shards are unassigned, so some data is unavailable. This + * can occur briefly during cluster startup as primary shards are assigned. + */ + Red("red", "RED"), - ; + ; - private final String jsonValue; - private final String[] aliases; + private final String jsonValue; + private final String[] aliases; - HealthStatus(String jsonValue, String... aliases) { - this.jsonValue = jsonValue; - this.aliases = aliases; - } + HealthStatus(String jsonValue, String... aliases) { + this.jsonValue = jsonValue; + this.aliases = aliases; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public String[] aliases() { - return this.aliases; - } + public String[] aliases() { + return this.aliases; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( - HealthStatus.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(HealthStatus.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndexingStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndexingStats.java index 4855743fff..9c81681f7a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndexingStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndexingStats.java @@ -30,12 +30,12 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,453 +45,450 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.IndexingStats @JsonpDeserializable public class IndexingStats implements JsonpSerializable { - private final long indexCurrent; + private final long indexCurrent; - private final long deleteCurrent; - - @Nullable - private final String deleteTime; + private final long deleteCurrent; + + @Nullable + private final String deleteTime; - private final long deleteTimeInMillis; - - private final long deleteTotal; - - private final boolean isThrottled; - - private final long noopUpdateTotal; - - @Nullable - private final String throttleTime; - - private final long throttleTimeInMillis; - - @Nullable - private final String indexTime; - - private final long indexTimeInMillis; - - private final long indexTotal; - - private final long indexFailed; - - private final Map types; - - // --------------------------------------------------------------------------------------------- - - private IndexingStats(Builder builder) { - - this.indexCurrent = ApiTypeHelper.requireNonNull(builder.indexCurrent, this, "indexCurrent"); - this.deleteCurrent = ApiTypeHelper.requireNonNull(builder.deleteCurrent, this, "deleteCurrent"); - this.deleteTime = builder.deleteTime; - this.deleteTimeInMillis = ApiTypeHelper.requireNonNull(builder.deleteTimeInMillis, this, "deleteTimeInMillis"); - this.deleteTotal = ApiTypeHelper.requireNonNull(builder.deleteTotal, this, "deleteTotal"); - this.isThrottled = ApiTypeHelper.requireNonNull(builder.isThrottled, this, "isThrottled"); - this.noopUpdateTotal = ApiTypeHelper.requireNonNull(builder.noopUpdateTotal, this, "noopUpdateTotal"); - this.throttleTime = builder.throttleTime; - this.throttleTimeInMillis = ApiTypeHelper.requireNonNull(builder.throttleTimeInMillis, this, - "throttleTimeInMillis"); - this.indexTime = builder.indexTime; - this.indexTimeInMillis = ApiTypeHelper.requireNonNull(builder.indexTimeInMillis, this, "indexTimeInMillis"); - this.indexTotal = ApiTypeHelper.requireNonNull(builder.indexTotal, this, "indexTotal"); - this.indexFailed = ApiTypeHelper.requireNonNull(builder.indexFailed, this, "indexFailed"); - this.types = ApiTypeHelper.unmodifiable(builder.types); - - } - - public static IndexingStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code index_current} - */ - public final long indexCurrent() { - return this.indexCurrent; - } - - /** - * Required - API name: {@code delete_current} - */ - public final long deleteCurrent() { - return this.deleteCurrent; - } - - /** - * API name: {@code delete_time} - */ - @Nullable - public final String deleteTime() { - return this.deleteTime; - } - - /** - * Required - API name: {@code delete_time_in_millis} - */ - public final long deleteTimeInMillis() { - return this.deleteTimeInMillis; - } - - /** - * Required - API name: {@code delete_total} - */ - public final long deleteTotal() { - return this.deleteTotal; - } - - /** - * Required - API name: {@code is_throttled} - */ - public final boolean isThrottled() { - return this.isThrottled; - } - - /** - * Required - API name: {@code noop_update_total} - */ - public final long noopUpdateTotal() { - return this.noopUpdateTotal; - } - - /** - * API name: {@code throttle_time} - */ - @Nullable - public final String throttleTime() { - return this.throttleTime; - } - - /** - * Required - API name: {@code throttle_time_in_millis} - */ - public final long throttleTimeInMillis() { - return this.throttleTimeInMillis; - } - - /** - * API name: {@code index_time} - */ - @Nullable - public final String indexTime() { - return this.indexTime; - } - - /** - * Required - API name: {@code index_time_in_millis} - */ - public final long indexTimeInMillis() { - return this.indexTimeInMillis; - } - - /** - * Required - API name: {@code index_total} - */ - public final long indexTotal() { - return this.indexTotal; - } - - /** - * Required - API name: {@code index_failed} - */ - public final long indexFailed() { - return this.indexFailed; - } - - /** - * API name: {@code types} - */ - public final Map types() { - return this.types; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("index_current"); - generator.write(this.indexCurrent); - - generator.writeKey("delete_current"); - generator.write(this.deleteCurrent); - - if (this.deleteTime != null) { - generator.writeKey("delete_time"); - generator.write(this.deleteTime); - - } - generator.writeKey("delete_time_in_millis"); - generator.write(this.deleteTimeInMillis); - - generator.writeKey("delete_total"); - generator.write(this.deleteTotal); - - generator.writeKey("is_throttled"); - generator.write(this.isThrottled); - - generator.writeKey("noop_update_total"); - generator.write(this.noopUpdateTotal); - - if (this.throttleTime != null) { - generator.writeKey("throttle_time"); - generator.write(this.throttleTime); - - } - generator.writeKey("throttle_time_in_millis"); - generator.write(this.throttleTimeInMillis); - - if (this.indexTime != null) { - generator.writeKey("index_time"); - generator.write(this.indexTime); - - } - generator.writeKey("index_time_in_millis"); - generator.write(this.indexTimeInMillis); - - generator.writeKey("index_total"); - generator.write(this.indexTotal); - - generator.writeKey("index_failed"); - generator.write(this.indexFailed); - - if (ApiTypeHelper.isDefined(this.types)) { - generator.writeKey("types"); - generator.writeStartObject(); - for (Map.Entry item0 : this.types.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link IndexingStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long indexCurrent; - - private Long deleteCurrent; - - @Nullable - private String deleteTime; - - private Long deleteTimeInMillis; - - private Long deleteTotal; - - private Boolean isThrottled; - - private Long noopUpdateTotal; - - @Nullable - private String throttleTime; - - private Long throttleTimeInMillis; - - @Nullable - private String indexTime; - - private Long indexTimeInMillis; - - private Long indexTotal; - - private Long indexFailed; - - @Nullable - private Map types; - - /** - * Required - API name: {@code index_current} - */ - public final Builder indexCurrent(long value) { - this.indexCurrent = value; - return this; - } - - /** - * Required - API name: {@code delete_current} - */ - public final Builder deleteCurrent(long value) { - this.deleteCurrent = value; - return this; - } - - /** - * API name: {@code delete_time} - */ - public final Builder deleteTime(@Nullable String value) { - this.deleteTime = value; - return this; - } - - /** - * Required - API name: {@code delete_time_in_millis} - */ - public final Builder deleteTimeInMillis(long value) { - this.deleteTimeInMillis = value; - return this; - } - - /** - * Required - API name: {@code delete_total} - */ - public final Builder deleteTotal(long value) { - this.deleteTotal = value; - return this; - } - - /** - * Required - API name: {@code is_throttled} - */ - public final Builder isThrottled(boolean value) { - this.isThrottled = value; - return this; - } - - /** - * Required - API name: {@code noop_update_total} - */ - public final Builder noopUpdateTotal(long value) { - this.noopUpdateTotal = value; - return this; - } - - /** - * API name: {@code throttle_time} - */ - public final Builder throttleTime(@Nullable String value) { - this.throttleTime = value; - return this; - } - - /** - * Required - API name: {@code throttle_time_in_millis} - */ - public final Builder throttleTimeInMillis(long value) { - this.throttleTimeInMillis = value; - return this; - } - - /** - * API name: {@code index_time} - */ - public final Builder indexTime(@Nullable String value) { - this.indexTime = value; - return this; - } - - /** - * Required - API name: {@code index_time_in_millis} - */ - public final Builder indexTimeInMillis(long value) { - this.indexTimeInMillis = value; - return this; - } - - /** - * Required - API name: {@code index_total} - */ - public final Builder indexTotal(long value) { - this.indexTotal = value; - return this; - } - - /** - * Required - API name: {@code index_failed} - */ - public final Builder indexFailed(long value) { - this.indexFailed = value; - return this; - } - - /** - * API name: {@code types} - *

- * Adds all entries of map to types. - */ - public final Builder types(Map map) { - this.types = _mapPutAll(this.types, map); - return this; - } - - /** - * API name: {@code types} - *

- * Adds an entry to types. - */ - public final Builder types(String key, IndexingStats value) { - this.types = _mapPut(this.types, key, value); - return this; - } - - /** - * API name: {@code types} - *

- * Adds an entry to types using a builder lambda. - */ - public final Builder types(String key, Function> fn) { - return types(key, fn.apply(new IndexingStats.Builder()).build()); - } - - /** - * Builds a {@link IndexingStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public IndexingStats build() { - _checkSingleUse(); - - return new IndexingStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link IndexingStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - IndexingStats::setupIndexingStatsDeserializer); - - protected static void setupIndexingStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::indexCurrent, JsonpDeserializer.longDeserializer(), "index_current"); - op.add(Builder::deleteCurrent, JsonpDeserializer.longDeserializer(), "delete_current"); - op.add(Builder::deleteTime, JsonpDeserializer.stringDeserializer(), "delete_time"); - op.add(Builder::deleteTimeInMillis, JsonpDeserializer.longDeserializer(), "delete_time_in_millis"); - op.add(Builder::deleteTotal, JsonpDeserializer.longDeserializer(), "delete_total"); - op.add(Builder::isThrottled, JsonpDeserializer.booleanDeserializer(), "is_throttled"); - op.add(Builder::noopUpdateTotal, JsonpDeserializer.longDeserializer(), "noop_update_total"); - op.add(Builder::throttleTime, JsonpDeserializer.stringDeserializer(), "throttle_time"); - op.add(Builder::throttleTimeInMillis, JsonpDeserializer.longDeserializer(), "throttle_time_in_millis"); - op.add(Builder::indexTime, JsonpDeserializer.stringDeserializer(), "index_time"); - op.add(Builder::indexTimeInMillis, JsonpDeserializer.longDeserializer(), "index_time_in_millis"); - op.add(Builder::indexTotal, JsonpDeserializer.longDeserializer(), "index_total"); - op.add(Builder::indexFailed, JsonpDeserializer.longDeserializer(), "index_failed"); - op.add(Builder::types, JsonpDeserializer.stringMapDeserializer(IndexingStats._DESERIALIZER), "types"); - - } + private final long deleteTimeInMillis; + + private final long deleteTotal; + + private final boolean isThrottled; + + private final long noopUpdateTotal; + + @Nullable + private final String throttleTime; + + private final long throttleTimeInMillis; + + @Nullable + private final String indexTime; + + private final long indexTimeInMillis; + + private final long indexTotal; + + private final long indexFailed; + + private final Map types; + + // --------------------------------------------------------------------------------------------- + + private IndexingStats(Builder builder) { + + this.indexCurrent = ApiTypeHelper.requireNonNull(builder.indexCurrent, this, "indexCurrent"); + this.deleteCurrent = ApiTypeHelper.requireNonNull(builder.deleteCurrent, this, "deleteCurrent"); + this.deleteTime = builder.deleteTime; + this.deleteTimeInMillis = ApiTypeHelper.requireNonNull(builder.deleteTimeInMillis, this, "deleteTimeInMillis"); + this.deleteTotal = ApiTypeHelper.requireNonNull(builder.deleteTotal, this, "deleteTotal"); + this.isThrottled = ApiTypeHelper.requireNonNull(builder.isThrottled, this, "isThrottled"); + this.noopUpdateTotal = ApiTypeHelper.requireNonNull(builder.noopUpdateTotal, this, "noopUpdateTotal"); + this.throttleTime = builder.throttleTime; + this.throttleTimeInMillis = ApiTypeHelper.requireNonNull(builder.throttleTimeInMillis, this, "throttleTimeInMillis"); + this.indexTime = builder.indexTime; + this.indexTimeInMillis = ApiTypeHelper.requireNonNull(builder.indexTimeInMillis, this, "indexTimeInMillis"); + this.indexTotal = ApiTypeHelper.requireNonNull(builder.indexTotal, this, "indexTotal"); + this.indexFailed = ApiTypeHelper.requireNonNull(builder.indexFailed, this, "indexFailed"); + this.types = ApiTypeHelper.unmodifiable(builder.types); + + } + + public static IndexingStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code index_current} + */ + public final long indexCurrent() { + return this.indexCurrent; + } + + /** + * Required - API name: {@code delete_current} + */ + public final long deleteCurrent() { + return this.deleteCurrent; + } + + /** + * API name: {@code delete_time} + */ + @Nullable + public final String deleteTime() { + return this.deleteTime; + } + + /** + * Required - API name: {@code delete_time_in_millis} + */ + public final long deleteTimeInMillis() { + return this.deleteTimeInMillis; + } + + /** + * Required - API name: {@code delete_total} + */ + public final long deleteTotal() { + return this.deleteTotal; + } + + /** + * Required - API name: {@code is_throttled} + */ + public final boolean isThrottled() { + return this.isThrottled; + } + + /** + * Required - API name: {@code noop_update_total} + */ + public final long noopUpdateTotal() { + return this.noopUpdateTotal; + } + + /** + * API name: {@code throttle_time} + */ + @Nullable + public final String throttleTime() { + return this.throttleTime; + } + + /** + * Required - API name: {@code throttle_time_in_millis} + */ + public final long throttleTimeInMillis() { + return this.throttleTimeInMillis; + } + + /** + * API name: {@code index_time} + */ + @Nullable + public final String indexTime() { + return this.indexTime; + } + + /** + * Required - API name: {@code index_time_in_millis} + */ + public final long indexTimeInMillis() { + return this.indexTimeInMillis; + } + + /** + * Required - API name: {@code index_total} + */ + public final long indexTotal() { + return this.indexTotal; + } + + /** + * Required - API name: {@code index_failed} + */ + public final long indexFailed() { + return this.indexFailed; + } + + /** + * API name: {@code types} + */ + public final Map types() { + return this.types; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("index_current"); + generator.write(this.indexCurrent); + + generator.writeKey("delete_current"); + generator.write(this.deleteCurrent); + + if (this.deleteTime != null) { + generator.writeKey("delete_time"); + generator.write(this.deleteTime); + + } + generator.writeKey("delete_time_in_millis"); + generator.write(this.deleteTimeInMillis); + + generator.writeKey("delete_total"); + generator.write(this.deleteTotal); + + generator.writeKey("is_throttled"); + generator.write(this.isThrottled); + + generator.writeKey("noop_update_total"); + generator.write(this.noopUpdateTotal); + + if (this.throttleTime != null) { + generator.writeKey("throttle_time"); + generator.write(this.throttleTime); + + } + generator.writeKey("throttle_time_in_millis"); + generator.write(this.throttleTimeInMillis); + + if (this.indexTime != null) { + generator.writeKey("index_time"); + generator.write(this.indexTime); + + } + generator.writeKey("index_time_in_millis"); + generator.write(this.indexTimeInMillis); + + generator.writeKey("index_total"); + generator.write(this.indexTotal); + + generator.writeKey("index_failed"); + generator.write(this.indexFailed); + + if (ApiTypeHelper.isDefined(this.types)) { + generator.writeKey("types"); + generator.writeStartObject(); + for (Map.Entry item0 : this.types.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link IndexingStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long indexCurrent; + + private Long deleteCurrent; + + @Nullable + private String deleteTime; + + private Long deleteTimeInMillis; + + private Long deleteTotal; + + private Boolean isThrottled; + + private Long noopUpdateTotal; + + @Nullable + private String throttleTime; + + private Long throttleTimeInMillis; + + @Nullable + private String indexTime; + + private Long indexTimeInMillis; + + private Long indexTotal; + + private Long indexFailed; + + @Nullable + private Map types; + + /** + * Required - API name: {@code index_current} + */ + public final Builder indexCurrent(long value) { + this.indexCurrent = value; + return this; + } + + /** + * Required - API name: {@code delete_current} + */ + public final Builder deleteCurrent(long value) { + this.deleteCurrent = value; + return this; + } + + /** + * API name: {@code delete_time} + */ + public final Builder deleteTime(@Nullable String value) { + this.deleteTime = value; + return this; + } + + /** + * Required - API name: {@code delete_time_in_millis} + */ + public final Builder deleteTimeInMillis(long value) { + this.deleteTimeInMillis = value; + return this; + } + + /** + * Required - API name: {@code delete_total} + */ + public final Builder deleteTotal(long value) { + this.deleteTotal = value; + return this; + } + + /** + * Required - API name: {@code is_throttled} + */ + public final Builder isThrottled(boolean value) { + this.isThrottled = value; + return this; + } + + /** + * Required - API name: {@code noop_update_total} + */ + public final Builder noopUpdateTotal(long value) { + this.noopUpdateTotal = value; + return this; + } + + /** + * API name: {@code throttle_time} + */ + public final Builder throttleTime(@Nullable String value) { + this.throttleTime = value; + return this; + } + + /** + * Required - API name: {@code throttle_time_in_millis} + */ + public final Builder throttleTimeInMillis(long value) { + this.throttleTimeInMillis = value; + return this; + } + + /** + * API name: {@code index_time} + */ + public final Builder indexTime(@Nullable String value) { + this.indexTime = value; + return this; + } + + /** + * Required - API name: {@code index_time_in_millis} + */ + public final Builder indexTimeInMillis(long value) { + this.indexTimeInMillis = value; + return this; + } + + /** + * Required - API name: {@code index_total} + */ + public final Builder indexTotal(long value) { + this.indexTotal = value; + return this; + } + + /** + * Required - API name: {@code index_failed} + */ + public final Builder indexFailed(long value) { + this.indexFailed = value; + return this; + } + + /** + * API name: {@code types} + *

+ * Adds all entries of map to types. + */ + public final Builder types(Map map) { + this.types = _mapPutAll(this.types, map); + return this; + } + + /** + * API name: {@code types} + *

+ * Adds an entry to types. + */ + public final Builder types(String key, IndexingStats value) { + this.types = _mapPut(this.types, key, value); + return this; + } + + /** + * API name: {@code types} + *

+ * Adds an entry to types using a builder lambda. + */ + public final Builder types(String key, Function> fn) { + return types(key, fn.apply(new IndexingStats.Builder()).build()); + } + + /** + * Builds a {@link IndexingStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public IndexingStats build() { + _checkSingleUse(); + + return new IndexingStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link IndexingStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + IndexingStats::setupIndexingStatsDeserializer + ); + + protected static void setupIndexingStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::indexCurrent, JsonpDeserializer.longDeserializer(), "index_current"); + op.add(Builder::deleteCurrent, JsonpDeserializer.longDeserializer(), "delete_current"); + op.add(Builder::deleteTime, JsonpDeserializer.stringDeserializer(), "delete_time"); + op.add(Builder::deleteTimeInMillis, JsonpDeserializer.longDeserializer(), "delete_time_in_millis"); + op.add(Builder::deleteTotal, JsonpDeserializer.longDeserializer(), "delete_total"); + op.add(Builder::isThrottled, JsonpDeserializer.booleanDeserializer(), "is_throttled"); + op.add(Builder::noopUpdateTotal, JsonpDeserializer.longDeserializer(), "noop_update_total"); + op.add(Builder::throttleTime, JsonpDeserializer.stringDeserializer(), "throttle_time"); + op.add(Builder::throttleTimeInMillis, JsonpDeserializer.longDeserializer(), "throttle_time_in_millis"); + op.add(Builder::indexTime, JsonpDeserializer.stringDeserializer(), "index_time"); + op.add(Builder::indexTimeInMillis, JsonpDeserializer.longDeserializer(), "index_time_in_millis"); + op.add(Builder::indexTotal, JsonpDeserializer.longDeserializer(), "index_total"); + op.add(Builder::indexFailed, JsonpDeserializer.longDeserializer(), "index_failed"); + op.add(Builder::types, JsonpDeserializer.stringMapDeserializer(IndexingStats._DESERIALIZER), "types"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java index 4e276f8667..ba251d885a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/IndicesResponseBase.java @@ -30,84 +30,78 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; - import java.util.function.Function; import javax.annotation.Nullable; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ObjectBuilder; // typedef: _types.IndicesResponseBase - public abstract class IndicesResponseBase extends AcknowledgedResponseBase { - @Nullable - private final ShardStatistics shards; + @Nullable + private final ShardStatistics shards; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - protected IndicesResponseBase(AbstractBuilder builder) { - super(builder); + protected IndicesResponseBase(AbstractBuilder builder) { + super(builder); - this.shards = builder.shards; + this.shards = builder.shards; - } + } - /** - * API name: {@code _shards} - */ - @Nullable - public final ShardStatistics shards() { - return this.shards; - } + /** + * API name: {@code _shards} + */ + @Nullable + public final ShardStatistics shards() { + return this.shards; + } - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - super.serializeInternal(generator, mapper); - if (this.shards != null) { - generator.writeKey("_shards"); - this.shards.serialize(generator, mapper); + super.serializeInternal(generator, mapper); + if (this.shards != null) { + generator.writeKey("_shards"); + this.shards.serialize(generator, mapper); - } + } - } + } - protected abstract static class AbstractBuilder> - extends - AcknowledgedResponseBase.AbstractBuilder { - @Nullable - private ShardStatistics shards; + protected abstract static class AbstractBuilder> extends + AcknowledgedResponseBase.AbstractBuilder { + @Nullable + private ShardStatistics shards; - /** - * API name: {@code _shards} - */ - public final BuilderT shards(@Nullable ShardStatistics value) { - this.shards = value; - return self(); - } + /** + * API name: {@code _shards} + */ + public final BuilderT shards(@Nullable ShardStatistics value) { + this.shards = value; + return self(); + } - /** - * API name: {@code _shards} - */ - public final BuilderT shards(Function> fn) { - return this.shards(fn.apply(new ShardStatistics.Builder()).build()); - } + /** + * API name: {@code _shards} + */ + public final BuilderT shards(Function> fn) { + return this.shards(fn.apply(new ShardStatistics.Builder()).build()); + } - } + } - // --------------------------------------------------------------------------------------------- - protected static > void setupIndicesResponseBaseDeserializer( - ObjectDeserializer op) { - setupAcknowledgedResponseBaseDeserializer(op); - op.add(AbstractBuilder::shards, ShardStatistics._DESERIALIZER, "_shards"); + // --------------------------------------------------------------------------------------------- + protected static > void setupIndicesResponseBaseDeserializer( + ObjectDeserializer op + ) { + setupAcknowledgedResponseBaseDeserializer(op); + op.add(AbstractBuilder::shards, ShardStatistics._DESERIALIZER, "_shards"); - } + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineGet.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineGet.java index e41a209a81..cdebb2c397 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineGet.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineGet.java @@ -30,12 +30,14 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -47,321 +49,317 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Supplier; -import javax.annotation.Nullable; // typedef: _types.InlineGet - public class InlineGet implements JsonpSerializable { - private final Map metadata; - - private final Map fields; - - private final boolean found; - - @Nullable - private final Long seqNo; - - @Nullable - private final Long primaryTerm; - - @Nullable - private final String routing; - - private final TDocument source; - - @Nullable - private final JsonpSerializer tDocumentSerializer; - - // --------------------------------------------------------------------------------------------- - - private InlineGet(Builder builder) { - - this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); - - this.fields = ApiTypeHelper.unmodifiable(builder.fields); - this.found = ApiTypeHelper.requireNonNull(builder.found, this, "found"); - this.seqNo = builder.seqNo; - this.primaryTerm = builder.primaryTerm; - this.routing = builder.routing; - this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); - this.tDocumentSerializer = builder.tDocumentSerializer; - - } - - public static InlineGet of( - Function, ObjectBuilder>> fn) { - return fn.apply(new Builder<>()).build(); - } - - /** - * Document metadata - */ - public final Map metadata() { - return this.metadata; - } - - /** - * API name: {@code fields} - */ - public final Map fields() { - return this.fields; - } - - /** - * Required - API name: {@code found} - */ - public final boolean found() { - return this.found; - } - - /** - * API name: {@code _seq_no} - */ - @Nullable - public final Long seqNo() { - return this.seqNo; - } - - /** - * API name: {@code _primary_term} - */ - @Nullable - public final Long primaryTerm() { - return this.primaryTerm; - } - - /** - * API name: {@code _routing} - */ - @Nullable - public final String routing() { - return this.routing; - } - - /** - * Required - API name: {@code _source} - */ - public final TDocument source() { - return this.source; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - for (Map.Entry item0 : this.metadata.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - - if (ApiTypeHelper.isDefined(this.fields)) { - generator.writeKey("fields"); - generator.writeStartObject(); - for (Map.Entry item0 : this.fields.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - - } - generator.writeEnd(); - - } - generator.writeKey("found"); - generator.write(this.found); - - if (this.seqNo != null) { - generator.writeKey("_seq_no"); - generator.write(this.seqNo); - - } - if (this.primaryTerm != null) { - generator.writeKey("_primary_term"); - generator.write(this.primaryTerm); - - } - if (this.routing != null) { - generator.writeKey("_routing"); - generator.write(this.routing); - - } - generator.writeKey("_source"); - JsonpUtils.serialize(this.source, generator, tDocumentSerializer, mapper); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link InlineGet}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder> { - @Nullable - private Map metadata = new HashMap<>(); - - /** - * Document metadata - *

- * Adds all entries of map to metadata. - */ - public final Builder metadata(Map map) { - this.metadata = _mapPutAll(this.metadata, map); - return this; - } - - /** - * Document metadata - *

- * Adds an entry to metadata. - */ - public final Builder metadata(String key, JsonData value) { - this.metadata = _mapPut(this.metadata, key, value); - return this; - } - - @Nullable - private Map fields; - - private Boolean found; - - @Nullable - private Long seqNo; - - @Nullable - private Long primaryTerm; - - @Nullable - private String routing; - - private TDocument source; - - @Nullable - private JsonpSerializer tDocumentSerializer; - - /** - * API name: {@code fields} - *

- * Adds all entries of map to fields. - */ - public final Builder fields(Map map) { - this.fields = _mapPutAll(this.fields, map); - return this; - } - - /** - * API name: {@code fields} - *

- * Adds an entry to fields. - */ - public final Builder fields(String key, JsonData value) { - this.fields = _mapPut(this.fields, key, value); - return this; - } - - /** - * Required - API name: {@code found} - */ - public final Builder found(boolean value) { - this.found = value; - return this; - } - - /** - * API name: {@code _seq_no} - */ - public final Builder seqNo(@Nullable Long value) { - this.seqNo = value; - return this; - } - - /** - * API name: {@code _primary_term} - */ - public final Builder primaryTerm(@Nullable Long value) { - this.primaryTerm = value; - return this; - } - - /** - * API name: {@code _routing} - */ - public final Builder routing(@Nullable String value) { - this.routing = value; - return this; - } - - /** - * Required - API name: {@code _source} - */ - public final Builder source(TDocument value) { - this.source = value; - return this; - } - - /** - * Serializer for TDocument. If not set, an attempt will be made to find a - * serializer from the JSON context. - */ - public final Builder tDocumentSerializer(@Nullable JsonpSerializer value) { - this.tDocumentSerializer = value; - return this; - } - - /** - * Builds a {@link InlineGet}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public InlineGet build() { - _checkSingleUse(); - - return new InlineGet(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Create a JSON deserializer for InlineGet - */ - public static JsonpDeserializer> createInlineGetDeserializer( - JsonpDeserializer tDocumentDeserializer) { - return ObjectBuilderDeserializer.createForObject((Supplier>) Builder::new, - op -> InlineGet.setupInlineGetDeserializer(op, tDocumentDeserializer)); - }; - - protected static void setupInlineGetDeserializer(ObjectDeserializer> op, - JsonpDeserializer tDocumentDeserializer) { - - op.add(Builder::fields, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "fields"); - op.add(Builder::found, JsonpDeserializer.booleanDeserializer(), "found"); - op.add(Builder::seqNo, JsonpDeserializer.longDeserializer(), "_seq_no"); - op.add(Builder::primaryTerm, JsonpDeserializer.longDeserializer(), "_primary_term"); - op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "_routing"); - op.add(Builder::source, tDocumentDeserializer, "_source"); - - op.setUnknownFieldHandler((builder, name, parser, mapper) -> { - if (builder.metadata == null) { - builder.metadata = new HashMap<>(); - } - builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); - }); - - } + private final Map metadata; + + private final Map fields; + + private final boolean found; + + @Nullable + private final Long seqNo; + + @Nullable + private final Long primaryTerm; + + @Nullable + private final String routing; + + private final TDocument source; + + @Nullable + private final JsonpSerializer tDocumentSerializer; + + // --------------------------------------------------------------------------------------------- + + private InlineGet(Builder builder) { + + this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); + + this.fields = ApiTypeHelper.unmodifiable(builder.fields); + this.found = ApiTypeHelper.requireNonNull(builder.found, this, "found"); + this.seqNo = builder.seqNo; + this.primaryTerm = builder.primaryTerm; + this.routing = builder.routing; + this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); + this.tDocumentSerializer = builder.tDocumentSerializer; + + } + + public static InlineGet of(Function, ObjectBuilder>> fn) { + return fn.apply(new Builder<>()).build(); + } + + /** + * Document metadata + */ + public final Map metadata() { + return this.metadata; + } + + /** + * API name: {@code fields} + */ + public final Map fields() { + return this.fields; + } + + /** + * Required - API name: {@code found} + */ + public final boolean found() { + return this.found; + } + + /** + * API name: {@code _seq_no} + */ + @Nullable + public final Long seqNo() { + return this.seqNo; + } + + /** + * API name: {@code _primary_term} + */ + @Nullable + public final Long primaryTerm() { + return this.primaryTerm; + } + + /** + * API name: {@code _routing} + */ + @Nullable + public final String routing() { + return this.routing; + } + + /** + * Required - API name: {@code _source} + */ + public final TDocument source() { + return this.source; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + for (Map.Entry item0 : this.metadata.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + + if (ApiTypeHelper.isDefined(this.fields)) { + generator.writeKey("fields"); + generator.writeStartObject(); + for (Map.Entry item0 : this.fields.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("found"); + generator.write(this.found); + + if (this.seqNo != null) { + generator.writeKey("_seq_no"); + generator.write(this.seqNo); + + } + if (this.primaryTerm != null) { + generator.writeKey("_primary_term"); + generator.write(this.primaryTerm); + + } + if (this.routing != null) { + generator.writeKey("_routing"); + generator.write(this.routing); + + } + generator.writeKey("_source"); + JsonpUtils.serialize(this.source, generator, tDocumentSerializer, mapper); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link InlineGet}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder> { + @Nullable + private Map metadata = new HashMap<>(); + + /** + * Document metadata + *

+ * Adds all entries of map to metadata. + */ + public final Builder metadata(Map map) { + this.metadata = _mapPutAll(this.metadata, map); + return this; + } + + /** + * Document metadata + *

+ * Adds an entry to metadata. + */ + public final Builder metadata(String key, JsonData value) { + this.metadata = _mapPut(this.metadata, key, value); + return this; + } + + @Nullable + private Map fields; + + private Boolean found; + + @Nullable + private Long seqNo; + + @Nullable + private Long primaryTerm; + + @Nullable + private String routing; + + private TDocument source; + + @Nullable + private JsonpSerializer tDocumentSerializer; + + /** + * API name: {@code fields} + *

+ * Adds all entries of map to fields. + */ + public final Builder fields(Map map) { + this.fields = _mapPutAll(this.fields, map); + return this; + } + + /** + * API name: {@code fields} + *

+ * Adds an entry to fields. + */ + public final Builder fields(String key, JsonData value) { + this.fields = _mapPut(this.fields, key, value); + return this; + } + + /** + * Required - API name: {@code found} + */ + public final Builder found(boolean value) { + this.found = value; + return this; + } + + /** + * API name: {@code _seq_no} + */ + public final Builder seqNo(@Nullable Long value) { + this.seqNo = value; + return this; + } + + /** + * API name: {@code _primary_term} + */ + public final Builder primaryTerm(@Nullable Long value) { + this.primaryTerm = value; + return this; + } + + /** + * API name: {@code _routing} + */ + public final Builder routing(@Nullable String value) { + this.routing = value; + return this; + } + + /** + * Required - API name: {@code _source} + */ + public final Builder source(TDocument value) { + this.source = value; + return this; + } + + /** + * Serializer for TDocument. If not set, an attempt will be made to find a + * serializer from the JSON context. + */ + public final Builder tDocumentSerializer(@Nullable JsonpSerializer value) { + this.tDocumentSerializer = value; + return this; + } + + /** + * Builds a {@link InlineGet}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public InlineGet build() { + _checkSingleUse(); + + return new InlineGet(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Create a JSON deserializer for InlineGet + */ + public static JsonpDeserializer> createInlineGetDeserializer( + JsonpDeserializer tDocumentDeserializer + ) { + return ObjectBuilderDeserializer.createForObject( + (Supplier>) Builder::new, + op -> InlineGet.setupInlineGetDeserializer(op, tDocumentDeserializer) + ); + }; + + protected static void setupInlineGetDeserializer( + ObjectDeserializer> op, + JsonpDeserializer tDocumentDeserializer + ) { + + op.add(Builder::fields, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "fields"); + op.add(Builder::found, JsonpDeserializer.booleanDeserializer(), "found"); + op.add(Builder::seqNo, JsonpDeserializer.longDeserializer(), "_seq_no"); + op.add(Builder::primaryTerm, JsonpDeserializer.longDeserializer(), "_primary_term"); + op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "_routing"); + op.add(Builder::source, tDocumentDeserializer, "_source"); + + op.setUnknownFieldHandler((builder, name, parser, mapper) -> { + if (builder.metadata == null) { + builder.metadata = new HashMap<>(); + } + builder.metadata.put(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java index 49d81d106e..be2177029b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/InlineScript.java @@ -30,12 +30,12 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -43,169 +43,166 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; -import jakarta.json.stream.JsonGenerator; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.InlineScript @JsonpDeserializable public class InlineScript extends ScriptBase { - @Nullable - private final String lang; - - private final Map options; - - private final String source; - - // --------------------------------------------------------------------------------------------- - - private InlineScript(Builder builder) { - super(builder); - - this.lang = builder.lang; - this.options = ApiTypeHelper.unmodifiable(builder.options); - this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); - - } - - public static InlineScript of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code lang} - */ - @Nullable - public final String lang() { - return this.lang; - } - - /** - * API name: {@code options} - */ - public final Map options() { - return this.options; - } - - /** - * Required - API name: {@code source} - */ - public final String source() { - return this.source; - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - super.serializeInternal(generator, mapper); - if (this.lang != null) { - generator.writeKey("lang"); - generator.write(this.lang); - - } - if (ApiTypeHelper.isDefined(this.options)) { - generator.writeKey("options"); - generator.writeStartObject(); - for (Map.Entry item0 : this.options.entrySet()) { - generator.writeKey(item0.getKey()); - generator.write(item0.getValue()); - - } - generator.writeEnd(); - - } - generator.writeKey("source"); - generator.write(this.source); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link InlineScript}. - */ - - public static class Builder extends ScriptBase.AbstractBuilder implements ObjectBuilder { - @Nullable - private String lang; - - @Nullable - private Map options; - - private String source; - - /** - * API name: {@code lang} - */ - public final Builder lang(@Nullable String value) { - this.lang = value; - return this; - } - - /** - * API name: {@code options} - *

- * Adds all entries of map to options. - */ - public final Builder options(Map map) { - this.options = _mapPutAll(this.options, map); - return this; - } - - /** - * API name: {@code options} - *

- * Adds an entry to options. - */ - public final Builder options(String key, String value) { - this.options = _mapPut(this.options, key, value); - return this; - } - - /** - * Required - API name: {@code source} - */ - public final Builder source(String value) { - this.source = value; - return this; - } - - @Override - protected Builder self() { - return this; - } - - /** - * Builds a {@link InlineScript}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public InlineScript build() { - _checkSingleUse(); - - return new InlineScript(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link InlineScript} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - InlineScript::setupInlineScriptDeserializer); - - protected static void setupInlineScriptDeserializer(ObjectDeserializer op) { - ScriptBase.setupScriptBaseDeserializer(op); - op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang"); - op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), - "options"); - op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); - - op.shortcutProperty("source"); - - } + @Nullable + private final String lang; + + private final Map options; + + private final String source; + + // --------------------------------------------------------------------------------------------- + + private InlineScript(Builder builder) { + super(builder); + + this.lang = builder.lang; + this.options = ApiTypeHelper.unmodifiable(builder.options); + this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); + + } + + public static InlineScript of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code lang} + */ + @Nullable + public final String lang() { + return this.lang; + } + + /** + * API name: {@code options} + */ + public final Map options() { + return this.options; + } + + /** + * Required - API name: {@code source} + */ + public final String source() { + return this.source; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (this.lang != null) { + generator.writeKey("lang"); + generator.write(this.lang); + + } + if (ApiTypeHelper.isDefined(this.options)) { + generator.writeKey("options"); + generator.writeStartObject(); + for (Map.Entry item0 : this.options.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + + } + generator.writeKey("source"); + generator.write(this.source); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link InlineScript}. + */ + + public static class Builder extends ScriptBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private String lang; + + @Nullable + private Map options; + + private String source; + + /** + * API name: {@code lang} + */ + public final Builder lang(@Nullable String value) { + this.lang = value; + return this; + } + + /** + * API name: {@code options} + *

+ * Adds all entries of map to options. + */ + public final Builder options(Map map) { + this.options = _mapPutAll(this.options, map); + return this; + } + + /** + * API name: {@code options} + *

+ * Adds an entry to options. + */ + public final Builder options(String key, String value) { + this.options = _mapPut(this.options, key, value); + return this; + } + + /** + * Required - API name: {@code source} + */ + public final Builder source(String value) { + this.source = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link InlineScript}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public InlineScript build() { + _checkSingleUse(); + + return new InlineScript(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link InlineScript} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + InlineScript::setupInlineScriptDeserializer + ); + + protected static void setupInlineScriptDeserializer(ObjectDeserializer op) { + ScriptBase.setupScriptBaseDeserializer(op); + op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang"); + op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "options"); + op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source"); + + op.shortcutProperty("source"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/LatLonGeoLocation.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/LatLonGeoLocation.java index 75e4ec749f..986416874a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/LatLonGeoLocation.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/LatLonGeoLocation.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,116 +43,116 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.LatLonGeoLocation @JsonpDeserializable public class LatLonGeoLocation implements JsonpSerializable { - private final double lat; - - private final double lon; - - // --------------------------------------------------------------------------------------------- + private final double lat; - private LatLonGeoLocation(Builder builder) { + private final double lon; + + // --------------------------------------------------------------------------------------------- - this.lat = ApiTypeHelper.requireNonNull(builder.lat, this, "lat"); - this.lon = ApiTypeHelper.requireNonNull(builder.lon, this, "lon"); + private LatLonGeoLocation(Builder builder) { - } + this.lat = ApiTypeHelper.requireNonNull(builder.lat, this, "lat"); + this.lon = ApiTypeHelper.requireNonNull(builder.lon, this, "lon"); - public static LatLonGeoLocation of(Function> fn) { - return fn.apply(new Builder()).build(); - } + } - /** - * Required - API name: {@code lat} - */ - public final double lat() { - return this.lat; - } + public static LatLonGeoLocation of(Function> fn) { + return fn.apply(new Builder()).build(); + } - /** - * Required - API name: {@code lon} - */ - public final double lon() { - return this.lon; - } + /** + * Required - API name: {@code lat} + */ + public final double lat() { + return this.lat; + } - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } + /** + * Required - API name: {@code lon} + */ + public final double lon() { + return this.lon; + } - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } - generator.writeKey("lat"); - generator.write(this.lat); + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("lon"); - generator.write(this.lon); + generator.writeKey("lat"); + generator.write(this.lat); - } + generator.writeKey("lon"); + generator.write(this.lon); - // --------------------------------------------------------------------------------------------- + } - /** - * Builder for {@link LatLonGeoLocation}. - */ + // --------------------------------------------------------------------------------------------- - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Double lat; + /** + * Builder for {@link LatLonGeoLocation}. + */ - private Double lon; + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Double lat; - /** - * Required - API name: {@code lat} - */ - public final Builder lat(double value) { - this.lat = value; - return this; - } + private Double lon; - /** - * Required - API name: {@code lon} - */ - public final Builder lon(double value) { - this.lon = value; - return this; - } + /** + * Required - API name: {@code lat} + */ + public final Builder lat(double value) { + this.lat = value; + return this; + } - /** - * Builds a {@link LatLonGeoLocation}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public LatLonGeoLocation build() { - _checkSingleUse(); + /** + * Required - API name: {@code lon} + */ + public final Builder lon(double value) { + this.lon = value; + return this; + } - return new LatLonGeoLocation(this); - } - } + /** + * Builds a {@link LatLonGeoLocation}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public LatLonGeoLocation build() { + _checkSingleUse(); - // --------------------------------------------------------------------------------------------- + return new LatLonGeoLocation(this); + } + } - /** - * Json deserializer for {@link LatLonGeoLocation} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, LatLonGeoLocation::setupLatLonGeoLocationDeserializer); + // --------------------------------------------------------------------------------------------- - protected static void setupLatLonGeoLocationDeserializer(ObjectDeserializer op) { + /** + * Json deserializer for {@link LatLonGeoLocation} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + LatLonGeoLocation::setupLatLonGeoLocationDeserializer + ); - op.add(Builder::lat, JsonpDeserializer.doubleDeserializer(), "lat"); - op.add(Builder::lon, JsonpDeserializer.doubleDeserializer(), "lon"); + protected static void setupLatLonGeoLocationDeserializer(ObjectDeserializer op) { - } + op.add(Builder::lat, JsonpDeserializer.doubleDeserializer(), "lat"); + op.add(Builder::lon, JsonpDeserializer.doubleDeserializer(), "lon"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Level.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Level.java index 5fddb6249f..a7df990bb7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Level.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Level.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,23 +37,23 @@ @JsonpDeserializable public enum Level implements JsonEnum { - Cluster("cluster"), + Cluster("cluster"), - Indices("indices"), + Indices("indices"), - Shards("shards"), + Shards("shards"), - ; + ; - private final String jsonValue; + private final String jsonValue; - Level(String jsonValue) { - this.jsonValue = jsonValue; - } + Level(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Level.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Level.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/LifecycleOperationMode.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/LifecycleOperationMode.java index b57a8e214b..71cd0307ce 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/LifecycleOperationMode.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/LifecycleOperationMode.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,24 +37,25 @@ @JsonpDeserializable public enum LifecycleOperationMode implements JsonEnum { - Running("RUNNING"), + Running("RUNNING"), - Stopping("STOPPING"), + Stopping("STOPPING"), - Stopped("STOPPED"), + Stopped("STOPPED"), - ; + ; - private final String jsonValue; + private final String jsonValue; - LifecycleOperationMode(String jsonValue) { - this.jsonValue = jsonValue; - } + LifecycleOperationMode(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( - LifecycleOperationMode.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>( + LifecycleOperationMode.values() + ); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/MergesStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/MergesStats.java index 6b60da03f0..7a09b9de4a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/MergesStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/MergesStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,487 +44,486 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.MergesStats @JsonpDeserializable public class MergesStats implements JsonpSerializable { - private final long current; - - private final long currentDocs; + private final long current; - @Nullable - private final String currentSize; + private final long currentDocs; + + @Nullable + private final String currentSize; - private final long currentSizeInBytes; - - private final long total; - - @Nullable - private final String totalAutoThrottle; - - private final long totalAutoThrottleInBytes; - - private final long totalDocs; - - @Nullable - private final String totalSize; - - private final long totalSizeInBytes; - - @Nullable - private final String totalStoppedTime; - - private final long totalStoppedTimeInMillis; - - @Nullable - private final String totalThrottledTime; - - private final long totalThrottledTimeInMillis; - - @Nullable - private final String totalTime; - - private final long totalTimeInMillis; - - // --------------------------------------------------------------------------------------------- - - private MergesStats(Builder builder) { - - this.current = ApiTypeHelper.requireNonNull(builder.current, this, "current"); - this.currentDocs = ApiTypeHelper.requireNonNull(builder.currentDocs, this, "currentDocs"); - this.currentSize = builder.currentSize; - this.currentSizeInBytes = ApiTypeHelper.requireNonNull(builder.currentSizeInBytes, this, "currentSizeInBytes"); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - this.totalAutoThrottle = builder.totalAutoThrottle; - this.totalAutoThrottleInBytes = ApiTypeHelper.requireNonNull(builder.totalAutoThrottleInBytes, this, - "totalAutoThrottleInBytes"); - this.totalDocs = ApiTypeHelper.requireNonNull(builder.totalDocs, this, "totalDocs"); - this.totalSize = builder.totalSize; - this.totalSizeInBytes = ApiTypeHelper.requireNonNull(builder.totalSizeInBytes, this, "totalSizeInBytes"); - this.totalStoppedTime = builder.totalStoppedTime; - this.totalStoppedTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalStoppedTimeInMillis, this, - "totalStoppedTimeInMillis"); - this.totalThrottledTime = builder.totalThrottledTime; - this.totalThrottledTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalThrottledTimeInMillis, this, - "totalThrottledTimeInMillis"); - this.totalTime = builder.totalTime; - this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); - - } - - public static MergesStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code current} - */ - public final long current() { - return this.current; - } - - /** - * Required - API name: {@code current_docs} - */ - public final long currentDocs() { - return this.currentDocs; - } - - /** - * API name: {@code current_size} - */ - @Nullable - public final String currentSize() { - return this.currentSize; - } - - /** - * Required - API name: {@code current_size_in_bytes} - */ - public final long currentSizeInBytes() { - return this.currentSizeInBytes; - } - - /** - * Required - API name: {@code total} - */ - public final long total() { - return this.total; - } - - /** - * API name: {@code total_auto_throttle} - */ - @Nullable - public final String totalAutoThrottle() { - return this.totalAutoThrottle; - } - - /** - * Required - API name: {@code total_auto_throttle_in_bytes} - */ - public final long totalAutoThrottleInBytes() { - return this.totalAutoThrottleInBytes; - } - - /** - * Required - API name: {@code total_docs} - */ - public final long totalDocs() { - return this.totalDocs; - } - - /** - * API name: {@code total_size} - */ - @Nullable - public final String totalSize() { - return this.totalSize; - } - - /** - * Required - API name: {@code total_size_in_bytes} - */ - public final long totalSizeInBytes() { - return this.totalSizeInBytes; - } - - /** - * API name: {@code total_stopped_time} - */ - @Nullable - public final String totalStoppedTime() { - return this.totalStoppedTime; - } - - /** - * Required - API name: {@code total_stopped_time_in_millis} - */ - public final long totalStoppedTimeInMillis() { - return this.totalStoppedTimeInMillis; - } - - /** - * API name: {@code total_throttled_time} - */ - @Nullable - public final String totalThrottledTime() { - return this.totalThrottledTime; - } - - /** - * Required - API name: {@code total_throttled_time_in_millis} - */ - public final long totalThrottledTimeInMillis() { - return this.totalThrottledTimeInMillis; - } - - /** - * API name: {@code total_time} - */ - @Nullable - public final String totalTime() { - return this.totalTime; - } - - /** - * Required - API name: {@code total_time_in_millis} - */ - public final long totalTimeInMillis() { - return this.totalTimeInMillis; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("current"); - generator.write(this.current); - - generator.writeKey("current_docs"); - generator.write(this.currentDocs); - - if (this.currentSize != null) { - generator.writeKey("current_size"); - generator.write(this.currentSize); - - } - generator.writeKey("current_size_in_bytes"); - generator.write(this.currentSizeInBytes); - - generator.writeKey("total"); - generator.write(this.total); - - if (this.totalAutoThrottle != null) { - generator.writeKey("total_auto_throttle"); - generator.write(this.totalAutoThrottle); - - } - generator.writeKey("total_auto_throttle_in_bytes"); - generator.write(this.totalAutoThrottleInBytes); - - generator.writeKey("total_docs"); - generator.write(this.totalDocs); - - if (this.totalSize != null) { - generator.writeKey("total_size"); - generator.write(this.totalSize); - - } - generator.writeKey("total_size_in_bytes"); - generator.write(this.totalSizeInBytes); - - if (this.totalStoppedTime != null) { - generator.writeKey("total_stopped_time"); - generator.write(this.totalStoppedTime); - - } - generator.writeKey("total_stopped_time_in_millis"); - generator.write(this.totalStoppedTimeInMillis); - - if (this.totalThrottledTime != null) { - generator.writeKey("total_throttled_time"); - generator.write(this.totalThrottledTime); - - } - generator.writeKey("total_throttled_time_in_millis"); - generator.write(this.totalThrottledTimeInMillis); - - if (this.totalTime != null) { - generator.writeKey("total_time"); - generator.write(this.totalTime); - - } - generator.writeKey("total_time_in_millis"); - generator.write(this.totalTimeInMillis); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link MergesStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long current; - - private Long currentDocs; - - @Nullable - private String currentSize; - - private Long currentSizeInBytes; - - private Long total; - - @Nullable - private String totalAutoThrottle; - - private Long totalAutoThrottleInBytes; - - private Long totalDocs; - - @Nullable - private String totalSize; - - private Long totalSizeInBytes; - - @Nullable - private String totalStoppedTime; - - private Long totalStoppedTimeInMillis; - - @Nullable - private String totalThrottledTime; - - private Long totalThrottledTimeInMillis; - - @Nullable - private String totalTime; - - private Long totalTimeInMillis; - - /** - * Required - API name: {@code current} - */ - public final Builder current(long value) { - this.current = value; - return this; - } - - /** - * Required - API name: {@code current_docs} - */ - public final Builder currentDocs(long value) { - this.currentDocs = value; - return this; - } - - /** - * API name: {@code current_size} - */ - public final Builder currentSize(@Nullable String value) { - this.currentSize = value; - return this; - } - - /** - * Required - API name: {@code current_size_in_bytes} - */ - public final Builder currentSizeInBytes(long value) { - this.currentSizeInBytes = value; - return this; - } - - /** - * Required - API name: {@code total} - */ - public final Builder total(long value) { - this.total = value; - return this; - } - - /** - * API name: {@code total_auto_throttle} - */ - public final Builder totalAutoThrottle(@Nullable String value) { - this.totalAutoThrottle = value; - return this; - } - - /** - * Required - API name: {@code total_auto_throttle_in_bytes} - */ - public final Builder totalAutoThrottleInBytes(long value) { - this.totalAutoThrottleInBytes = value; - return this; - } - - /** - * Required - API name: {@code total_docs} - */ - public final Builder totalDocs(long value) { - this.totalDocs = value; - return this; - } - - /** - * API name: {@code total_size} - */ - public final Builder totalSize(@Nullable String value) { - this.totalSize = value; - return this; - } - - /** - * Required - API name: {@code total_size_in_bytes} - */ - public final Builder totalSizeInBytes(long value) { - this.totalSizeInBytes = value; - return this; - } - - /** - * API name: {@code total_stopped_time} - */ - public final Builder totalStoppedTime(@Nullable String value) { - this.totalStoppedTime = value; - return this; - } - - /** - * Required - API name: {@code total_stopped_time_in_millis} - */ - public final Builder totalStoppedTimeInMillis(long value) { - this.totalStoppedTimeInMillis = value; - return this; - } - - /** - * API name: {@code total_throttled_time} - */ - public final Builder totalThrottledTime(@Nullable String value) { - this.totalThrottledTime = value; - return this; - } - - /** - * Required - API name: {@code total_throttled_time_in_millis} - */ - public final Builder totalThrottledTimeInMillis(long value) { - this.totalThrottledTimeInMillis = value; - return this; - } - - /** - * API name: {@code total_time} - */ - public final Builder totalTime(@Nullable String value) { - this.totalTime = value; - return this; - } - - /** - * Required - API name: {@code total_time_in_millis} - */ - public final Builder totalTimeInMillis(long value) { - this.totalTimeInMillis = value; - return this; - } - - /** - * Builds a {@link MergesStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public MergesStats build() { - _checkSingleUse(); - - return new MergesStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link MergesStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - MergesStats::setupMergesStatsDeserializer); - - protected static void setupMergesStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::current, JsonpDeserializer.longDeserializer(), "current"); - op.add(Builder::currentDocs, JsonpDeserializer.longDeserializer(), "current_docs"); - op.add(Builder::currentSize, JsonpDeserializer.stringDeserializer(), "current_size"); - op.add(Builder::currentSizeInBytes, JsonpDeserializer.longDeserializer(), "current_size_in_bytes"); - op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); - op.add(Builder::totalAutoThrottle, JsonpDeserializer.stringDeserializer(), "total_auto_throttle"); - op.add(Builder::totalAutoThrottleInBytes, JsonpDeserializer.longDeserializer(), "total_auto_throttle_in_bytes"); - op.add(Builder::totalDocs, JsonpDeserializer.longDeserializer(), "total_docs"); - op.add(Builder::totalSize, JsonpDeserializer.stringDeserializer(), "total_size"); - op.add(Builder::totalSizeInBytes, JsonpDeserializer.longDeserializer(), "total_size_in_bytes"); - op.add(Builder::totalStoppedTime, JsonpDeserializer.stringDeserializer(), "total_stopped_time"); - op.add(Builder::totalStoppedTimeInMillis, JsonpDeserializer.longDeserializer(), "total_stopped_time_in_millis"); - op.add(Builder::totalThrottledTime, JsonpDeserializer.stringDeserializer(), "total_throttled_time"); - op.add(Builder::totalThrottledTimeInMillis, JsonpDeserializer.longDeserializer(), - "total_throttled_time_in_millis"); - op.add(Builder::totalTime, JsonpDeserializer.stringDeserializer(), "total_time"); - op.add(Builder::totalTimeInMillis, JsonpDeserializer.longDeserializer(), "total_time_in_millis"); - - } + private final long currentSizeInBytes; + + private final long total; + + @Nullable + private final String totalAutoThrottle; + + private final long totalAutoThrottleInBytes; + + private final long totalDocs; + + @Nullable + private final String totalSize; + + private final long totalSizeInBytes; + + @Nullable + private final String totalStoppedTime; + + private final long totalStoppedTimeInMillis; + + @Nullable + private final String totalThrottledTime; + + private final long totalThrottledTimeInMillis; + + @Nullable + private final String totalTime; + + private final long totalTimeInMillis; + + // --------------------------------------------------------------------------------------------- + + private MergesStats(Builder builder) { + + this.current = ApiTypeHelper.requireNonNull(builder.current, this, "current"); + this.currentDocs = ApiTypeHelper.requireNonNull(builder.currentDocs, this, "currentDocs"); + this.currentSize = builder.currentSize; + this.currentSizeInBytes = ApiTypeHelper.requireNonNull(builder.currentSizeInBytes, this, "currentSizeInBytes"); + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); + this.totalAutoThrottle = builder.totalAutoThrottle; + this.totalAutoThrottleInBytes = ApiTypeHelper.requireNonNull(builder.totalAutoThrottleInBytes, this, "totalAutoThrottleInBytes"); + this.totalDocs = ApiTypeHelper.requireNonNull(builder.totalDocs, this, "totalDocs"); + this.totalSize = builder.totalSize; + this.totalSizeInBytes = ApiTypeHelper.requireNonNull(builder.totalSizeInBytes, this, "totalSizeInBytes"); + this.totalStoppedTime = builder.totalStoppedTime; + this.totalStoppedTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalStoppedTimeInMillis, this, "totalStoppedTimeInMillis"); + this.totalThrottledTime = builder.totalThrottledTime; + this.totalThrottledTimeInMillis = ApiTypeHelper.requireNonNull( + builder.totalThrottledTimeInMillis, + this, + "totalThrottledTimeInMillis" + ); + this.totalTime = builder.totalTime; + this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); + + } + + public static MergesStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code current} + */ + public final long current() { + return this.current; + } + + /** + * Required - API name: {@code current_docs} + */ + public final long currentDocs() { + return this.currentDocs; + } + + /** + * API name: {@code current_size} + */ + @Nullable + public final String currentSize() { + return this.currentSize; + } + + /** + * Required - API name: {@code current_size_in_bytes} + */ + public final long currentSizeInBytes() { + return this.currentSizeInBytes; + } + + /** + * Required - API name: {@code total} + */ + public final long total() { + return this.total; + } + + /** + * API name: {@code total_auto_throttle} + */ + @Nullable + public final String totalAutoThrottle() { + return this.totalAutoThrottle; + } + + /** + * Required - API name: {@code total_auto_throttle_in_bytes} + */ + public final long totalAutoThrottleInBytes() { + return this.totalAutoThrottleInBytes; + } + + /** + * Required - API name: {@code total_docs} + */ + public final long totalDocs() { + return this.totalDocs; + } + + /** + * API name: {@code total_size} + */ + @Nullable + public final String totalSize() { + return this.totalSize; + } + + /** + * Required - API name: {@code total_size_in_bytes} + */ + public final long totalSizeInBytes() { + return this.totalSizeInBytes; + } + + /** + * API name: {@code total_stopped_time} + */ + @Nullable + public final String totalStoppedTime() { + return this.totalStoppedTime; + } + + /** + * Required - API name: {@code total_stopped_time_in_millis} + */ + public final long totalStoppedTimeInMillis() { + return this.totalStoppedTimeInMillis; + } + + /** + * API name: {@code total_throttled_time} + */ + @Nullable + public final String totalThrottledTime() { + return this.totalThrottledTime; + } + + /** + * Required - API name: {@code total_throttled_time_in_millis} + */ + public final long totalThrottledTimeInMillis() { + return this.totalThrottledTimeInMillis; + } + + /** + * API name: {@code total_time} + */ + @Nullable + public final String totalTime() { + return this.totalTime; + } + + /** + * Required - API name: {@code total_time_in_millis} + */ + public final long totalTimeInMillis() { + return this.totalTimeInMillis; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("current"); + generator.write(this.current); + + generator.writeKey("current_docs"); + generator.write(this.currentDocs); + + if (this.currentSize != null) { + generator.writeKey("current_size"); + generator.write(this.currentSize); + + } + generator.writeKey("current_size_in_bytes"); + generator.write(this.currentSizeInBytes); + + generator.writeKey("total"); + generator.write(this.total); + + if (this.totalAutoThrottle != null) { + generator.writeKey("total_auto_throttle"); + generator.write(this.totalAutoThrottle); + + } + generator.writeKey("total_auto_throttle_in_bytes"); + generator.write(this.totalAutoThrottleInBytes); + + generator.writeKey("total_docs"); + generator.write(this.totalDocs); + + if (this.totalSize != null) { + generator.writeKey("total_size"); + generator.write(this.totalSize); + + } + generator.writeKey("total_size_in_bytes"); + generator.write(this.totalSizeInBytes); + + if (this.totalStoppedTime != null) { + generator.writeKey("total_stopped_time"); + generator.write(this.totalStoppedTime); + + } + generator.writeKey("total_stopped_time_in_millis"); + generator.write(this.totalStoppedTimeInMillis); + + if (this.totalThrottledTime != null) { + generator.writeKey("total_throttled_time"); + generator.write(this.totalThrottledTime); + + } + generator.writeKey("total_throttled_time_in_millis"); + generator.write(this.totalThrottledTimeInMillis); + + if (this.totalTime != null) { + generator.writeKey("total_time"); + generator.write(this.totalTime); + + } + generator.writeKey("total_time_in_millis"); + generator.write(this.totalTimeInMillis); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link MergesStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long current; + + private Long currentDocs; + + @Nullable + private String currentSize; + + private Long currentSizeInBytes; + + private Long total; + + @Nullable + private String totalAutoThrottle; + + private Long totalAutoThrottleInBytes; + + private Long totalDocs; + + @Nullable + private String totalSize; + + private Long totalSizeInBytes; + + @Nullable + private String totalStoppedTime; + + private Long totalStoppedTimeInMillis; + + @Nullable + private String totalThrottledTime; + + private Long totalThrottledTimeInMillis; + + @Nullable + private String totalTime; + + private Long totalTimeInMillis; + + /** + * Required - API name: {@code current} + */ + public final Builder current(long value) { + this.current = value; + return this; + } + + /** + * Required - API name: {@code current_docs} + */ + public final Builder currentDocs(long value) { + this.currentDocs = value; + return this; + } + + /** + * API name: {@code current_size} + */ + public final Builder currentSize(@Nullable String value) { + this.currentSize = value; + return this; + } + + /** + * Required - API name: {@code current_size_in_bytes} + */ + public final Builder currentSizeInBytes(long value) { + this.currentSizeInBytes = value; + return this; + } + + /** + * Required - API name: {@code total} + */ + public final Builder total(long value) { + this.total = value; + return this; + } + + /** + * API name: {@code total_auto_throttle} + */ + public final Builder totalAutoThrottle(@Nullable String value) { + this.totalAutoThrottle = value; + return this; + } + + /** + * Required - API name: {@code total_auto_throttle_in_bytes} + */ + public final Builder totalAutoThrottleInBytes(long value) { + this.totalAutoThrottleInBytes = value; + return this; + } + + /** + * Required - API name: {@code total_docs} + */ + public final Builder totalDocs(long value) { + this.totalDocs = value; + return this; + } + + /** + * API name: {@code total_size} + */ + public final Builder totalSize(@Nullable String value) { + this.totalSize = value; + return this; + } + + /** + * Required - API name: {@code total_size_in_bytes} + */ + public final Builder totalSizeInBytes(long value) { + this.totalSizeInBytes = value; + return this; + } + + /** + * API name: {@code total_stopped_time} + */ + public final Builder totalStoppedTime(@Nullable String value) { + this.totalStoppedTime = value; + return this; + } + + /** + * Required - API name: {@code total_stopped_time_in_millis} + */ + public final Builder totalStoppedTimeInMillis(long value) { + this.totalStoppedTimeInMillis = value; + return this; + } + + /** + * API name: {@code total_throttled_time} + */ + public final Builder totalThrottledTime(@Nullable String value) { + this.totalThrottledTime = value; + return this; + } + + /** + * Required - API name: {@code total_throttled_time_in_millis} + */ + public final Builder totalThrottledTimeInMillis(long value) { + this.totalThrottledTimeInMillis = value; + return this; + } + + /** + * API name: {@code total_time} + */ + public final Builder totalTime(@Nullable String value) { + this.totalTime = value; + return this; + } + + /** + * Required - API name: {@code total_time_in_millis} + */ + public final Builder totalTimeInMillis(long value) { + this.totalTimeInMillis = value; + return this; + } + + /** + * Builds a {@link MergesStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public MergesStats build() { + _checkSingleUse(); + + return new MergesStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link MergesStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + MergesStats::setupMergesStatsDeserializer + ); + + protected static void setupMergesStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::current, JsonpDeserializer.longDeserializer(), "current"); + op.add(Builder::currentDocs, JsonpDeserializer.longDeserializer(), "current_docs"); + op.add(Builder::currentSize, JsonpDeserializer.stringDeserializer(), "current_size"); + op.add(Builder::currentSizeInBytes, JsonpDeserializer.longDeserializer(), "current_size_in_bytes"); + op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); + op.add(Builder::totalAutoThrottle, JsonpDeserializer.stringDeserializer(), "total_auto_throttle"); + op.add(Builder::totalAutoThrottleInBytes, JsonpDeserializer.longDeserializer(), "total_auto_throttle_in_bytes"); + op.add(Builder::totalDocs, JsonpDeserializer.longDeserializer(), "total_docs"); + op.add(Builder::totalSize, JsonpDeserializer.stringDeserializer(), "total_size"); + op.add(Builder::totalSizeInBytes, JsonpDeserializer.longDeserializer(), "total_size_in_bytes"); + op.add(Builder::totalStoppedTime, JsonpDeserializer.stringDeserializer(), "total_stopped_time"); + op.add(Builder::totalStoppedTimeInMillis, JsonpDeserializer.longDeserializer(), "total_stopped_time_in_millis"); + op.add(Builder::totalThrottledTime, JsonpDeserializer.stringDeserializer(), "total_throttled_time"); + op.add(Builder::totalThrottledTimeInMillis, JsonpDeserializer.longDeserializer(), "total_throttled_time_in_millis"); + op.add(Builder::totalTime, JsonpDeserializer.stringDeserializer(), "total_time"); + op.add(Builder::totalTimeInMillis, JsonpDeserializer.longDeserializer(), "total_time_in_millis"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NestedSortValue.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NestedSortValue.java index bc66595a7e..366abbca50 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NestedSortValue.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NestedSortValue.java @@ -30,211 +30,208 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; -import org.opensearch.client.opensearch._types.query_dsl.Query; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.opensearch._types.query_dsl.Query; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; - -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.NestedSortValue @JsonpDeserializable public class NestedSortValue implements JsonpSerializable { - @Nullable - private final Query filter; - - @Nullable - private final Integer maxChildren; + @Nullable + private final Query filter; + + @Nullable + private final Integer maxChildren; - @Nullable - private final NestedSortValue nested; - - private final String path; - - // --------------------------------------------------------------------------------------------- - - private NestedSortValue(Builder builder) { - - this.filter = builder.filter; - this.maxChildren = builder.maxChildren; - this.nested = builder.nested; - this.path = ApiTypeHelper.requireNonNull(builder.path, this, "path"); - - } - - public static NestedSortValue of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code filter} - */ - @Nullable - public final Query filter() { - return this.filter; - } - - /** - * API name: {@code max_children} - */ - @Nullable - public final Integer maxChildren() { - return this.maxChildren; - } - - /** - * API name: {@code nested} - */ - @Nullable - public final NestedSortValue nested() { - return this.nested; - } - - /** - * Required - API name: {@code path} - */ - public final String path() { - return this.path; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (this.filter != null) { - generator.writeKey("filter"); - this.filter.serialize(generator, mapper); - - } - if (this.maxChildren != null) { - generator.writeKey("max_children"); - generator.write(this.maxChildren); - - } - if (this.nested != null) { - generator.writeKey("nested"); - this.nested.serialize(generator, mapper); - - } - generator.writeKey("path"); - generator.write(this.path); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link NestedSortValue}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private Query filter; - - @Nullable - private Integer maxChildren; - - @Nullable - private NestedSortValue nested; - - private String path; - - /** - * API name: {@code filter} - */ - public final Builder filter(@Nullable Query value) { - this.filter = value; - return this; - } - - /** - * API name: {@code filter} - */ - public final Builder filter(Function> fn) { - return this.filter(fn.apply(new Query.Builder()).build()); - } - - /** - * API name: {@code max_children} - */ - public final Builder maxChildren(@Nullable Integer value) { - this.maxChildren = value; - return this; - } - - /** - * API name: {@code nested} - */ - public final Builder nested(@Nullable NestedSortValue value) { - this.nested = value; - return this; - } - - /** - * API name: {@code nested} - */ - public final Builder nested(Function> fn) { - return this.nested(fn.apply(new NestedSortValue.Builder()).build()); - } - - /** - * Required - API name: {@code path} - */ - public final Builder path(String value) { - this.path = value; - return this; - } - - /** - * Builds a {@link NestedSortValue}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public NestedSortValue build() { - _checkSingleUse(); - - return new NestedSortValue(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link NestedSortValue} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - NestedSortValue::setupNestedSortValueDeserializer); - - protected static void setupNestedSortValueDeserializer(ObjectDeserializer op) { - - op.add(Builder::filter, Query._DESERIALIZER, "filter"); - op.add(Builder::maxChildren, JsonpDeserializer.integerDeserializer(), "max_children"); - op.add(Builder::nested, NestedSortValue._DESERIALIZER, "nested"); - op.add(Builder::path, JsonpDeserializer.stringDeserializer(), "path"); - - } + @Nullable + private final NestedSortValue nested; + + private final String path; + + // --------------------------------------------------------------------------------------------- + + private NestedSortValue(Builder builder) { + + this.filter = builder.filter; + this.maxChildren = builder.maxChildren; + this.nested = builder.nested; + this.path = ApiTypeHelper.requireNonNull(builder.path, this, "path"); + + } + + public static NestedSortValue of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code filter} + */ + @Nullable + public final Query filter() { + return this.filter; + } + + /** + * API name: {@code max_children} + */ + @Nullable + public final Integer maxChildren() { + return this.maxChildren; + } + + /** + * API name: {@code nested} + */ + @Nullable + public final NestedSortValue nested() { + return this.nested; + } + + /** + * Required - API name: {@code path} + */ + public final String path() { + return this.path; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.filter != null) { + generator.writeKey("filter"); + this.filter.serialize(generator, mapper); + + } + if (this.maxChildren != null) { + generator.writeKey("max_children"); + generator.write(this.maxChildren); + + } + if (this.nested != null) { + generator.writeKey("nested"); + this.nested.serialize(generator, mapper); + + } + generator.writeKey("path"); + generator.write(this.path); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link NestedSortValue}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private Query filter; + + @Nullable + private Integer maxChildren; + + @Nullable + private NestedSortValue nested; + + private String path; + + /** + * API name: {@code filter} + */ + public final Builder filter(@Nullable Query value) { + this.filter = value; + return this; + } + + /** + * API name: {@code filter} + */ + public final Builder filter(Function> fn) { + return this.filter(fn.apply(new Query.Builder()).build()); + } + + /** + * API name: {@code max_children} + */ + public final Builder maxChildren(@Nullable Integer value) { + this.maxChildren = value; + return this; + } + + /** + * API name: {@code nested} + */ + public final Builder nested(@Nullable NestedSortValue value) { + this.nested = value; + return this; + } + + /** + * API name: {@code nested} + */ + public final Builder nested(Function> fn) { + return this.nested(fn.apply(new NestedSortValue.Builder()).build()); + } + + /** + * Required - API name: {@code path} + */ + public final Builder path(String value) { + this.path = value; + return this; + } + + /** + * Builds a {@link NestedSortValue}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public NestedSortValue build() { + _checkSingleUse(); + + return new NestedSortValue(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link NestedSortValue} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + NestedSortValue::setupNestedSortValueDeserializer + ); + + protected static void setupNestedSortValueDeserializer(ObjectDeserializer op) { + + op.add(Builder::filter, Query._DESERIALIZER, "filter"); + op.add(Builder::maxChildren, JsonpDeserializer.integerDeserializer(), "max_children"); + op.add(Builder::nested, NestedSortValue._DESERIALIZER, "nested"); + op.add(Builder::path, JsonpDeserializer.stringDeserializer(), "path"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeAttributes.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeAttributes.java index e5dc784da0..ac02a7b1d3 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeAttributes.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeAttributes.java @@ -30,12 +30,13 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,283 +46,279 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.NodeAttributes @JsonpDeserializable public class NodeAttributes implements JsonpSerializable { - private final Map attributes; - - private final String ephemeralId; - - @Nullable - private final String id; - - private final String name; - - private final String transportAddress; - - private final List roles; - - // --------------------------------------------------------------------------------------------- - - private NodeAttributes(Builder builder) { - - this.attributes = ApiTypeHelper.unmodifiableRequired(builder.attributes, this, "attributes"); - this.ephemeralId = ApiTypeHelper.requireNonNull(builder.ephemeralId, this, "ephemeralId"); - this.id = builder.id; - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); - this.transportAddress = ApiTypeHelper.requireNonNull(builder.transportAddress, this, "transportAddress"); - this.roles = ApiTypeHelper.unmodifiable(builder.roles); - - } - - public static NodeAttributes of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - Lists node attributes. - *

- * API name: {@code attributes} - */ - public final Map attributes() { - return this.attributes; - } - - /** - * Required - The ephemeral ID of the node. - *

- * API name: {@code ephemeral_id} - */ - public final String ephemeralId() { - return this.ephemeralId; - } - - /** - * The unique identifier of the node. - *

- * API name: {@code id} - */ - @Nullable - public final String id() { - return this.id; - } - - /** - * Required - The unique identifier of the node. - *

- * API name: {@code name} - */ - public final String name() { - return this.name; - } - - /** - * Required - The host and port where transport HTTP connections are accepted. - *

- * API name: {@code transport_address} - */ - public final String transportAddress() { - return this.transportAddress; - } - - /** - * API name: {@code roles} - */ - public final List roles() { - return this.roles; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.attributes)) { - generator.writeKey("attributes"); - generator.writeStartObject(); - for (Map.Entry item0 : this.attributes.entrySet()) { - generator.writeKey(item0.getKey()); - generator.write(item0.getValue()); - - } - generator.writeEnd(); - - } - generator.writeKey("ephemeral_id"); - generator.write(this.ephemeralId); - - if (this.id != null) { - generator.writeKey("id"); - generator.write(this.id); - - } - generator.writeKey("name"); - generator.write(this.name); - - generator.writeKey("transport_address"); - generator.write(this.transportAddress); - - if (ApiTypeHelper.isDefined(this.roles)) { - generator.writeKey("roles"); - generator.writeStartArray(); - for (NodeRole item0 : this.roles) { - item0.serialize(generator, mapper); - } - generator.writeEnd(); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link NodeAttributes}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Map attributes; - - private String ephemeralId; - - @Nullable - private String id; - - private String name; - - private String transportAddress; - - @Nullable - private List roles; - - /** - * Required - Lists node attributes. - *

- * API name: {@code attributes} - *

- * Adds all entries of map to attributes. - */ - public final Builder attributes(Map map) { - this.attributes = _mapPutAll(this.attributes, map); - return this; - } - - /** - * Required - Lists node attributes. - *

- * API name: {@code attributes} - *

- * Adds an entry to attributes. - */ - public final Builder attributes(String key, String value) { - this.attributes = _mapPut(this.attributes, key, value); - return this; - } - - /** - * Required - The ephemeral ID of the node. - *

- * API name: {@code ephemeral_id} - */ - public final Builder ephemeralId(String value) { - this.ephemeralId = value; - return this; - } - - /** - * The unique identifier of the node. - *

- * API name: {@code id} - */ - public final Builder id(@Nullable String value) { - this.id = value; - return this; - } - - /** - * Required - The unique identifier of the node. - *

- * API name: {@code name} - */ - public final Builder name(String value) { - this.name = value; - return this; - } - - /** - * Required - The host and port where transport HTTP connections are accepted. - *

- * API name: {@code transport_address} - */ - public final Builder transportAddress(String value) { - this.transportAddress = value; - return this; - } - - /** - * API name: {@code roles} - *

- * Adds all elements of list to roles. - */ - public final Builder roles(List list) { - this.roles = _listAddAll(this.roles, list); - return this; - } - - /** - * API name: {@code roles} - *

- * Adds one or more values to roles. - */ - public final Builder roles(NodeRole value, NodeRole... values) { - this.roles = _listAdd(this.roles, value, values); - return this; - } - - /** - * Builds a {@link NodeAttributes}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public NodeAttributes build() { - _checkSingleUse(); - - return new NodeAttributes(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link NodeAttributes} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - NodeAttributes::setupNodeAttributesDeserializer); - - protected static void setupNodeAttributesDeserializer(ObjectDeserializer op) { - - op.add(Builder::attributes, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), - "attributes"); - op.add(Builder::ephemeralId, JsonpDeserializer.stringDeserializer(), "ephemeral_id"); - op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); - op.add(Builder::transportAddress, JsonpDeserializer.stringDeserializer(), "transport_address"); - op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(NodeRole._DESERIALIZER), "roles"); - - } + private final Map attributes; + + private final String ephemeralId; + + @Nullable + private final String id; + + private final String name; + + private final String transportAddress; + + private final List roles; + + // --------------------------------------------------------------------------------------------- + + private NodeAttributes(Builder builder) { + + this.attributes = ApiTypeHelper.unmodifiableRequired(builder.attributes, this, "attributes"); + this.ephemeralId = ApiTypeHelper.requireNonNull(builder.ephemeralId, this, "ephemeralId"); + this.id = builder.id; + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); + this.transportAddress = ApiTypeHelper.requireNonNull(builder.transportAddress, this, "transportAddress"); + this.roles = ApiTypeHelper.unmodifiable(builder.roles); + + } + + public static NodeAttributes of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - Lists node attributes. + *

+ * API name: {@code attributes} + */ + public final Map attributes() { + return this.attributes; + } + + /** + * Required - The ephemeral ID of the node. + *

+ * API name: {@code ephemeral_id} + */ + public final String ephemeralId() { + return this.ephemeralId; + } + + /** + * The unique identifier of the node. + *

+ * API name: {@code id} + */ + @Nullable + public final String id() { + return this.id; + } + + /** + * Required - The unique identifier of the node. + *

+ * API name: {@code name} + */ + public final String name() { + return this.name; + } + + /** + * Required - The host and port where transport HTTP connections are accepted. + *

+ * API name: {@code transport_address} + */ + public final String transportAddress() { + return this.transportAddress; + } + + /** + * API name: {@code roles} + */ + public final List roles() { + return this.roles; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (ApiTypeHelper.isDefined(this.attributes)) { + generator.writeKey("attributes"); + generator.writeStartObject(); + for (Map.Entry item0 : this.attributes.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + + } + generator.writeKey("ephemeral_id"); + generator.write(this.ephemeralId); + + if (this.id != null) { + generator.writeKey("id"); + generator.write(this.id); + + } + generator.writeKey("name"); + generator.write(this.name); + + generator.writeKey("transport_address"); + generator.write(this.transportAddress); + + if (ApiTypeHelper.isDefined(this.roles)) { + generator.writeKey("roles"); + generator.writeStartArray(); + for (NodeRole item0 : this.roles) { + item0.serialize(generator, mapper); + } + generator.writeEnd(); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link NodeAttributes}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Map attributes; + + private String ephemeralId; + + @Nullable + private String id; + + private String name; + + private String transportAddress; + + @Nullable + private List roles; + + /** + * Required - Lists node attributes. + *

+ * API name: {@code attributes} + *

+ * Adds all entries of map to attributes. + */ + public final Builder attributes(Map map) { + this.attributes = _mapPutAll(this.attributes, map); + return this; + } + + /** + * Required - Lists node attributes. + *

+ * API name: {@code attributes} + *

+ * Adds an entry to attributes. + */ + public final Builder attributes(String key, String value) { + this.attributes = _mapPut(this.attributes, key, value); + return this; + } + + /** + * Required - The ephemeral ID of the node. + *

+ * API name: {@code ephemeral_id} + */ + public final Builder ephemeralId(String value) { + this.ephemeralId = value; + return this; + } + + /** + * The unique identifier of the node. + *

+ * API name: {@code id} + */ + public final Builder id(@Nullable String value) { + this.id = value; + return this; + } + + /** + * Required - The unique identifier of the node. + *

+ * API name: {@code name} + */ + public final Builder name(String value) { + this.name = value; + return this; + } + + /** + * Required - The host and port where transport HTTP connections are accepted. + *

+ * API name: {@code transport_address} + */ + public final Builder transportAddress(String value) { + this.transportAddress = value; + return this; + } + + /** + * API name: {@code roles} + *

+ * Adds all elements of list to roles. + */ + public final Builder roles(List list) { + this.roles = _listAddAll(this.roles, list); + return this; + } + + /** + * API name: {@code roles} + *

+ * Adds one or more values to roles. + */ + public final Builder roles(NodeRole value, NodeRole... values) { + this.roles = _listAdd(this.roles, value, values); + return this; + } + + /** + * Builds a {@link NodeAttributes}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public NodeAttributes build() { + _checkSingleUse(); + + return new NodeAttributes(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link NodeAttributes} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + NodeAttributes::setupNodeAttributesDeserializer + ); + + protected static void setupNodeAttributesDeserializer(ObjectDeserializer op) { + + op.add(Builder::attributes, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "attributes"); + op.add(Builder::ephemeralId, JsonpDeserializer.stringDeserializer(), "ephemeral_id"); + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + op.add(Builder::transportAddress, JsonpDeserializer.stringDeserializer(), "transport_address"); + op.add(Builder::roles, JsonpDeserializer.arrayDeserializer(NodeRole._DESERIALIZER), "roles"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeRole.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeRole.java index e16d91babe..530603353f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeRole.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeRole.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,48 +37,48 @@ @JsonpDeserializable public enum NodeRole implements JsonEnum { - @Deprecated - Master("master"), + @Deprecated + Master("master"), - ClusterManager("cluster_manager"), + ClusterManager("cluster_manager"), - Data("data"), + Data("data"), - DataCold("data_cold"), + DataCold("data_cold"), - DataContent("data_content"), + DataContent("data_content"), - DataFrozen("data_frozen"), + DataFrozen("data_frozen"), - DataHot("data_hot"), + DataHot("data_hot"), - DataWarm("data_warm"), + DataWarm("data_warm"), - Client("client"), + Client("client"), - Ingest("ingest"), + Ingest("ingest"), - Ml("ml"), + Ml("ml"), - VotingOnly("voting_only"), + VotingOnly("voting_only"), - Transform("transform"), + Transform("transform"), - RemoteClusterClient("remote_cluster_client"), + RemoteClusterClient("remote_cluster_client"), - CoordinatingOnly("coordinating_only"), + CoordinatingOnly("coordinating_only"), - ; + ; - private final String jsonValue; + private final String jsonValue; - NodeRole(String jsonValue) { - this.jsonValue = jsonValue; - } + NodeRole(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(NodeRole.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(NodeRole.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeShard.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeShard.java index c785bb3516..2e504aa517 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeShard.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeShard.java @@ -30,342 +30,336 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; -import org.opensearch.client.opensearch.cluster.allocation_explain.UnassignedInformation; -import org.opensearch.client.opensearch.indices.stats.ShardRoutingState; +import jakarta.json.stream.JsonGenerator; +import java.util.Map; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; import org.opensearch.client.json.JsonpSerializable; import org.opensearch.client.json.ObjectBuilderDeserializer; import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.opensearch.cluster.allocation_explain.UnassignedInformation; +import org.opensearch.client.opensearch.indices.stats.ShardRoutingState; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; - -import java.util.Map; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.NodeShard @JsonpDeserializable public class NodeShard implements JsonpSerializable { - private final ShardRoutingState state; - - private final boolean primary; - - @Nullable - private final String node; - - private final int shard; - - private final String index; - - private final Map allocationId; - - private final Map recoverySource; - - @Nullable - private final UnassignedInformation unassignedInfo; - - // --------------------------------------------------------------------------------------------- - - private NodeShard(Builder builder) { - - this.state = ApiTypeHelper.requireNonNull(builder.state, this, "state"); - this.primary = ApiTypeHelper.requireNonNull(builder.primary, this, "primary"); - this.node = builder.node; - this.shard = ApiTypeHelper.requireNonNull(builder.shard, this, "shard"); - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.allocationId = ApiTypeHelper.unmodifiable(builder.allocationId); - this.recoverySource = ApiTypeHelper.unmodifiable(builder.recoverySource); - this.unassignedInfo = builder.unassignedInfo; - - } - - public static NodeShard of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code state} - */ - public final ShardRoutingState state() { - return this.state; - } - - /** - * Required - API name: {@code primary} - */ - public final boolean primary() { - return this.primary; - } - - /** - * API name: {@code node} - */ - @Nullable - public final String node() { - return this.node; - } - - /** - * Required - API name: {@code shard} - */ - public final int shard() { - return this.shard; - } - - /** - * Required - API name: {@code index} - */ - public final String index() { - return this.index; - } - - /** - * API name: {@code allocation_id} - */ - public final Map allocationId() { - return this.allocationId; - } - - /** - * API name: {@code recovery_source} - */ - public final Map recoverySource() { - return this.recoverySource; - } - - /** - * API name: {@code unassigned_info} - */ - @Nullable - public final UnassignedInformation unassignedInfo() { - return this.unassignedInfo; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("state"); - this.state.serialize(generator, mapper); - generator.writeKey("primary"); - generator.write(this.primary); - - if (this.node != null) { - generator.writeKey("node"); - generator.write(this.node); - - } - generator.writeKey("shard"); - generator.write(this.shard); - - generator.writeKey("index"); - generator.write(this.index); - - if (ApiTypeHelper.isDefined(this.allocationId)) { - generator.writeKey("allocation_id"); - generator.writeStartObject(); - for (Map.Entry item0 : this.allocationId.entrySet()) { - generator.writeKey(item0.getKey()); - generator.write(item0.getValue()); - - } - generator.writeEnd(); - - } - if (ApiTypeHelper.isDefined(this.recoverySource)) { - generator.writeKey("recovery_source"); - generator.writeStartObject(); - for (Map.Entry item0 : this.recoverySource.entrySet()) { - generator.writeKey(item0.getKey()); - generator.write(item0.getValue()); - - } - generator.writeEnd(); - - } - if (this.unassignedInfo != null) { - generator.writeKey("unassigned_info"); - this.unassignedInfo.serialize(generator, mapper); - - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link NodeShard}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private ShardRoutingState state; - - private Boolean primary; - - @Nullable - private String node; - - private Integer shard; - - private String index; - - @Nullable - private Map allocationId; - - @Nullable - private Map recoverySource; - - @Nullable - private UnassignedInformation unassignedInfo; - - /** - * Required - API name: {@code state} - */ - public final Builder state(ShardRoutingState value) { - this.state = value; - return this; - } - - /** - * Required - API name: {@code primary} - */ - public final Builder primary(boolean value) { - this.primary = value; - return this; - } - - /** - * API name: {@code node} - */ - public final Builder node(@Nullable String value) { - this.node = value; - return this; - } - - /** - * Required - API name: {@code shard} - */ - public final Builder shard(int value) { - this.shard = value; - return this; - } - - /** - * Required - API name: {@code index} - */ - public final Builder index(String value) { - this.index = value; - return this; - } - - /** - * API name: {@code allocation_id} - *

- * Adds all entries of map to allocationId. - */ - public final Builder allocationId(Map map) { - this.allocationId = _mapPutAll(this.allocationId, map); - return this; - } - - /** - * API name: {@code allocation_id} - *

- * Adds an entry to allocationId. - */ - public final Builder allocationId(String key, String value) { - this.allocationId = _mapPut(this.allocationId, key, value); - return this; - } - - /** - * API name: {@code recovery_source} - *

- * Adds all entries of map to recoverySource. - */ - public final Builder recoverySource(Map map) { - this.recoverySource = _mapPutAll(this.recoverySource, map); - return this; - } - - /** - * API name: {@code recovery_source} - *

- * Adds an entry to recoverySource. - */ - public final Builder recoverySource(String key, String value) { - this.recoverySource = _mapPut(this.recoverySource, key, value); - return this; - } - - /** - * API name: {@code unassigned_info} - */ - public final Builder unassignedInfo(@Nullable UnassignedInformation value) { - this.unassignedInfo = value; - return this; - } - - /** - * API name: {@code unassigned_info} - */ - public final Builder unassignedInfo( - Function> fn) { - return this.unassignedInfo(fn.apply(new UnassignedInformation.Builder()).build()); - } - - /** - * Builds a {@link NodeShard}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public NodeShard build() { - _checkSingleUse(); - - return new NodeShard(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link NodeShard} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - NodeShard::setupNodeShardDeserializer); - - protected static void setupNodeShardDeserializer(ObjectDeserializer op) { - - op.add(Builder::state, ShardRoutingState._DESERIALIZER, "state"); - op.add(Builder::primary, JsonpDeserializer.booleanDeserializer(), "primary"); - op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node"); - op.add(Builder::shard, JsonpDeserializer.integerDeserializer(), "shard"); - op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); - op.add(Builder::allocationId, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), - "allocation_id"); - op.add(Builder::recoverySource, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), - "recovery_source"); - op.add(Builder::unassignedInfo, UnassignedInformation._DESERIALIZER, "unassigned_info"); - - } + private final ShardRoutingState state; + + private final boolean primary; + + @Nullable + private final String node; + + private final int shard; + + private final String index; + + private final Map allocationId; + + private final Map recoverySource; + + @Nullable + private final UnassignedInformation unassignedInfo; + + // --------------------------------------------------------------------------------------------- + + private NodeShard(Builder builder) { + + this.state = ApiTypeHelper.requireNonNull(builder.state, this, "state"); + this.primary = ApiTypeHelper.requireNonNull(builder.primary, this, "primary"); + this.node = builder.node; + this.shard = ApiTypeHelper.requireNonNull(builder.shard, this, "shard"); + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); + this.allocationId = ApiTypeHelper.unmodifiable(builder.allocationId); + this.recoverySource = ApiTypeHelper.unmodifiable(builder.recoverySource); + this.unassignedInfo = builder.unassignedInfo; + + } + + public static NodeShard of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code state} + */ + public final ShardRoutingState state() { + return this.state; + } + + /** + * Required - API name: {@code primary} + */ + public final boolean primary() { + return this.primary; + } + + /** + * API name: {@code node} + */ + @Nullable + public final String node() { + return this.node; + } + + /** + * Required - API name: {@code shard} + */ + public final int shard() { + return this.shard; + } + + /** + * Required - API name: {@code index} + */ + public final String index() { + return this.index; + } + + /** + * API name: {@code allocation_id} + */ + public final Map allocationId() { + return this.allocationId; + } + + /** + * API name: {@code recovery_source} + */ + public final Map recoverySource() { + return this.recoverySource; + } + + /** + * API name: {@code unassigned_info} + */ + @Nullable + public final UnassignedInformation unassignedInfo() { + return this.unassignedInfo; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("state"); + this.state.serialize(generator, mapper); + generator.writeKey("primary"); + generator.write(this.primary); + + if (this.node != null) { + generator.writeKey("node"); + generator.write(this.node); + + } + generator.writeKey("shard"); + generator.write(this.shard); + + generator.writeKey("index"); + generator.write(this.index); + + if (ApiTypeHelper.isDefined(this.allocationId)) { + generator.writeKey("allocation_id"); + generator.writeStartObject(); + for (Map.Entry item0 : this.allocationId.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + + } + if (ApiTypeHelper.isDefined(this.recoverySource)) { + generator.writeKey("recovery_source"); + generator.writeStartObject(); + for (Map.Entry item0 : this.recoverySource.entrySet()) { + generator.writeKey(item0.getKey()); + generator.write(item0.getValue()); + + } + generator.writeEnd(); + + } + if (this.unassignedInfo != null) { + generator.writeKey("unassigned_info"); + this.unassignedInfo.serialize(generator, mapper); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link NodeShard}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private ShardRoutingState state; + + private Boolean primary; + + @Nullable + private String node; + + private Integer shard; + + private String index; + + @Nullable + private Map allocationId; + + @Nullable + private Map recoverySource; + + @Nullable + private UnassignedInformation unassignedInfo; + + /** + * Required - API name: {@code state} + */ + public final Builder state(ShardRoutingState value) { + this.state = value; + return this; + } + + /** + * Required - API name: {@code primary} + */ + public final Builder primary(boolean value) { + this.primary = value; + return this; + } + + /** + * API name: {@code node} + */ + public final Builder node(@Nullable String value) { + this.node = value; + return this; + } + + /** + * Required - API name: {@code shard} + */ + public final Builder shard(int value) { + this.shard = value; + return this; + } + + /** + * Required - API name: {@code index} + */ + public final Builder index(String value) { + this.index = value; + return this; + } + + /** + * API name: {@code allocation_id} + *

+ * Adds all entries of map to allocationId. + */ + public final Builder allocationId(Map map) { + this.allocationId = _mapPutAll(this.allocationId, map); + return this; + } + + /** + * API name: {@code allocation_id} + *

+ * Adds an entry to allocationId. + */ + public final Builder allocationId(String key, String value) { + this.allocationId = _mapPut(this.allocationId, key, value); + return this; + } + + /** + * API name: {@code recovery_source} + *

+ * Adds all entries of map to recoverySource. + */ + public final Builder recoverySource(Map map) { + this.recoverySource = _mapPutAll(this.recoverySource, map); + return this; + } + + /** + * API name: {@code recovery_source} + *

+ * Adds an entry to recoverySource. + */ + public final Builder recoverySource(String key, String value) { + this.recoverySource = _mapPut(this.recoverySource, key, value); + return this; + } + + /** + * API name: {@code unassigned_info} + */ + public final Builder unassignedInfo(@Nullable UnassignedInformation value) { + this.unassignedInfo = value; + return this; + } + + /** + * API name: {@code unassigned_info} + */ + public final Builder unassignedInfo(Function> fn) { + return this.unassignedInfo(fn.apply(new UnassignedInformation.Builder()).build()); + } + + /** + * Builds a {@link NodeShard}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public NodeShard build() { + _checkSingleUse(); + + return new NodeShard(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link NodeShard} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + NodeShard::setupNodeShardDeserializer + ); + + protected static void setupNodeShardDeserializer(ObjectDeserializer op) { + + op.add(Builder::state, ShardRoutingState._DESERIALIZER, "state"); + op.add(Builder::primary, JsonpDeserializer.booleanDeserializer(), "primary"); + op.add(Builder::node, JsonpDeserializer.stringDeserializer(), "node"); + op.add(Builder::shard, JsonpDeserializer.integerDeserializer(), "shard"); + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); + op.add(Builder::allocationId, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "allocation_id"); + op.add(Builder::recoverySource, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "recovery_source"); + op.add(Builder::unassignedInfo, UnassignedInformation._DESERIALIZER, "unassigned_info"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeStatistics.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeStatistics.java index a2c8bacd92..61bc2e5fc1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeStatistics.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/NodeStatistics.java @@ -30,12 +30,12 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,211 +45,209 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.NodeStatistics @JsonpDeserializable public class NodeStatistics implements JsonpSerializable { - private final List failures; - - private final int total; - - private final int successful; + private final List failures; + + private final int total; + + private final int successful; - private final int failed; + private final int failed; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - private NodeStatistics(Builder builder) { - - this.failures = ApiTypeHelper.unmodifiable(builder.failures); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - this.successful = ApiTypeHelper.requireNonNull(builder.successful, this, "successful"); - this.failed = ApiTypeHelper.requireNonNull(builder.failed, this, "failed"); - - } - - public static NodeStatistics of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * API name: {@code failures} - */ - public final List failures() { - return this.failures; - } - - /** - * Required - Total number of nodes selected by the request. - *

- * API name: {@code total} - */ - public final int total() { - return this.total; - } - - /** - * Required - Number of nodes that responded successfully to the request. - *

- * API name: {@code successful} - */ - public final int successful() { - return this.successful; - } - - /** - * Required - Number of nodes that rejected the request or failed to respond. If - * this value is not 0, a reason for the rejection or failure is included in the - * response. - *

- * API name: {@code failed} - */ - public final int failed() { - return this.failed; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (ApiTypeHelper.isDefined(this.failures)) { - generator.writeKey("failures"); - generator.writeStartArray(); - for (ErrorCause item0 : this.failures) { - item0.serialize(generator, mapper); - - } - generator.writeEnd(); - - } - generator.writeKey("total"); - generator.write(this.total); - - generator.writeKey("successful"); - generator.write(this.successful); - - generator.writeKey("failed"); - generator.write(this.failed); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link NodeStatistics}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private List failures; - - private Integer total; - - private Integer successful; - - private Integer failed; - - /** - * API name: {@code failures} - *

- * Adds all elements of list to failures. - */ - public final Builder failures(List list) { - this.failures = _listAddAll(this.failures, list); - return this; - } - - /** - * API name: {@code failures} - *

- * Adds one or more values to failures. - */ - public final Builder failures(ErrorCause value, ErrorCause... values) { - this.failures = _listAdd(this.failures, value, values); - return this; - } - - /** - * API name: {@code failures} - *

- * Adds a value to failures using a builder lambda. - */ - public final Builder failures(Function> fn) { - return failures(fn.apply(new ErrorCause.Builder()).build()); - } - - /** - * Required - Total number of nodes selected by the request. - *

- * API name: {@code total} - */ - public final Builder total(int value) { - this.total = value; - return this; - } - - /** - * Required - Number of nodes that responded successfully to the request. - *

- * API name: {@code successful} - */ - public final Builder successful(int value) { - this.successful = value; - return this; - } - - /** - * Required - Number of nodes that rejected the request or failed to respond. If - * this value is not 0, a reason for the rejection or failure is included in the - * response. - *

- * API name: {@code failed} - */ - public final Builder failed(int value) { - this.failed = value; - return this; - } - - /** - * Builds a {@link NodeStatistics}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public NodeStatistics build() { - _checkSingleUse(); - - return new NodeStatistics(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link NodeStatistics} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - NodeStatistics::setupNodeStatisticsDeserializer); - - protected static void setupNodeStatisticsDeserializer(ObjectDeserializer op) { - - op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "failures"); - op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); - op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); - op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); - - } + private NodeStatistics(Builder builder) { + + this.failures = ApiTypeHelper.unmodifiable(builder.failures); + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); + this.successful = ApiTypeHelper.requireNonNull(builder.successful, this, "successful"); + this.failed = ApiTypeHelper.requireNonNull(builder.failed, this, "failed"); + + } + + public static NodeStatistics of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code failures} + */ + public final List failures() { + return this.failures; + } + + /** + * Required - Total number of nodes selected by the request. + *

+ * API name: {@code total} + */ + public final int total() { + return this.total; + } + + /** + * Required - Number of nodes that responded successfully to the request. + *

+ * API name: {@code successful} + */ + public final int successful() { + return this.successful; + } + + /** + * Required - Number of nodes that rejected the request or failed to respond. If + * this value is not 0, a reason for the rejection or failure is included in the + * response. + *

+ * API name: {@code failed} + */ + public final int failed() { + return this.failed; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (ApiTypeHelper.isDefined(this.failures)) { + generator.writeKey("failures"); + generator.writeStartArray(); + for (ErrorCause item0 : this.failures) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } + generator.writeKey("total"); + generator.write(this.total); + + generator.writeKey("successful"); + generator.write(this.successful); + + generator.writeKey("failed"); + generator.write(this.failed); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link NodeStatistics}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private List failures; + + private Integer total; + + private Integer successful; + + private Integer failed; + + /** + * API name: {@code failures} + *

+ * Adds all elements of list to failures. + */ + public final Builder failures(List list) { + this.failures = _listAddAll(this.failures, list); + return this; + } + + /** + * API name: {@code failures} + *

+ * Adds one or more values to failures. + */ + public final Builder failures(ErrorCause value, ErrorCause... values) { + this.failures = _listAdd(this.failures, value, values); + return this; + } + + /** + * API name: {@code failures} + *

+ * Adds a value to failures using a builder lambda. + */ + public final Builder failures(Function> fn) { + return failures(fn.apply(new ErrorCause.Builder()).build()); + } + + /** + * Required - Total number of nodes selected by the request. + *

+ * API name: {@code total} + */ + public final Builder total(int value) { + this.total = value; + return this; + } + + /** + * Required - Number of nodes that responded successfully to the request. + *

+ * API name: {@code successful} + */ + public final Builder successful(int value) { + this.successful = value; + return this; + } + + /** + * Required - Number of nodes that rejected the request or failed to respond. If + * this value is not 0, a reason for the rejection or failure is included in the + * response. + *

+ * API name: {@code failed} + */ + public final Builder failed(int value) { + this.failed = value; + return this; + } + + /** + * Builds a {@link NodeStatistics}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public NodeStatistics build() { + _checkSingleUse(); + + return new NodeStatistics(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link NodeStatistics} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + NodeStatistics::setupNodeStatisticsDeserializer + ); + + protected static void setupNodeStatisticsDeserializer(ObjectDeserializer op) { + + op.add(Builder::failures, JsonpDeserializer.arrayDeserializer(ErrorCause._DESERIALIZER), "failures"); + op.add(Builder::total, JsonpDeserializer.integerDeserializer(), "total"); + op.add(Builder::successful, JsonpDeserializer.integerDeserializer(), "successful"); + op.add(Builder::failed, JsonpDeserializer.integerDeserializer(), "failed"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpType.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpType.java index a462e9c707..0a3151caa2 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpType.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpType.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,21 +37,21 @@ @JsonpDeserializable public enum OpType implements JsonEnum { - Index("index"), + Index("index"), - Create("create"), + Create("create"), - ; + ; - private final String jsonValue; + private final String jsonValue; - OpType(String jsonValue) { - this.jsonValue = jsonValue; - } + OpType(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(OpType.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(OpType.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpenSearchException.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpenSearchException.java index 993d68989d..21d3dfc172 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpenSearchException.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpenSearchException.java @@ -33,7 +33,7 @@ package org.opensearch.client.opensearch._types; /** - * Exception thrown by API client methods when Elasticsearch could not accept or + * Exception thrown by API client methods when OpenSearch could not accept or * process a request. *

* The {@link #error()} contains the error's type and reason along with @@ -42,32 +42,32 @@ */ public class OpenSearchException extends RuntimeException { - private final ErrorResponse response; + private final ErrorResponse response; - public OpenSearchException(ErrorResponse response) { - super("Request failed: [" + response.error().type() + "] " + response.error().reason()); - this.response = response; - } + public OpenSearchException(ErrorResponse response) { + super("Request failed: [" + response.error().type() + "] " + response.error().reason()); + this.response = response; + } - /** - * The error response sent by Elasticsearch - */ - public ErrorResponse response() { - return this.response; - } + /** + * The error response sent by OpenSearch + */ + public ErrorResponse response() { + return this.response; + } - /** - * The cause of the error. Shortcut for {@code response().error()}. - */ - public ErrorCause error() { - return this.response.error(); - } + /** + * The cause of the error. Shortcut for {@code response().error()}. + */ + public ErrorCause error() { + return this.response.error(); + } - /** - * Status code returned by Elasticsearch. Shortcut for - * {@code response().status()}. - */ - public int status() { - return this.response.status(); - } + /** + * Status code returned by OpenSearch. Shortcut for + * {@code response().status()}. + */ + public int status() { + return this.response.status(); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java index 2f0f645a4f..12f9e60a7e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/OpenSearchVersionInfo.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,310 +43,313 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; @JsonpDeserializable public final class OpenSearchVersionInfo implements JsonpSerializable { - private final String buildDate; - - private final String buildFlavor; - - private final String buildHash; - - private final boolean buildSnapshot; - - private final String buildType; - - private final String distribution; - - private final String luceneVersion; - - private final String minimumIndexCompatibilityVersion; - - private final String minimumWireCompatibilityVersion; - - private final String number; - - // --------------------------------------------------------------------------------------------- - - private OpenSearchVersionInfo(Builder builder) { - - this.buildDate = ApiTypeHelper.requireNonNull(builder.buildDate, this, "buildDate"); - this.buildFlavor = builder.buildFlavor; - this.buildHash = ApiTypeHelper.requireNonNull(builder.buildHash, this, "buildHash"); - this.buildSnapshot = ApiTypeHelper.requireNonNull(builder.buildSnapshot, this, "buildSnapshot"); - this.buildType = ApiTypeHelper.requireNonNull(builder.buildType, this, "buildType"); - this.distribution = ApiTypeHelper.requireNonNull(builder.distribution, this, "distribution"); - this.luceneVersion = ApiTypeHelper.requireNonNull(builder.luceneVersion, this, "luceneVersion"); - this.minimumIndexCompatibilityVersion = ApiTypeHelper.requireNonNull(builder.minimumIndexCompatibilityVersion, - this, "minimumIndexCompatibilityVersion"); - this.minimumWireCompatibilityVersion = ApiTypeHelper.requireNonNull(builder.minimumWireCompatibilityVersion, - this, "minimumWireCompatibilityVersion"); - this.number = ApiTypeHelper.requireNonNull(builder.number, this, "number"); - - } - - public static OpenSearchVersionInfo of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code build_date} - */ - public String buildDate() { - return this.buildDate; - } - - /** - * API name: {@code build_flavor} - */ - public String buildFlavor() { - return this.buildFlavor; - } - - /** - * API name: {@code build_hash} - */ - public String buildHash() { - return this.buildHash; - } - - /** - * Required - API name: {@code build_snapshot} - */ - public boolean buildSnapshot() { - return this.buildSnapshot; - } - - /** - * Required - API name: {@code build_type} - */ - public String buildType() { - return this.buildType; - } - - /** - * API name: {@code distribution} - */ - public String distribution() { - return this.distribution; - } - - /** - * API name: {@code lucene_version} - */ - public String luceneVersion() { - return this.luceneVersion; - } + private final String buildDate; + + private final String buildFlavor; + + private final String buildHash; + + private final boolean buildSnapshot; + + private final String buildType; + + private final String distribution; + + private final String luceneVersion; + + private final String minimumIndexCompatibilityVersion; + + private final String minimumWireCompatibilityVersion; + + private final String number; + + // --------------------------------------------------------------------------------------------- + + private OpenSearchVersionInfo(Builder builder) { + + this.buildDate = ApiTypeHelper.requireNonNull(builder.buildDate, this, "buildDate"); + this.buildFlavor = builder.buildFlavor; + this.buildHash = ApiTypeHelper.requireNonNull(builder.buildHash, this, "buildHash"); + this.buildSnapshot = ApiTypeHelper.requireNonNull(builder.buildSnapshot, this, "buildSnapshot"); + this.buildType = ApiTypeHelper.requireNonNull(builder.buildType, this, "buildType"); + this.distribution = ApiTypeHelper.requireNonNull(builder.distribution, this, "distribution"); + this.luceneVersion = ApiTypeHelper.requireNonNull(builder.luceneVersion, this, "luceneVersion"); + this.minimumIndexCompatibilityVersion = ApiTypeHelper.requireNonNull( + builder.minimumIndexCompatibilityVersion, + this, + "minimumIndexCompatibilityVersion" + ); + this.minimumWireCompatibilityVersion = ApiTypeHelper.requireNonNull( + builder.minimumWireCompatibilityVersion, + this, + "minimumWireCompatibilityVersion" + ); + this.number = ApiTypeHelper.requireNonNull(builder.number, this, "number"); + + } + + public static OpenSearchVersionInfo of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code build_date} + */ + public String buildDate() { + return this.buildDate; + } + + /** + * API name: {@code build_flavor} + */ + public String buildFlavor() { + return this.buildFlavor; + } + + /** + * API name: {@code build_hash} + */ + public String buildHash() { + return this.buildHash; + } + + /** + * Required - API name: {@code build_snapshot} + */ + public boolean buildSnapshot() { + return this.buildSnapshot; + } + + /** + * Required - API name: {@code build_type} + */ + public String buildType() { + return this.buildType; + } - /** - * Required - API name: {@code minimum_index_compatibility_version} - */ - public String minimumIndexCompatibilityVersion() { - return this.minimumIndexCompatibilityVersion; - } + /** + * API name: {@code distribution} + */ + public String distribution() { + return this.distribution; + } - /** - * Required - API name: {@code minimum_wire_compatibility_version} - */ - public String minimumWireCompatibilityVersion() { - return this.minimumWireCompatibilityVersion; - } + /** + * API name: {@code lucene_version} + */ + public String luceneVersion() { + return this.luceneVersion; + } - /** - * Required - API name: {@code number} - */ - public String number() { - return this.number; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("build_date"); - generator.write(this.buildDate); - - generator.writeKey("build_flavor"); - generator.write(this.buildFlavor); - - generator.writeKey("build_hash"); - generator.write(this.buildHash); - - generator.writeKey("build_snapshot"); - generator.write(this.buildSnapshot); - - generator.writeKey("build_type"); - generator.write(this.buildType); - - generator.writeKey("distribution"); - generator.write(this.distribution); - - generator.writeKey("lucene_version"); - generator.write(this.luceneVersion); - - generator.writeKey("minimum_index_compatibility_version"); - generator.write(this.minimumIndexCompatibilityVersion); - - generator.writeKey("minimum_wire_compatibility_version"); - generator.write(this.minimumWireCompatibilityVersion); - - generator.writeKey("number"); - generator.write(this.number); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link OpenSearchVersionInfo}. - */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String buildDate; - - private String buildFlavor; - - private String buildHash; - - private Boolean buildSnapshot; - - private String buildType; - - private String distribution; - - private String luceneVersion; - - private String minimumIndexCompatibilityVersion; - - private String minimumWireCompatibilityVersion; - - private String number; - - /** - * Required - API name: {@code build_date} - */ - public final Builder buildDate(String value) { - this.buildDate = value; - return this; - } - - /** - * API name: {@code build_flavor} - */ - public Builder buildFlavor(String value) { - this.buildFlavor = value; - return this; - } - - /** - * API name: {@code build_hash} - */ - public final Builder buildHash(String value) { - this.buildHash = value; - return this; - } - - /** - * Required - API name: {@code build_snapshot} - */ - public final Builder buildSnapshot(boolean value) { - this.buildSnapshot = value; - return this; - } - - /** - * Required - API name: {@code build_type} - */ - public final Builder buildType(String value) { - this.buildType = value; - return this; - } - - /** - * API name: {@code distribution} - */ - public Builder distribution(String value) { - this.distribution = value; - return this; - } - - /** - * API name: {@code lucene_version} - */ - public final Builder luceneVersion(String value) { - this.luceneVersion = value; - return this; - } - - /** - * Required - API name: {@code minimum_index_compatibility_version} - */ - public final Builder minimumIndexCompatibilityVersion(String value) { - this.minimumIndexCompatibilityVersion = value; - return this; - } - - /** - * Required - API name: {@code minimum_wire_compatibility_version} - */ - public final Builder minimumWireCompatibilityVersion(String value) { - this.minimumWireCompatibilityVersion = value; - return this; - } - - /** - * Required - API name: {@code number} - */ - public final Builder number(String value) { - this.number = value; - return this; - } - - /** - * Builds a {@link OpenSearchVersionInfo}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - - public OpenSearchVersionInfo build() { - _checkSingleUse(); - return new OpenSearchVersionInfo(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for OpenSearchVersionInfo - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, OpenSearchVersionInfo::setupOpenSearchVersionInfoDeserializer); - - protected static void setupOpenSearchVersionInfoDeserializer( - ObjectDeserializer op) { - - op.add(Builder::buildDate, JsonpDeserializer.stringDeserializer(), "build_date"); - op.add(Builder::buildFlavor, JsonpDeserializer.stringDeserializer(), "build_flavor"); - op.add(Builder::buildHash, JsonpDeserializer.stringDeserializer(), "build_hash"); - op.add(Builder::buildSnapshot, JsonpDeserializer.booleanDeserializer(), "build_snapshot"); - op.add(Builder::buildType, JsonpDeserializer.stringDeserializer(), "build_type"); - op.add(Builder::distribution, JsonpDeserializer.stringDeserializer(), "distribution"); - op.add(Builder::luceneVersion, JsonpDeserializer.stringDeserializer(), "lucene_version"); - op.add(Builder::minimumIndexCompatibilityVersion, JsonpDeserializer.stringDeserializer(), - "minimum_index_compatibility_version"); - op.add(Builder::minimumWireCompatibilityVersion, JsonpDeserializer.stringDeserializer(), - "minimum_wire_compatibility_version"); - op.add(Builder::number, JsonpDeserializer.stringDeserializer(), "number"); - - } + /** + * Required - API name: {@code minimum_index_compatibility_version} + */ + public String minimumIndexCompatibilityVersion() { + return this.minimumIndexCompatibilityVersion; + } + + /** + * Required - API name: {@code minimum_wire_compatibility_version} + */ + public String minimumWireCompatibilityVersion() { + return this.minimumWireCompatibilityVersion; + } + + /** + * Required - API name: {@code number} + */ + public String number() { + return this.number; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("build_date"); + generator.write(this.buildDate); + + generator.writeKey("build_flavor"); + generator.write(this.buildFlavor); + + generator.writeKey("build_hash"); + generator.write(this.buildHash); + + generator.writeKey("build_snapshot"); + generator.write(this.buildSnapshot); + + generator.writeKey("build_type"); + generator.write(this.buildType); + + generator.writeKey("distribution"); + generator.write(this.distribution); + + generator.writeKey("lucene_version"); + generator.write(this.luceneVersion); + + generator.writeKey("minimum_index_compatibility_version"); + generator.write(this.minimumIndexCompatibilityVersion); + + generator.writeKey("minimum_wire_compatibility_version"); + generator.write(this.minimumWireCompatibilityVersion); + + generator.writeKey("number"); + generator.write(this.number); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link OpenSearchVersionInfo}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String buildDate; + + private String buildFlavor; + + private String buildHash; + + private Boolean buildSnapshot; + + private String buildType; + + private String distribution; + + private String luceneVersion; + + private String minimumIndexCompatibilityVersion; + + private String minimumWireCompatibilityVersion; + + private String number; + + /** + * Required - API name: {@code build_date} + */ + public final Builder buildDate(String value) { + this.buildDate = value; + return this; + } + + /** + * API name: {@code build_flavor} + */ + public Builder buildFlavor(String value) { + this.buildFlavor = value; + return this; + } + + /** + * API name: {@code build_hash} + */ + public final Builder buildHash(String value) { + this.buildHash = value; + return this; + } + + /** + * Required - API name: {@code build_snapshot} + */ + public final Builder buildSnapshot(boolean value) { + this.buildSnapshot = value; + return this; + } + + /** + * Required - API name: {@code build_type} + */ + public final Builder buildType(String value) { + this.buildType = value; + return this; + } + + /** + * API name: {@code distribution} + */ + public Builder distribution(String value) { + this.distribution = value; + return this; + } + + /** + * API name: {@code lucene_version} + */ + public final Builder luceneVersion(String value) { + this.luceneVersion = value; + return this; + } + + /** + * Required - API name: {@code minimum_index_compatibility_version} + */ + public final Builder minimumIndexCompatibilityVersion(String value) { + this.minimumIndexCompatibilityVersion = value; + return this; + } + + /** + * Required - API name: {@code minimum_wire_compatibility_version} + */ + public final Builder minimumWireCompatibilityVersion(String value) { + this.minimumWireCompatibilityVersion = value; + return this; + } + + /** + * Required - API name: {@code number} + */ + public final Builder number(String value) { + this.number = value; + return this; + } + + /** + * Builds a {@link OpenSearchVersionInfo}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + + public OpenSearchVersionInfo build() { + _checkSingleUse(); + return new OpenSearchVersionInfo(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for OpenSearchVersionInfo + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + OpenSearchVersionInfo::setupOpenSearchVersionInfoDeserializer + ); + + protected static void setupOpenSearchVersionInfoDeserializer(ObjectDeserializer op) { + + op.add(Builder::buildDate, JsonpDeserializer.stringDeserializer(), "build_date"); + op.add(Builder::buildFlavor, JsonpDeserializer.stringDeserializer(), "build_flavor"); + op.add(Builder::buildHash, JsonpDeserializer.stringDeserializer(), "build_hash"); + op.add(Builder::buildSnapshot, JsonpDeserializer.booleanDeserializer(), "build_snapshot"); + op.add(Builder::buildType, JsonpDeserializer.stringDeserializer(), "build_type"); + op.add(Builder::distribution, JsonpDeserializer.stringDeserializer(), "distribution"); + op.add(Builder::luceneVersion, JsonpDeserializer.stringDeserializer(), "lucene_version"); + op.add(Builder::minimumIndexCompatibilityVersion, JsonpDeserializer.stringDeserializer(), "minimum_index_compatibility_version"); + op.add(Builder::minimumWireCompatibilityVersion, JsonpDeserializer.stringDeserializer(), "minimum_wire_compatibility_version"); + op.add(Builder::number, JsonpDeserializer.stringDeserializer(), "number"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/PluginStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/PluginStats.java index 0aca1805c0..9ed07791d4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/PluginStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/PluginStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.List; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,331 +44,278 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.function.Function; // typedef: _types.PluginStats @JsonpDeserializable public class PluginStats implements JsonpSerializable { - private final String classname; - - private final String description; - - private final String opensearchVersion; - - private final List extendedPlugins; - - private final boolean hasNativeController; - - private final String javaVersion; - - private final String name; - - private final String version; - - private final boolean licensed; - - private final String type; - - // --------------------------------------------------------------------------------------------- - - private PluginStats(Builder builder) { - - this.classname = ApiTypeHelper.requireNonNull(builder.classname, this, "classname"); - this.description = ApiTypeHelper.requireNonNull(builder.description, this, "description"); - this.opensearchVersion = ApiTypeHelper.requireNonNull(builder.opensearchVersion, this, - "opensearchVersion"); - this.extendedPlugins = ApiTypeHelper.unmodifiableRequired(builder.extendedPlugins, this, "extendedPlugins"); - this.hasNativeController = ApiTypeHelper.requireNonNull(builder.hasNativeController, this, - "hasNativeController"); - this.javaVersion = ApiTypeHelper.requireNonNull(builder.javaVersion, this, "javaVersion"); - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); - this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version"); - this.licensed = ApiTypeHelper.requireNonNull(builder.licensed, this, "licensed"); - this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - - } - - public static PluginStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code classname} - */ - public final String classname() { - return this.classname; - } - - /** - * Required - API name: {@code description} - */ - public final String description() { - return this.description; - } - - /** - * API name: {@code opensearch_version} - */ - public String opensearchVersion() { - return this.opensearchVersion; - } - - /** - * Required - API name: {@code extended_plugins} - */ - public final List extendedPlugins() { - return this.extendedPlugins; - } - - /** - * Required - API name: {@code has_native_controller} - */ - public final boolean hasNativeController() { - return this.hasNativeController; - } + private final String classname; + + private final String description; + + private final String opensearchVersion; + + private final List extendedPlugins; + + private final boolean hasNativeController; + + private final String javaVersion; + + private final String name; + + private final String version; + + // --------------------------------------------------------------------------------------------- + + private PluginStats(Builder builder) { + + this.classname = ApiTypeHelper.requireNonNull(builder.classname, this, "classname"); + this.description = ApiTypeHelper.requireNonNull(builder.description, this, "description"); + this.opensearchVersion = ApiTypeHelper.requireNonNull(builder.opensearchVersion, this, "opensearchVersion"); + this.extendedPlugins = ApiTypeHelper.unmodifiableRequired(builder.extendedPlugins, this, "extendedPlugins"); + this.hasNativeController = ApiTypeHelper.requireNonNull(builder.hasNativeController, this, "hasNativeController"); + this.javaVersion = ApiTypeHelper.requireNonNull(builder.javaVersion, this, "javaVersion"); + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); + this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version"); + + } + + public static PluginStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code classname} + */ + public final String classname() { + return this.classname; + } + + /** + * Required - API name: {@code description} + */ + public final String description() { + return this.description; + } - /** - * Required - API name: {@code java_version} - */ - public final String javaVersion() { - return this.javaVersion; - } + /** + * API name: {@code opensearch_version} + */ + public String opensearchVersion() { + return this.opensearchVersion; + } - /** - * Required - API name: {@code name} - */ - public final String name() { - return this.name; - } + /** + * Required - API name: {@code extended_plugins} + */ + public final List extendedPlugins() { + return this.extendedPlugins; + } - /** - * Required - API name: {@code version} - */ - public final String version() { - return this.version; - } + /** + * Required - API name: {@code has_native_controller} + */ + public final boolean hasNativeController() { + return this.hasNativeController; + } - /** - * Required - API name: {@code licensed} - */ - public final boolean licensed() { - return this.licensed; - } + /** + * Required - API name: {@code java_version} + */ + public final String javaVersion() { + return this.javaVersion; + } - /** - * Required - API name: {@code type} - */ - public final String type() { - return this.type; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("classname"); - generator.write(this.classname); - - generator.writeKey("description"); - generator.write(this.description); - - generator.writeKey("opensearch_version"); - generator.write(this.opensearchVersion); - - if (ApiTypeHelper.isDefined(this.extendedPlugins)) { - generator.writeKey("extended_plugins"); - generator.writeStartArray(); - for (String item0 : this.extendedPlugins) { - generator.write(item0); - - } - generator.writeEnd(); - - } - generator.writeKey("has_native_controller"); - generator.write(this.hasNativeController); - - generator.writeKey("java_version"); - generator.write(this.javaVersion); - - generator.writeKey("name"); - generator.write(this.name); - - generator.writeKey("version"); - generator.write(this.version); - - generator.writeKey("licensed"); - generator.write(this.licensed); - - generator.writeKey("type"); - generator.write(this.type); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link PluginStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String classname; - - private String description; - - private String opensearchVersion; - - private List extendedPlugins; - - private Boolean hasNativeController; - - private String javaVersion; - - private String name; - - private String version; - - private Boolean licensed; - - private String type; - - /** - * Required - API name: {@code classname} - */ - public final Builder classname(String value) { - this.classname = value; - return this; - } - - /** - * Required - API name: {@code description} - */ - public final Builder description(String value) { - this.description = value; - return this; - } - - /** - * Required - API name: {@code opensearch_version} - */ - public final Builder opensearchVersion(String value) { - this.opensearchVersion = value; - return this; - } - - /** - * Required - API name: {@code extended_plugins} - *

- * Adds all elements of list to extendedPlugins. - */ - public final Builder extendedPlugins(List list) { - this.extendedPlugins = _listAddAll(this.extendedPlugins, list); - return this; - } - - /** - * Required - API name: {@code extended_plugins} - *

- * Adds one or more values to extendedPlugins. - */ - public final Builder extendedPlugins(String value, String... values) { - this.extendedPlugins = _listAdd(this.extendedPlugins, value, values); - return this; - } - - /** - * Required - API name: {@code has_native_controller} - */ - public final Builder hasNativeController(boolean value) { - this.hasNativeController = value; - return this; - } - - /** - * Required - API name: {@code java_version} - */ - public final Builder javaVersion(String value) { - this.javaVersion = value; - return this; - } - - /** - * Required - API name: {@code name} - */ - public final Builder name(String value) { - this.name = value; - return this; - } - - /** - * Required - API name: {@code version} - */ - public final Builder version(String value) { - this.version = value; - return this; - } - - /** - * Required - API name: {@code licensed} - */ - public final Builder licensed(boolean value) { - this.licensed = value; - return this; - } - - /** - * Required - API name: {@code type} - */ - public final Builder type(String value) { - this.type = value; - return this; - } - - /** - * Builds a {@link PluginStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public PluginStats build() { - _checkSingleUse(); - - return new PluginStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link PluginStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - PluginStats::setupPluginStatsDeserializer); - - protected static void setupPluginStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::classname, JsonpDeserializer.stringDeserializer(), "classname"); - op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description"); - op.add(Builder::opensearchVersion, JsonpDeserializer.stringDeserializer(), "opensearch_version"); - op.add(Builder::extendedPlugins, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), - "extended_plugins"); - op.add(Builder::hasNativeController, JsonpDeserializer.booleanDeserializer(), "has_native_controller"); - op.add(Builder::javaVersion, JsonpDeserializer.stringDeserializer(), "java_version"); - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); - op.add(Builder::version, JsonpDeserializer.stringDeserializer(), "version"); - op.add(Builder::licensed, JsonpDeserializer.booleanDeserializer(), "licensed"); - op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); - - } + /** + * Required - API name: {@code name} + */ + public final String name() { + return this.name; + } + + /** + * Required - API name: {@code version} + */ + public final String version() { + return this.version; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("classname"); + generator.write(this.classname); + + generator.writeKey("description"); + generator.write(this.description); + + generator.writeKey("opensearch_version"); + generator.write(this.opensearchVersion); + + if (ApiTypeHelper.isDefined(this.extendedPlugins)) { + generator.writeKey("extended_plugins"); + generator.writeStartArray(); + for (String item0 : this.extendedPlugins) { + generator.write(item0); + + } + generator.writeEnd(); + + } + generator.writeKey("has_native_controller"); + generator.write(this.hasNativeController); + + generator.writeKey("java_version"); + generator.write(this.javaVersion); + + generator.writeKey("name"); + generator.write(this.name); + + generator.writeKey("version"); + generator.write(this.version); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link PluginStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private String classname; + + private String description; + + private String opensearchVersion; + + private List extendedPlugins; + + private Boolean hasNativeController; + + private String javaVersion; + + private String name; + + private String version; + + /** + * Required - API name: {@code classname} + */ + public final Builder classname(String value) { + this.classname = value; + return this; + } + + /** + * Required - API name: {@code description} + */ + public final Builder description(String value) { + this.description = value; + return this; + } + + /** + * Required - API name: {@code opensearch_version} + */ + public final Builder opensearchVersion(String value) { + this.opensearchVersion = value; + return this; + } + + /** + * Required - API name: {@code extended_plugins} + *

+ * Adds all elements of list to extendedPlugins. + */ + public final Builder extendedPlugins(List list) { + this.extendedPlugins = _listAddAll(this.extendedPlugins, list); + return this; + } + + /** + * Required - API name: {@code extended_plugins} + *

+ * Adds one or more values to extendedPlugins. + */ + public final Builder extendedPlugins(String value, String... values) { + this.extendedPlugins = _listAdd(this.extendedPlugins, value, values); + return this; + } + + /** + * Required - API name: {@code has_native_controller} + */ + public final Builder hasNativeController(boolean value) { + this.hasNativeController = value; + return this; + } + + /** + * Required - API name: {@code java_version} + */ + public final Builder javaVersion(String value) { + this.javaVersion = value; + return this; + } + + /** + * Required - API name: {@code name} + */ + public final Builder name(String value) { + this.name = value; + return this; + } + + /** + * Required - API name: {@code version} + */ + public final Builder version(String value) { + this.version = value; + return this; + } + + /** + * Builds a {@link PluginStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public PluginStats build() { + _checkSingleUse(); + + return new PluginStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link PluginStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + PluginStats::setupPluginStatsDeserializer + ); + + protected static void setupPluginStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::classname, JsonpDeserializer.stringDeserializer(), "classname"); + op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description"); + op.add(Builder::opensearchVersion, JsonpDeserializer.stringDeserializer(), "opensearch_version"); + op.add(Builder::extendedPlugins, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "extended_plugins"); + op.add(Builder::hasNativeController, JsonpDeserializer.booleanDeserializer(), "has_native_controller"); + op.add(Builder::javaVersion, JsonpDeserializer.stringDeserializer(), "java_version"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); + op.add(Builder::version, JsonpDeserializer.stringDeserializer(), "version"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/QueryCacheStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/QueryCacheStats.java index 1de429133d..d5ba4b1224 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/QueryCacheStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/QueryCacheStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,266 +44,265 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.QueryCacheStats @JsonpDeserializable public class QueryCacheStats implements JsonpSerializable { - private final int cacheCount; - - private final int cacheSize; - - private final int evictions; - - private final int hitCount; - - @Nullable - private final String memorySize; - - private final int memorySizeInBytes; - - private final int missCount; - - private final int totalCount; - - // --------------------------------------------------------------------------------------------- - - private QueryCacheStats(Builder builder) { - - this.cacheCount = ApiTypeHelper.requireNonNull(builder.cacheCount, this, "cacheCount"); - this.cacheSize = ApiTypeHelper.requireNonNull(builder.cacheSize, this, "cacheSize"); - this.evictions = ApiTypeHelper.requireNonNull(builder.evictions, this, "evictions"); - this.hitCount = ApiTypeHelper.requireNonNull(builder.hitCount, this, "hitCount"); - this.memorySize = builder.memorySize; - this.memorySizeInBytes = ApiTypeHelper.requireNonNull(builder.memorySizeInBytes, this, "memorySizeInBytes"); - this.missCount = ApiTypeHelper.requireNonNull(builder.missCount, this, "missCount"); - this.totalCount = ApiTypeHelper.requireNonNull(builder.totalCount, this, "totalCount"); - - } - - public static QueryCacheStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code cache_count} - */ - public final int cacheCount() { - return this.cacheCount; - } + private final int cacheCount; + + private final int cacheSize; + + private final int evictions; + + private final int hitCount; + + @Nullable + private final String memorySize; + + private final int memorySizeInBytes; + + private final int missCount; + + private final int totalCount; + + // --------------------------------------------------------------------------------------------- + + private QueryCacheStats(Builder builder) { + + this.cacheCount = ApiTypeHelper.requireNonNull(builder.cacheCount, this, "cacheCount"); + this.cacheSize = ApiTypeHelper.requireNonNull(builder.cacheSize, this, "cacheSize"); + this.evictions = ApiTypeHelper.requireNonNull(builder.evictions, this, "evictions"); + this.hitCount = ApiTypeHelper.requireNonNull(builder.hitCount, this, "hitCount"); + this.memorySize = builder.memorySize; + this.memorySizeInBytes = ApiTypeHelper.requireNonNull(builder.memorySizeInBytes, this, "memorySizeInBytes"); + this.missCount = ApiTypeHelper.requireNonNull(builder.missCount, this, "missCount"); + this.totalCount = ApiTypeHelper.requireNonNull(builder.totalCount, this, "totalCount"); + + } + + public static QueryCacheStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code cache_count} + */ + public final int cacheCount() { + return this.cacheCount; + } - /** - * Required - API name: {@code cache_size} - */ - public final int cacheSize() { - return this.cacheSize; - } + /** + * Required - API name: {@code cache_size} + */ + public final int cacheSize() { + return this.cacheSize; + } - /** - * Required - API name: {@code evictions} - */ - public final int evictions() { - return this.evictions; - } + /** + * Required - API name: {@code evictions} + */ + public final int evictions() { + return this.evictions; + } - /** - * Required - API name: {@code hit_count} - */ - public final int hitCount() { - return this.hitCount; - } + /** + * Required - API name: {@code hit_count} + */ + public final int hitCount() { + return this.hitCount; + } - /** - * API name: {@code memory_size} - */ - @Nullable - public final String memorySize() { - return this.memorySize; - } + /** + * API name: {@code memory_size} + */ + @Nullable + public final String memorySize() { + return this.memorySize; + } - /** - * Required - API name: {@code memory_size_in_bytes} - */ - public final int memorySizeInBytes() { - return this.memorySizeInBytes; - } + /** + * Required - API name: {@code memory_size_in_bytes} + */ + public final int memorySizeInBytes() { + return this.memorySizeInBytes; + } - /** - * Required - API name: {@code miss_count} - */ - public final int missCount() { - return this.missCount; - } - - /** - * Required - API name: {@code total_count} - */ - public final int totalCount() { - return this.totalCount; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("cache_count"); - generator.write(this.cacheCount); - - generator.writeKey("cache_size"); - generator.write(this.cacheSize); - - generator.writeKey("evictions"); - generator.write(this.evictions); - - generator.writeKey("hit_count"); - generator.write(this.hitCount); - - if (this.memorySize != null) { - generator.writeKey("memory_size"); - generator.write(this.memorySize); - - } - generator.writeKey("memory_size_in_bytes"); - generator.write(this.memorySizeInBytes); - - generator.writeKey("miss_count"); - generator.write(this.missCount); - - generator.writeKey("total_count"); - generator.write(this.totalCount); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link QueryCacheStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Integer cacheCount; - - private Integer cacheSize; - - private Integer evictions; - - private Integer hitCount; - - @Nullable - private String memorySize; - - private Integer memorySizeInBytes; - - private Integer missCount; - - private Integer totalCount; - - /** - * Required - API name: {@code cache_count} - */ - public final Builder cacheCount(int value) { - this.cacheCount = value; - return this; - } - - /** - * Required - API name: {@code cache_size} - */ - public final Builder cacheSize(int value) { - this.cacheSize = value; - return this; - } - - /** - * Required - API name: {@code evictions} - */ - public final Builder evictions(int value) { - this.evictions = value; - return this; - } - - /** - * Required - API name: {@code hit_count} - */ - public final Builder hitCount(int value) { - this.hitCount = value; - return this; - } - - /** - * API name: {@code memory_size} - */ - public final Builder memorySize(@Nullable String value) { - this.memorySize = value; - return this; - } - - /** - * Required - API name: {@code memory_size_in_bytes} - */ - public final Builder memorySizeInBytes(int value) { - this.memorySizeInBytes = value; - return this; - } - - /** - * Required - API name: {@code miss_count} - */ - public final Builder missCount(int value) { - this.missCount = value; - return this; - } - - /** - * Required - API name: {@code total_count} - */ - public final Builder totalCount(int value) { - this.totalCount = value; - return this; - } - - /** - * Builds a {@link QueryCacheStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public QueryCacheStats build() { - _checkSingleUse(); - - return new QueryCacheStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link QueryCacheStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - QueryCacheStats::setupQueryCacheStatsDeserializer); - - protected static void setupQueryCacheStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::cacheCount, JsonpDeserializer.integerDeserializer(), "cache_count"); - op.add(Builder::cacheSize, JsonpDeserializer.integerDeserializer(), "cache_size"); - op.add(Builder::evictions, JsonpDeserializer.integerDeserializer(), "evictions"); - op.add(Builder::hitCount, JsonpDeserializer.integerDeserializer(), "hit_count"); - op.add(Builder::memorySize, JsonpDeserializer.stringDeserializer(), "memory_size"); - op.add(Builder::memorySizeInBytes, JsonpDeserializer.integerDeserializer(), "memory_size_in_bytes"); - op.add(Builder::missCount, JsonpDeserializer.integerDeserializer(), "miss_count"); - op.add(Builder::totalCount, JsonpDeserializer.integerDeserializer(), "total_count"); - - } + /** + * Required - API name: {@code miss_count} + */ + public final int missCount() { + return this.missCount; + } + + /** + * Required - API name: {@code total_count} + */ + public final int totalCount() { + return this.totalCount; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("cache_count"); + generator.write(this.cacheCount); + + generator.writeKey("cache_size"); + generator.write(this.cacheSize); + + generator.writeKey("evictions"); + generator.write(this.evictions); + + generator.writeKey("hit_count"); + generator.write(this.hitCount); + + if (this.memorySize != null) { + generator.writeKey("memory_size"); + generator.write(this.memorySize); + + } + generator.writeKey("memory_size_in_bytes"); + generator.write(this.memorySizeInBytes); + + generator.writeKey("miss_count"); + generator.write(this.missCount); + + generator.writeKey("total_count"); + generator.write(this.totalCount); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link QueryCacheStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Integer cacheCount; + + private Integer cacheSize; + + private Integer evictions; + + private Integer hitCount; + + @Nullable + private String memorySize; + + private Integer memorySizeInBytes; + + private Integer missCount; + + private Integer totalCount; + + /** + * Required - API name: {@code cache_count} + */ + public final Builder cacheCount(int value) { + this.cacheCount = value; + return this; + } + + /** + * Required - API name: {@code cache_size} + */ + public final Builder cacheSize(int value) { + this.cacheSize = value; + return this; + } + + /** + * Required - API name: {@code evictions} + */ + public final Builder evictions(int value) { + this.evictions = value; + return this; + } + + /** + * Required - API name: {@code hit_count} + */ + public final Builder hitCount(int value) { + this.hitCount = value; + return this; + } + + /** + * API name: {@code memory_size} + */ + public final Builder memorySize(@Nullable String value) { + this.memorySize = value; + return this; + } + + /** + * Required - API name: {@code memory_size_in_bytes} + */ + public final Builder memorySizeInBytes(int value) { + this.memorySizeInBytes = value; + return this; + } + + /** + * Required - API name: {@code miss_count} + */ + public final Builder missCount(int value) { + this.missCount = value; + return this; + } + + /** + * Required - API name: {@code total_count} + */ + public final Builder totalCount(int value) { + this.totalCount = value; + return this; + } + + /** + * Builds a {@link QueryCacheStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public QueryCacheStats build() { + _checkSingleUse(); + + return new QueryCacheStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link QueryCacheStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + QueryCacheStats::setupQueryCacheStatsDeserializer + ); + + protected static void setupQueryCacheStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::cacheCount, JsonpDeserializer.integerDeserializer(), "cache_count"); + op.add(Builder::cacheSize, JsonpDeserializer.integerDeserializer(), "cache_size"); + op.add(Builder::evictions, JsonpDeserializer.integerDeserializer(), "evictions"); + op.add(Builder::hitCount, JsonpDeserializer.integerDeserializer(), "hit_count"); + op.add(Builder::memorySize, JsonpDeserializer.stringDeserializer(), "memory_size"); + op.add(Builder::memorySizeInBytes, JsonpDeserializer.integerDeserializer(), "memory_size_in_bytes"); + op.add(Builder::missCount, JsonpDeserializer.integerDeserializer(), "miss_count"); + op.add(Builder::totalCount, JsonpDeserializer.integerDeserializer(), "total_count"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/RecoveryStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/RecoveryStats.java index e9167920b6..80f4d182ff 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/RecoveryStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/RecoveryStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,171 +44,169 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.RecoveryStats @JsonpDeserializable public class RecoveryStats implements JsonpSerializable { - private final long currentAsSource; + private final long currentAsSource; - private final long currentAsTarget; + private final long currentAsTarget; - @Nullable - private final String throttleTime; + @Nullable + private final String throttleTime; - private final long throttleTimeInMillis; + private final long throttleTimeInMillis; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - private RecoveryStats(Builder builder) { + private RecoveryStats(Builder builder) { - this.currentAsSource = ApiTypeHelper.requireNonNull(builder.currentAsSource, this, "currentAsSource"); - this.currentAsTarget = ApiTypeHelper.requireNonNull(builder.currentAsTarget, this, "currentAsTarget"); - this.throttleTime = builder.throttleTime; - this.throttleTimeInMillis = ApiTypeHelper.requireNonNull(builder.throttleTimeInMillis, this, - "throttleTimeInMillis"); - - } - - public static RecoveryStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code current_as_source} - */ - public final long currentAsSource() { - return this.currentAsSource; - } - - /** - * Required - API name: {@code current_as_target} - */ - public final long currentAsTarget() { - return this.currentAsTarget; - } - - /** - * API name: {@code throttle_time} - */ - @Nullable - public final String throttleTime() { - return this.throttleTime; - } - - /** - * Required - API name: {@code throttle_time_in_millis} - */ - public final long throttleTimeInMillis() { - return this.throttleTimeInMillis; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("current_as_source"); - generator.write(this.currentAsSource); - - generator.writeKey("current_as_target"); - generator.write(this.currentAsTarget); - - if (this.throttleTime != null) { - generator.writeKey("throttle_time"); - generator.write(this.throttleTime); - - } - generator.writeKey("throttle_time_in_millis"); - generator.write(this.throttleTimeInMillis); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link RecoveryStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long currentAsSource; - - private Long currentAsTarget; - - @Nullable - private String throttleTime; - - private Long throttleTimeInMillis; - - /** - * Required - API name: {@code current_as_source} - */ - public final Builder currentAsSource(long value) { - this.currentAsSource = value; - return this; - } - - /** - * Required - API name: {@code current_as_target} - */ - public final Builder currentAsTarget(long value) { - this.currentAsTarget = value; - return this; - } - - /** - * API name: {@code throttle_time} - */ - public final Builder throttleTime(@Nullable String value) { - this.throttleTime = value; - return this; - } - - /** - * Required - API name: {@code throttle_time_in_millis} - */ - public final Builder throttleTimeInMillis(long value) { - this.throttleTimeInMillis = value; - return this; - } - - /** - * Builds a {@link RecoveryStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public RecoveryStats build() { - _checkSingleUse(); - - return new RecoveryStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link RecoveryStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - RecoveryStats::setupRecoveryStatsDeserializer); - - protected static void setupRecoveryStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::currentAsSource, JsonpDeserializer.longDeserializer(), "current_as_source"); - op.add(Builder::currentAsTarget, JsonpDeserializer.longDeserializer(), "current_as_target"); - op.add(Builder::throttleTime, JsonpDeserializer.stringDeserializer(), "throttle_time"); - op.add(Builder::throttleTimeInMillis, JsonpDeserializer.longDeserializer(), "throttle_time_in_millis"); - - } + this.currentAsSource = ApiTypeHelper.requireNonNull(builder.currentAsSource, this, "currentAsSource"); + this.currentAsTarget = ApiTypeHelper.requireNonNull(builder.currentAsTarget, this, "currentAsTarget"); + this.throttleTime = builder.throttleTime; + this.throttleTimeInMillis = ApiTypeHelper.requireNonNull(builder.throttleTimeInMillis, this, "throttleTimeInMillis"); + + } + + public static RecoveryStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Required - API name: {@code current_as_source} + */ + public final long currentAsSource() { + return this.currentAsSource; + } + + /** + * Required - API name: {@code current_as_target} + */ + public final long currentAsTarget() { + return this.currentAsTarget; + } + + /** + * API name: {@code throttle_time} + */ + @Nullable + public final String throttleTime() { + return this.throttleTime; + } + + /** + * Required - API name: {@code throttle_time_in_millis} + */ + public final long throttleTimeInMillis() { + return this.throttleTimeInMillis; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("current_as_source"); + generator.write(this.currentAsSource); + + generator.writeKey("current_as_target"); + generator.write(this.currentAsTarget); + + if (this.throttleTime != null) { + generator.writeKey("throttle_time"); + generator.write(this.throttleTime); + + } + generator.writeKey("throttle_time_in_millis"); + generator.write(this.throttleTimeInMillis); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RecoveryStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long currentAsSource; + + private Long currentAsTarget; + + @Nullable + private String throttleTime; + + private Long throttleTimeInMillis; + + /** + * Required - API name: {@code current_as_source} + */ + public final Builder currentAsSource(long value) { + this.currentAsSource = value; + return this; + } + + /** + * Required - API name: {@code current_as_target} + */ + public final Builder currentAsTarget(long value) { + this.currentAsTarget = value; + return this; + } + + /** + * API name: {@code throttle_time} + */ + public final Builder throttleTime(@Nullable String value) { + this.throttleTime = value; + return this; + } + + /** + * Required - API name: {@code throttle_time_in_millis} + */ + public final Builder throttleTimeInMillis(long value) { + this.throttleTimeInMillis = value; + return this; + } + + /** + * Builds a {@link RecoveryStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RecoveryStats build() { + _checkSingleUse(); + + return new RecoveryStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RecoveryStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + RecoveryStats::setupRecoveryStatsDeserializer + ); + + protected static void setupRecoveryStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::currentAsSource, JsonpDeserializer.longDeserializer(), "current_as_source"); + op.add(Builder::currentAsTarget, JsonpDeserializer.longDeserializer(), "current_as_target"); + op.add(Builder::throttleTime, JsonpDeserializer.stringDeserializer(), "throttle_time"); + op.add(Builder::throttleTimeInMillis, JsonpDeserializer.longDeserializer(), "throttle_time_in_millis"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Refresh.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Refresh.java index bbd1ccec70..b1b78d0305 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Refresh.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Refresh.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,23 +37,23 @@ @JsonpDeserializable public enum Refresh implements JsonEnum { - True("true"), + True("true"), - False("false"), + False("false"), - WaitFor("wait_for"), + WaitFor("wait_for"), - ; + ; - private final String jsonValue; + private final String jsonValue; - Refresh(String jsonValue) { - this.jsonValue = jsonValue; - } + Refresh(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Refresh.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Refresh.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/RefreshStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/RefreshStats.java index 74032db07b..bfa6015a4b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/RefreshStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/RefreshStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,221 +44,217 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.RefreshStats - @JsonpDeserializable public class RefreshStats implements JsonpSerializable { - private final long externalTotal; - - private final long externalTotalTimeInMillis; - - private final long listeners; - - private final long total; - - @Nullable - private final String totalTime; + private final long externalTotal; + + private final long externalTotalTimeInMillis; + + private final long listeners; + + private final long total; + + @Nullable + private final String totalTime; + + private final long totalTimeInMillis; - private final long totalTimeInMillis; + // --------------------------------------------------------------------------------------------- - // --------------------------------------------------------------------------------------------- + private RefreshStats(Builder builder) { - private RefreshStats(Builder builder) { + this.externalTotal = ApiTypeHelper.requireNonNull(builder.externalTotal, this, "externalTotal"); + this.externalTotalTimeInMillis = ApiTypeHelper.requireNonNull(builder.externalTotalTimeInMillis, this, "externalTotalTimeInMillis"); + this.listeners = ApiTypeHelper.requireNonNull(builder.listeners, this, "listeners"); + this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); + this.totalTime = builder.totalTime; + this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); - this.externalTotal = ApiTypeHelper.requireNonNull(builder.externalTotal, this, "externalTotal"); - this.externalTotalTimeInMillis = ApiTypeHelper.requireNonNull(builder.externalTotalTimeInMillis, this, - "externalTotalTimeInMillis"); - this.listeners = ApiTypeHelper.requireNonNull(builder.listeners, this, "listeners"); - this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - this.totalTime = builder.totalTime; - this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); + } - } + public static RefreshStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } - public static RefreshStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } + /** + * Required - API name: {@code external_total} + */ + public final long externalTotal() { + return this.externalTotal; + } - /** - * Required - API name: {@code external_total} - */ - public final long externalTotal() { - return this.externalTotal; - } + /** + * Required - API name: {@code external_total_time_in_millis} + */ + public final long externalTotalTimeInMillis() { + return this.externalTotalTimeInMillis; + } - /** - * Required - API name: {@code external_total_time_in_millis} - */ - public final long externalTotalTimeInMillis() { - return this.externalTotalTimeInMillis; - } + /** + * Required - API name: {@code listeners} + */ + public final long listeners() { + return this.listeners; + } - /** - * Required - API name: {@code listeners} - */ - public final long listeners() { - return this.listeners; - } - - /** - * Required - API name: {@code total} - */ - public final long total() { - return this.total; - } - - /** - * API name: {@code total_time} - */ - @Nullable - public final String totalTime() { - return this.totalTime; - } - - /** - * Required - API name: {@code total_time_in_millis} - */ - public final long totalTimeInMillis() { - return this.totalTimeInMillis; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("external_total"); - generator.write(this.externalTotal); - - generator.writeKey("external_total_time_in_millis"); - generator.write(this.externalTotalTimeInMillis); - - generator.writeKey("listeners"); - generator.write(this.listeners); - - generator.writeKey("total"); - generator.write(this.total); - - if (this.totalTime != null) { - generator.writeKey("total_time"); - generator.write(this.totalTime); - - } - generator.writeKey("total_time_in_millis"); - generator.write(this.totalTimeInMillis); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link RefreshStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long externalTotal; - - private Long externalTotalTimeInMillis; - - private Long listeners; - - private Long total; - - @Nullable - private String totalTime; - - private Long totalTimeInMillis; - - /** - * Required - API name: {@code external_total} - */ - public final Builder externalTotal(long value) { - this.externalTotal = value; - return this; - } - - /** - * Required - API name: {@code external_total_time_in_millis} - */ - public final Builder externalTotalTimeInMillis(long value) { - this.externalTotalTimeInMillis = value; - return this; - } - - /** - * Required - API name: {@code listeners} - */ - public final Builder listeners(long value) { - this.listeners = value; - return this; - } - - /** - * Required - API name: {@code total} - */ - public final Builder total(long value) { - this.total = value; - return this; - } - - /** - * API name: {@code total_time} - */ - public final Builder totalTime(@Nullable String value) { - this.totalTime = value; - return this; - } - - /** - * Required - API name: {@code total_time_in_millis} - */ - public final Builder totalTimeInMillis(long value) { - this.totalTimeInMillis = value; - return this; - } - - /** - * Builds a {@link RefreshStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public RefreshStats build() { - _checkSingleUse(); - - return new RefreshStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link RefreshStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - RefreshStats::setupRefreshStatsDeserializer); - - protected static void setupRefreshStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::externalTotal, JsonpDeserializer.longDeserializer(), "external_total"); - op.add(Builder::externalTotalTimeInMillis, JsonpDeserializer.longDeserializer(), - "external_total_time_in_millis"); - op.add(Builder::listeners, JsonpDeserializer.longDeserializer(), "listeners"); - op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); - op.add(Builder::totalTime, JsonpDeserializer.stringDeserializer(), "total_time"); - op.add(Builder::totalTimeInMillis, JsonpDeserializer.longDeserializer(), "total_time_in_millis"); - - } + /** + * Required - API name: {@code total} + */ + public final long total() { + return this.total; + } + + /** + * API name: {@code total_time} + */ + @Nullable + public final String totalTime() { + return this.totalTime; + } + + /** + * Required - API name: {@code total_time_in_millis} + */ + public final long totalTimeInMillis() { + return this.totalTimeInMillis; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("external_total"); + generator.write(this.externalTotal); + + generator.writeKey("external_total_time_in_millis"); + generator.write(this.externalTotalTimeInMillis); + + generator.writeKey("listeners"); + generator.write(this.listeners); + + generator.writeKey("total"); + generator.write(this.total); + + if (this.totalTime != null) { + generator.writeKey("total_time"); + generator.write(this.totalTime); + + } + generator.writeKey("total_time_in_millis"); + generator.write(this.totalTimeInMillis); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RefreshStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long externalTotal; + + private Long externalTotalTimeInMillis; + + private Long listeners; + + private Long total; + + @Nullable + private String totalTime; + + private Long totalTimeInMillis; + + /** + * Required - API name: {@code external_total} + */ + public final Builder externalTotal(long value) { + this.externalTotal = value; + return this; + } + + /** + * Required - API name: {@code external_total_time_in_millis} + */ + public final Builder externalTotalTimeInMillis(long value) { + this.externalTotalTimeInMillis = value; + return this; + } + + /** + * Required - API name: {@code listeners} + */ + public final Builder listeners(long value) { + this.listeners = value; + return this; + } + + /** + * Required - API name: {@code total} + */ + public final Builder total(long value) { + this.total = value; + return this; + } + + /** + * API name: {@code total_time} + */ + public final Builder totalTime(@Nullable String value) { + this.totalTime = value; + return this; + } + + /** + * Required - API name: {@code total_time_in_millis} + */ + public final Builder totalTimeInMillis(long value) { + this.totalTimeInMillis = value; + return this; + } + + /** + * Builds a {@link RefreshStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RefreshStats build() { + _checkSingleUse(); + + return new RefreshStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RefreshStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + RefreshStats::setupRefreshStatsDeserializer + ); + + protected static void setupRefreshStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::externalTotal, JsonpDeserializer.longDeserializer(), "external_total"); + op.add(Builder::externalTotalTimeInMillis, JsonpDeserializer.longDeserializer(), "external_total_time_in_millis"); + op.add(Builder::listeners, JsonpDeserializer.longDeserializer(), "listeners"); + op.add(Builder::total, JsonpDeserializer.longDeserializer(), "total"); + op.add(Builder::totalTime, JsonpDeserializer.stringDeserializer(), "total_time"); + op.add(Builder::totalTimeInMillis, JsonpDeserializer.longDeserializer(), "total_time_in_millis"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/RequestBase.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/RequestBase.java index 2017f5d127..165c5258a0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/RequestBase.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/RequestBase.java @@ -30,26 +30,18 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.util.ObjectBuilderBase; // typedef: _types.RequestBase - public abstract class RequestBase { - public RequestBase() { - } + public RequestBase() {} - protected abstract static class AbstractBuilder> - extends - ObjectBuilderBase { - protected abstract BuilderT self(); + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { + protected abstract BuilderT self(); - } + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/RequestCacheStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/RequestCacheStats.java index b324630d5c..1b7a25c28f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/RequestCacheStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/RequestCacheStats.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,194 +44,193 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.RequestCacheStats @JsonpDeserializable public class RequestCacheStats implements JsonpSerializable { - private final long evictions; + private final long evictions; - private final long hitCount; + private final long hitCount; - @Nullable - private final String memorySize; + @Nullable + private final String memorySize; - private final long memorySizeInBytes; + private final long memorySizeInBytes; - private final long missCount; + private final long missCount; - // --------------------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------------------- - private RequestCacheStats(Builder builder) { + private RequestCacheStats(Builder builder) { - this.evictions = ApiTypeHelper.requireNonNull(builder.evictions, this, "evictions"); - this.hitCount = ApiTypeHelper.requireNonNull(builder.hitCount, this, "hitCount"); - this.memorySize = builder.memorySize; - this.memorySizeInBytes = ApiTypeHelper.requireNonNull(builder.memorySizeInBytes, this, "memorySizeInBytes"); - this.missCount = ApiTypeHelper.requireNonNull(builder.missCount, this, "missCount"); + this.evictions = ApiTypeHelper.requireNonNull(builder.evictions, this, "evictions"); + this.hitCount = ApiTypeHelper.requireNonNull(builder.hitCount, this, "hitCount"); + this.memorySize = builder.memorySize; + this.memorySizeInBytes = ApiTypeHelper.requireNonNull(builder.memorySizeInBytes, this, "memorySizeInBytes"); + this.missCount = ApiTypeHelper.requireNonNull(builder.missCount, this, "missCount"); - } + } - public static RequestCacheStats of(Function> fn) { - return fn.apply(new Builder()).build(); - } + public static RequestCacheStats of(Function> fn) { + return fn.apply(new Builder()).build(); + } - /** - * Required - API name: {@code evictions} - */ - public final long evictions() { - return this.evictions; - } - - /** - * Required - API name: {@code hit_count} - */ - public final long hitCount() { - return this.hitCount; - } - - /** - * API name: {@code memory_size} - */ - @Nullable - public final String memorySize() { - return this.memorySize; - } - - /** - * Required - API name: {@code memory_size_in_bytes} - */ - public final long memorySizeInBytes() { - return this.memorySizeInBytes; - } - - /** - * Required - API name: {@code miss_count} - */ - public final long missCount() { - return this.missCount; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("evictions"); - generator.write(this.evictions); - - generator.writeKey("hit_count"); - generator.write(this.hitCount); - - if (this.memorySize != null) { - generator.writeKey("memory_size"); - generator.write(this.memorySize); - - } - generator.writeKey("memory_size_in_bytes"); - generator.write(this.memorySizeInBytes); - - generator.writeKey("miss_count"); - generator.write(this.missCount); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link RequestCacheStats}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long evictions; - - private Long hitCount; - - @Nullable - private String memorySize; - - private Long memorySizeInBytes; - - private Long missCount; - - /** - * Required - API name: {@code evictions} - */ - public final Builder evictions(long value) { - this.evictions = value; - return this; - } - - /** - * Required - API name: {@code hit_count} - */ - public final Builder hitCount(long value) { - this.hitCount = value; - return this; - } - - /** - * API name: {@code memory_size} - */ - public final Builder memorySize(@Nullable String value) { - this.memorySize = value; - return this; - } - - /** - * Required - API name: {@code memory_size_in_bytes} - */ - public final Builder memorySizeInBytes(long value) { - this.memorySizeInBytes = value; - return this; - } - - /** - * Required - API name: {@code miss_count} - */ - public final Builder missCount(long value) { - this.missCount = value; - return this; - } - - /** - * Builds a {@link RequestCacheStats}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public RequestCacheStats build() { - _checkSingleUse(); - - return new RequestCacheStats(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link RequestCacheStats} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer - .lazy(Builder::new, RequestCacheStats::setupRequestCacheStatsDeserializer); - - protected static void setupRequestCacheStatsDeserializer(ObjectDeserializer op) { - - op.add(Builder::evictions, JsonpDeserializer.longDeserializer(), "evictions"); - op.add(Builder::hitCount, JsonpDeserializer.longDeserializer(), "hit_count"); - op.add(Builder::memorySize, JsonpDeserializer.stringDeserializer(), "memory_size"); - op.add(Builder::memorySizeInBytes, JsonpDeserializer.longDeserializer(), "memory_size_in_bytes"); - op.add(Builder::missCount, JsonpDeserializer.longDeserializer(), "miss_count"); - - } + /** + * Required - API name: {@code evictions} + */ + public final long evictions() { + return this.evictions; + } + + /** + * Required - API name: {@code hit_count} + */ + public final long hitCount() { + return this.hitCount; + } + + /** + * API name: {@code memory_size} + */ + @Nullable + public final String memorySize() { + return this.memorySize; + } + + /** + * Required - API name: {@code memory_size_in_bytes} + */ + public final long memorySizeInBytes() { + return this.memorySizeInBytes; + } + + /** + * Required - API name: {@code miss_count} + */ + public final long missCount() { + return this.missCount; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.writeKey("evictions"); + generator.write(this.evictions); + + generator.writeKey("hit_count"); + generator.write(this.hitCount); + + if (this.memorySize != null) { + generator.writeKey("memory_size"); + generator.write(this.memorySize); + + } + generator.writeKey("memory_size_in_bytes"); + generator.write(this.memorySizeInBytes); + + generator.writeKey("miss_count"); + generator.write(this.missCount); + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link RequestCacheStats}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long evictions; + + private Long hitCount; + + @Nullable + private String memorySize; + + private Long memorySizeInBytes; + + private Long missCount; + + /** + * Required - API name: {@code evictions} + */ + public final Builder evictions(long value) { + this.evictions = value; + return this; + } + + /** + * Required - API name: {@code hit_count} + */ + public final Builder hitCount(long value) { + this.hitCount = value; + return this; + } + + /** + * API name: {@code memory_size} + */ + public final Builder memorySize(@Nullable String value) { + this.memorySize = value; + return this; + } + + /** + * Required - API name: {@code memory_size_in_bytes} + */ + public final Builder memorySizeInBytes(long value) { + this.memorySizeInBytes = value; + return this; + } + + /** + * Required - API name: {@code miss_count} + */ + public final Builder missCount(long value) { + this.missCount = value; + return this; + } + + /** + * Builds a {@link RequestCacheStats}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public RequestCacheStats build() { + _checkSingleUse(); + + return new RequestCacheStats(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link RequestCacheStats} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + RequestCacheStats::setupRequestCacheStatsDeserializer + ); + + protected static void setupRequestCacheStatsDeserializer(ObjectDeserializer op) { + + op.add(Builder::evictions, JsonpDeserializer.longDeserializer(), "evictions"); + op.add(Builder::hitCount, JsonpDeserializer.longDeserializer(), "hit_count"); + op.add(Builder::memorySize, JsonpDeserializer.stringDeserializer(), "memory_size"); + op.add(Builder::memorySizeInBytes, JsonpDeserializer.longDeserializer(), "memory_size_in_bytes"); + op.add(Builder::missCount, JsonpDeserializer.longDeserializer(), "miss_count"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Result.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Result.java index 02597e9133..54b408cf76 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Result.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Result.java @@ -30,10 +30,6 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; import org.opensearch.client.json.JsonEnum; @@ -41,27 +37,27 @@ @JsonpDeserializable public enum Result implements JsonEnum { - Created("created"), + Created("created"), - Updated("updated"), + Updated("updated"), - Deleted("deleted"), + Deleted("deleted"), - NotFound("not_found"), + NotFound("not_found"), - NoOp("noop"), + NoOp("noop"), - ; + ; - private final String jsonValue; + private final String jsonValue; - Result(String jsonValue) { - this.jsonValue = jsonValue; - } + Result(String jsonValue) { + this.jsonValue = jsonValue; + } - public String jsonValue() { - return this.jsonValue; - } + public String jsonValue() { + return this.jsonValue; + } - public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Result.values()); + public static final JsonEnum.Deserializer _DESERIALIZER = new JsonEnum.Deserializer<>(Result.values()); } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Retries.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Retries.java index ec40fd5de1..235a05576c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Retries.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Retries.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -45,116 +43,116 @@ import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.Retries @JsonpDeserializable public class Retries implements JsonpSerializable { - private final long bulk; - - private final long search; - - // --------------------------------------------------------------------------------------------- + private final long bulk; - private Retries(Builder builder) { + private final long search; + + // --------------------------------------------------------------------------------------------- - this.bulk = ApiTypeHelper.requireNonNull(builder.bulk, this, "bulk"); - this.search = ApiTypeHelper.requireNonNull(builder.search, this, "search"); + private Retries(Builder builder) { - } + this.bulk = ApiTypeHelper.requireNonNull(builder.bulk, this, "bulk"); + this.search = ApiTypeHelper.requireNonNull(builder.search, this, "search"); - public static Retries of(Function> fn) { - return fn.apply(new Builder()).build(); - } + } - /** - * Required - API name: {@code bulk} - */ - public final long bulk() { - return this.bulk; - } + public static Retries of(Function> fn) { + return fn.apply(new Builder()).build(); + } - /** - * Required - API name: {@code search} - */ - public final long search() { - return this.search; - } + /** + * Required - API name: {@code bulk} + */ + public final long bulk() { + return this.bulk; + } - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } + /** + * Required - API name: {@code search} + */ + public final long search() { + return this.search; + } - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } - generator.writeKey("bulk"); - generator.write(this.bulk); + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("search"); - generator.write(this.search); + generator.writeKey("bulk"); + generator.write(this.bulk); - } + generator.writeKey("search"); + generator.write(this.search); - // --------------------------------------------------------------------------------------------- + } - /** - * Builder for {@link Retries}. - */ + // --------------------------------------------------------------------------------------------- - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private Long bulk; + /** + * Builder for {@link Retries}. + */ - private Long search; + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Long bulk; - /** - * Required - API name: {@code bulk} - */ - public final Builder bulk(long value) { - this.bulk = value; - return this; - } + private Long search; - /** - * Required - API name: {@code search} - */ - public final Builder search(long value) { - this.search = value; - return this; - } + /** + * Required - API name: {@code bulk} + */ + public final Builder bulk(long value) { + this.bulk = value; + return this; + } - /** - * Builds a {@link Retries}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public Retries build() { - _checkSingleUse(); + /** + * Required - API name: {@code search} + */ + public final Builder search(long value) { + this.search = value; + return this; + } - return new Retries(this); - } - } + /** + * Builds a {@link Retries}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public Retries build() { + _checkSingleUse(); - // --------------------------------------------------------------------------------------------- + return new Retries(this); + } + } - /** - * Json deserializer for {@link Retries} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - Retries::setupRetriesDeserializer); + // --------------------------------------------------------------------------------------------- - protected static void setupRetriesDeserializer(ObjectDeserializer op) { + /** + * Json deserializer for {@link Retries} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + Retries::setupRetriesDeserializer + ); - op.add(Builder::bulk, JsonpDeserializer.longDeserializer(), "bulk"); - op.add(Builder::search, JsonpDeserializer.longDeserializer(), "search"); + protected static void setupRetriesDeserializer(ObjectDeserializer op) { - } + op.add(Builder::bulk, JsonpDeserializer.longDeserializer(), "bulk"); + op.add(Builder::search, JsonpDeserializer.longDeserializer(), "search"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ScoreSort.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ScoreSort.java index 486075482a..b432f1dfd1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/ScoreSort.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/ScoreSort.java @@ -30,12 +30,11 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -44,107 +43,105 @@ import org.opensearch.client.json.ObjectDeserializer; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import jakarta.json.stream.JsonGenerator; - -import java.util.function.Function; -import javax.annotation.Nullable; // typedef: _types.ScoreSort @JsonpDeserializable public class ScoreSort implements SortOptionsVariant, JsonpSerializable { - @Nullable - private final SortOrder order; - - // --------------------------------------------------------------------------------------------- - - private ScoreSort(Builder builder) { - - this.order = builder.order; - - } - - public static ScoreSort of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * SortOptions variant kind. - */ - @Override - public SortOptions.Kind _sortOptionsKind() { - return SortOptions.Kind.Doc; - } - - /** - * API name: {@code order} - */ - @Nullable - public final SortOrder order() { - return this.order; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (this.order != null) { - generator.writeKey("order"); - this.order.serialize(generator, mapper); - } - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link ScoreSort}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private SortOrder order; - - /** - * API name: {@code order} - */ - public final Builder order(@Nullable SortOrder value) { - this.order = value; - return this; - } - - /** - * Builds a {@link ScoreSort}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public ScoreSort build() { - _checkSingleUse(); - - return new ScoreSort(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link ScoreSort} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, - ScoreSort::setupScoreSortDeserializer); - - protected static void setupScoreSortDeserializer(ObjectDeserializer op) { - - op.add(Builder::order, SortOrder._DESERIALIZER, "order"); - - } + @Nullable + private final SortOrder order; + + // --------------------------------------------------------------------------------------------- + + private ScoreSort(Builder builder) { + + this.order = builder.order; + + } + + public static ScoreSort of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * SortOptions variant kind. + */ + @Override + public SortOptions.Kind _sortOptionsKind() { + return SortOptions.Kind.Doc; + } + + /** + * API name: {@code order} + */ + @Nullable + public final SortOrder order() { + return this.order; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.order != null) { + generator.writeKey("order"); + this.order.serialize(generator, mapper); + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link ScoreSort}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + @Nullable + private SortOrder order; + + /** + * API name: {@code order} + */ + public final Builder order(@Nullable SortOrder value) { + this.order = value; + return this; + } + + /** + * Builds a {@link ScoreSort}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public ScoreSort build() { + _checkSingleUse(); + + return new ScoreSort(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link ScoreSort} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + ScoreSort::setupScoreSortDeserializer + ); + + protected static void setupScoreSortDeserializer(ObjectDeserializer op) { + + op.add(Builder::order, SortOrder._DESERIALIZER, "order"); + + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java index bdef9edc12..6f969b8f5a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java @@ -30,12 +30,10 @@ * GitHub history for details. */ -//---------------------------------------------------- -// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. -//---------------------------------------------------- - package org.opensearch.client.opensearch._types; +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; import org.opensearch.client.json.JsonpDeserializable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -46,127 +44,125 @@ import org.opensearch.client.util.ObjectBuilderBase; import org.opensearch.client.util.TaggedUnion; import org.opensearch.client.util.TaggedUnionUtils; -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; // typedef: _types.Script @JsonpDeserializable public class Script implements TaggedUnion, JsonpSerializable { - public enum Kind { - Inline, Stored - - } - - private final Kind _kind; - private final Object _value; - - @Override - public final Kind _kind() { - return _kind; - } - - @Override - public final Object _get() { - return _value; - } - - private Script(Kind kind, Object value) { - this._kind = kind; - this._value = value; - } - - private Script(Builder builder) { - - this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); - this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); - - } - - public static Script of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Is this variant instance of kind {@code inline}? - */ - public boolean isInline() { - return _kind == Kind.Inline; - } - - /** - * Get the {@code inline} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code inline} kind. - */ - public InlineScript inline() { - return TaggedUnionUtils.get(this, Kind.Inline); - } - - /** - * Is this variant instance of kind {@code stored}? - */ - public boolean isStored() { - return _kind == Kind.Stored; - } - - /** - * Get the {@code stored} variant value. - * - * @throws IllegalStateException - * if the current variant is not of the {@code stored} kind. - */ - public StoredScriptId stored() { - return TaggedUnionUtils.get(this, Kind.Stored); - } - - @Override - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - if (_value instanceof JsonpSerializable) { - ((JsonpSerializable) _value).serialize(generator, mapper); - } - - } - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder