From 76a0dadfdd80097dea060309cc92a3ced64c3f66 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 19:10:21 -0800 Subject: [PATCH 01/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_file.yml | 77 +++++++++++++++++++++++++++++++ CHANGELOG.md | 2 + noxfile.py | 2 +- opensearchpy/client/__init__.py | 66 -------------------------- 4 files changed, 80 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/update_file.yml diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml new file mode 100644 index 00000000..dd9bc3be --- /dev/null +++ b/.github/workflows/update_file.yml @@ -0,0 +1,77 @@ +name: Update OpenSearch API +on: + workflow_dispatch: + schedule: + - cron: "10 2 * * *" +jobs: + update-api: + if: ${{ github.repository == 'saimedhi/opensearch-py' }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Config git to rebase + run: git config --global pull.rebase true + - name: Set up Python 3.7 + uses: actions/setup-python@v4 + with: + python-version: 3.7 + - name: Install dependencies + run: | + python3.7 -m pip install nox + - name: Generate API + run: nox -s generate + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" + - name: GitHub App token + if: ${{ github.repository == 'saimedhi/opensearch-py' }} + id: github_app_token + uses: tibdex/github-app-token@v2.1.0 + with: + app_id: ${{ secrets.CI_APP_ID }} + private_key: ${{ secrets.CI_APP_PRIVATE_KEY }} + - name: Create pull request + id: cpr + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Updated opensearch-py to reflect the latest OpenSearch API spec (${{ steps.date.outputs.date }}) + title: Updated opensearch-py to reflect the latest OpenSearch API spec + body: | + Updated [opensearch-py](https://github.com/saimedhi/opensearch-py) to reflect the latest [OpenSearch API spec](https://github.com/opensearch-project/opensearch-api-specification/blob/main/OpenSearch.openapi.json) + Date: ${{ steps.date.outputs.date }} + branch: automated-api-update + base: main + committer: opensearchpy-api-update-bot + author: opensearchpy-api-update-bot + - name: Check out update branch + if: ${{ steps.cpr.outputs.pull-request-number != '' }} + run: | + git fetch origin automated-api-update + git checkout automated-api-update + - name: Update CHANGELOG + uses: jacobtomlinson/gha-find-replace@v3 + if: ${{ steps.cpr.outputs.pull-request-number != '' }} + with: + branch: automated-api-update + find: "- Your contribution here." + replace: "Updated opensearch-py to reflect the latest OpenSearch API spec ([#${{steps.cpr.outputs.pull-request-number}}](https://github.com/saimedhi/opensearch-py/pull/${{steps.cpr.outputs.pull-request-number}}))\n- Your contribution here." + include: "**CHANGELOG.md" + - name: Commit and Push + if: ${{ steps.cpr.outputs.pull-request-number != '' }} + run: | + git config --local user.name 'opensearchpy-api-update-bot' + git config --local user.email 'noreply@github.com' + git config --local --unset-all http.https://github.com/.extraheader || true + AUTH=$(echo -n "x-access-token:${{ steps.github_app_token.outputs.token || secrets.GITHUB_TOKEN }}" | base64) + echo "::add-mask::${AUTH}" + git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${AUTH}" + git add CHANGELOG.md + git commit --amend --no-edit + git push origin automated-api-update -f diff --git a/CHANGELOG.md b/CHANGELOG.md index 40563c66..a5987341 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Incorporated API generation into CI workflow and fixed 'generate' nox session ([#660](https://github.com/opensearch-project/opensearch-py/pull/660)) ### Changed - Updated the `get_policy` API in the index_management plugin to allow the policy_id argument as optional ([#633](https://github.com/opensearch-project/opensearch-py/pull/633)) +### Automated API Update +- Your contribution here. ### Deprecated ### Removed - Removed unnecessary `# -*- coding: utf-8 -*-` headers from .py files ([#615](https://github.com/opensearch-project/opensearch-py/pull/615), [#617](https://github.com/opensearch-project/opensearch-py/pull/617)) diff --git a/noxfile.py b/noxfile.py index 1b261fe0..df945d2a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -74,7 +74,7 @@ def format(session: Any) -> None: session.run("black", *SOURCE_FILES) session.run("python", "utils/license_headers.py", "fix", *SOURCE_FILES) - session.notify("lint") + #session.notify("lint") @nox.session(python=["3.7"]) # type: ignore diff --git a/opensearchpy/client/__init__.py b/opensearchpy/client/__init__.py index 0dfafab7..1caaba88 100644 --- a/opensearchpy/client/__init__.py +++ b/opensearchpy/client/__init__.py @@ -339,72 +339,6 @@ def create( "PUT", path, params=params, headers=headers, body=body ) - @query_params( - "if_primary_term", - "if_seq_no", - "op_type", - "pipeline", - "refresh", - "require_alias", - "routing", - "timeout", - "version", - "version_type", - "wait_for_active_shards", - ) - def index( - self, - index: Any, - body: Any, - id: Any = None, - params: Any = None, - headers: Any = None, - ) -> Any: - """ - Creates or updates a document in an index. - - - :arg index: Index name. - :arg body: The document - :arg id: Document ID. - :arg if_primary_term: only perform the operation if the last - operation that has changed the document has the specified primary term. - :arg if_seq_no: only perform the operation if the last operation - that has changed the document has the specified sequence number. - :arg op_type: Explicit operation type. Defaults to `index` for - requests with an explicit document ID, and to `create` for requests - without an explicit document ID. Valid choices are index, create. - :arg pipeline: The pipeline id to preprocess incoming documents - with. - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices are true, false, wait_for. - :arg require_alias: When true, requires destination to be an - alias. Default is false. - :arg routing: Routing value. - :arg timeout: Operation timeout. - :arg version: Explicit version number for concurrency control. - :arg version_type: Specific version type. Valid choices are - internal, external, external_gte, force. - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the operation. Defaults to 1, - meaning the primary shard only. Set to `all` for all shard copies, - otherwise set to any non-negative value less than or equal to the total - number of copies for the shard (number of replicas + 1). Default is 1. - """ - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return self.transport.perform_request( - "POST" if id in SKIP_IN_PATH else "PUT", - _make_path(index, "_doc", id), - params=params, - headers=headers, - body=body, - ) - @query_params( "_source", "_source_excludes", From d693e36cfd28e9b7af58841e7e5611ac7511274e Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 19:11:05 -0800 Subject: [PATCH 02/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml index dd9bc3be..30de4853 100644 --- a/.github/workflows/update_file.yml +++ b/.github/workflows/update_file.yml @@ -2,7 +2,7 @@ name: Update OpenSearch API on: workflow_dispatch: schedule: - - cron: "10 2 * * *" + - cron: "11 2 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} From 9bb3a11e71a9fd6e2001fbc73e39a2f9dcd36b90 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 19:11:18 -0800 Subject: [PATCH 03/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml index 30de4853..21357dd9 100644 --- a/.github/workflows/update_file.yml +++ b/.github/workflows/update_file.yml @@ -2,7 +2,7 @@ name: Update OpenSearch API on: workflow_dispatch: schedule: - - cron: "11 2 * * *" + - cron: "12 2 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} From ea882c861f480068adaa7db0712caca96cb7b481 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 19:14:16 -0800 Subject: [PATCH 04/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml index 21357dd9..bfd6a379 100644 --- a/.github/workflows/update_file.yml +++ b/.github/workflows/update_file.yml @@ -2,7 +2,7 @@ name: Update OpenSearch API on: workflow_dispatch: schedule: - - cron: "12 2 * * *" + - cron: "15 19 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} From 5b42733778f96a22ff35ffbbbd8cb09bb4b0ec96 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 19:16:26 -0800 Subject: [PATCH 05/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml index bfd6a379..a576ef36 100644 --- a/.github/workflows/update_file.yml +++ b/.github/workflows/update_file.yml @@ -2,7 +2,7 @@ name: Update OpenSearch API on: workflow_dispatch: schedule: - - cron: "15 19 * * *" + - cron: "17 3 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} From 58ea182035448f494da67389c3a8e276336bc354 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 19:22:13 -0800 Subject: [PATCH 06/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml index a576ef36..94ccbbab 100644 --- a/.github/workflows/update_file.yml +++ b/.github/workflows/update_file.yml @@ -2,7 +2,7 @@ name: Update OpenSearch API on: workflow_dispatch: schedule: - - cron: "17 3 * * *" + - cron: "25 3 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} From 086563c64759a02a0c9a0bd57a131f7833082f51 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 19:34:23 -0800 Subject: [PATCH 07/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml index 94ccbbab..0401b9d7 100644 --- a/.github/workflows/update_file.yml +++ b/.github/workflows/update_file.yml @@ -61,7 +61,7 @@ jobs: with: branch: automated-api-update find: "- Your contribution here." - replace: "Updated opensearch-py to reflect the latest OpenSearch API spec ([#${{steps.cpr.outputs.pull-request-number}}](https://github.com/saimedhi/opensearch-py/pull/${{steps.cpr.outputs.pull-request-number}}))\n- Your contribution here." + replace: "- Updated opensearch-py to reflect the latest OpenSearch API spec ([#${{steps.cpr.outputs.pull-request-number}}](https://github.com/saimedhi/opensearch-py/pull/${{steps.cpr.outputs.pull-request-number}}))\n- Your contribution here." include: "**CHANGELOG.md" - name: Commit and Push if: ${{ steps.cpr.outputs.pull-request-number != '' }} From 4489b5b7518a2f7ae772b600ebb875496315b182 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 19:38:05 -0800 Subject: [PATCH 08/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_file.yml index 0401b9d7..efcb60f8 100644 --- a/.github/workflows/update_file.yml +++ b/.github/workflows/update_file.yml @@ -2,7 +2,7 @@ name: Update OpenSearch API on: workflow_dispatch: schedule: - - cron: "25 3 * * *" + - cron: "40 3 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} From 41edf3ef2dec8501cf98808d9e8b3c6ab2bdc802 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 22:28:27 -0800 Subject: [PATCH 09/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/{update_file.yml => update_api.yml} | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) rename .github/workflows/{update_file.yml => update_api.yml} (95%) diff --git a/.github/workflows/update_file.yml b/.github/workflows/update_api.yml similarity index 95% rename from .github/workflows/update_file.yml rename to .github/workflows/update_api.yml index efcb60f8..17ce87d5 100644 --- a/.github/workflows/update_file.yml +++ b/.github/workflows/update_api.yml @@ -1,8 +1,8 @@ -name: Update OpenSearch API +name: Update API on: workflow_dispatch: schedule: - - cron: "40 3 * * *" + - cron: "30 6 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} @@ -59,7 +59,6 @@ jobs: uses: jacobtomlinson/gha-find-replace@v3 if: ${{ steps.cpr.outputs.pull-request-number != '' }} with: - branch: automated-api-update find: "- Your contribution here." replace: "- Updated opensearch-py to reflect the latest OpenSearch API spec ([#${{steps.cpr.outputs.pull-request-number}}](https://github.com/saimedhi/opensearch-py/pull/${{steps.cpr.outputs.pull-request-number}}))\n- Your contribution here." include: "**CHANGELOG.md" @@ -74,4 +73,4 @@ jobs: git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${AUTH}" git add CHANGELOG.md git commit --amend --no-edit - git push origin automated-api-update -f + git push origin automated-api-update -f \ No newline at end of file From 7ddb91184dac8e065ebb4cb7ca102d24669e2a74 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 22:35:06 -0800 Subject: [PATCH 10/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_api.yml b/.github/workflows/update_api.yml index 17ce87d5..3c1d74f3 100644 --- a/.github/workflows/update_api.yml +++ b/.github/workflows/update_api.yml @@ -2,7 +2,7 @@ name: Update API on: workflow_dispatch: schedule: - - cron: "30 6 * * *" + - cron: "37 6 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} From bd58c185547e528cfe688dbf42a478064dec7ee1 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Tue, 30 Jan 2024 22:44:30 -0800 Subject: [PATCH 11/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_api.yml b/.github/workflows/update_api.yml index 3c1d74f3..602e64c1 100644 --- a/.github/workflows/update_api.yml +++ b/.github/workflows/update_api.yml @@ -2,7 +2,7 @@ name: Update API on: workflow_dispatch: schedule: - - cron: "37 6 * * *" + - cron: "55 6 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} From b3182d5bc9c31927ab8143b7cfbf5dc6a950a3ad Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Thu, 1 Feb 2024 17:43:18 -0800 Subject: [PATCH 12/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_api.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_api.yml b/.github/workflows/update_api.yml index 602e64c1..1f724930 100644 --- a/.github/workflows/update_api.yml +++ b/.github/workflows/update_api.yml @@ -73,4 +73,5 @@ jobs: git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${AUTH}" git add CHANGELOG.md git commit --amend --no-edit - git push origin automated-api-update -f \ No newline at end of file + git push origin automated-api-update -f + \ No newline at end of file From 6713be3e0131b2b9792091251eff9b08a036bdbf Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Thu, 1 Feb 2024 17:45:18 -0800 Subject: [PATCH 13/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_api.yml | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/.github/workflows/update_api.yml b/.github/workflows/update_api.yml index 1f724930..55a29446 100644 --- a/.github/workflows/update_api.yml +++ b/.github/workflows/update_api.yml @@ -2,7 +2,7 @@ name: Update API on: workflow_dispatch: schedule: - - cron: "55 6 * * *" + - cron: "30 3 * * *" jobs: update-api: if: ${{ github.repository == 'saimedhi/opensearch-py' }} @@ -30,17 +30,17 @@ jobs: id: date run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - name: GitHub App token - if: ${{ github.repository == 'saimedhi/opensearch-py' }} +if: ${{ github.repository == 'saimedhi/opensearch-py' }} id: github_app_token uses: tibdex/github-app-token@v2.1.0 with: app_id: ${{ secrets.CI_APP_ID }} private_key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - name: Create pull request + - name: Create pull request id: cpr uses: peter-evans/create-pull-request@v5 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.github_app_token.outputs.token }} commit-message: Updated opensearch-py to reflect the latest OpenSearch API spec (${{ steps.date.outputs.date }}) title: Updated opensearch-py to reflect the latest OpenSearch API spec body: | @@ -48,8 +48,9 @@ jobs: Date: ${{ steps.date.outputs.date }} branch: automated-api-update base: main - committer: opensearchpy-api-update-bot - author: opensearchpy-api-update-bot + signoff: true + labels: | + autocut - name: Check out update branch if: ${{ steps.cpr.outputs.pull-request-number != '' }} run: | @@ -63,15 +64,8 @@ jobs: replace: "- Updated opensearch-py to reflect the latest OpenSearch API spec ([#${{steps.cpr.outputs.pull-request-number}}](https://github.com/saimedhi/opensearch-py/pull/${{steps.cpr.outputs.pull-request-number}}))\n- Your contribution here." include: "**CHANGELOG.md" - name: Commit and Push - if: ${{ steps.cpr.outputs.pull-request-number != '' }} - run: | - git config --local user.name 'opensearchpy-api-update-bot' - git config --local user.email 'noreply@github.com' - git config --local --unset-all http.https://github.com/.extraheader || true - AUTH=$(echo -n "x-access-token:${{ steps.github_app_token.outputs.token || secrets.GITHUB_TOKEN }}" | base64) - echo "::add-mask::${AUTH}" - git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${AUTH}" - git add CHANGELOG.md - git commit --amend --no-edit - git push origin automated-api-update -f - \ No newline at end of file + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Update changelog" + branch: automated-api-update + commit_options: '--signoff' \ No newline at end of file From 5dd90615c4f5b982f7233c6da6a5076615eb0a42 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Thu, 1 Feb 2024 17:46:21 -0800 Subject: [PATCH 14/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_api.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_api.yml b/.github/workflows/update_api.yml index 55a29446..95f8b26e 100644 --- a/.github/workflows/update_api.yml +++ b/.github/workflows/update_api.yml @@ -30,13 +30,13 @@ jobs: id: date run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - name: GitHub App token -if: ${{ github.repository == 'saimedhi/opensearch-py' }} + if: ${{ github.repository == 'saimedhi/opensearch-py' }} id: github_app_token uses: tibdex/github-app-token@v2.1.0 with: app_id: ${{ secrets.CI_APP_ID }} private_key: ${{ secrets.CI_APP_PRIVATE_KEY }} - - name: Create pull request + - name: Create pull request id: cpr uses: peter-evans/create-pull-request@v5 with: From a32e116edbeffe5bb0be2affe34e32040af0b02d Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada Date: Thu, 1 Feb 2024 17:47:47 -0800 Subject: [PATCH 15/16] updated Signed-off-by: Sai Medhini Reddy Maryada --- .github/workflows/update_api.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/update_api.yml b/.github/workflows/update_api.yml index 95f8b26e..d5319cfa 100644 --- a/.github/workflows/update_api.yml +++ b/.github/workflows/update_api.yml @@ -26,6 +26,12 @@ jobs: python3.7 -m pip install nox - name: Generate API run: nox -s generate + - name: Update CHANGELOG + uses: jacobtomlinson/gha-find-replace@v3 + with: + find: "- Your contribution here." + replace: "- Updated opensearch-py to reflect the latest OpenSearch API spec." + include: "**CHANGELOG.md" - name: Get current date id: date run: echo "::set-output name=date::$(date +'%Y-%m-%d')" @@ -51,21 +57,3 @@ jobs: signoff: true labels: | autocut - - name: Check out update branch - if: ${{ steps.cpr.outputs.pull-request-number != '' }} - run: | - git fetch origin automated-api-update - git checkout automated-api-update - - name: Update CHANGELOG - uses: jacobtomlinson/gha-find-replace@v3 - if: ${{ steps.cpr.outputs.pull-request-number != '' }} - with: - find: "- Your contribution here." - replace: "- Updated opensearch-py to reflect the latest OpenSearch API spec ([#${{steps.cpr.outputs.pull-request-number}}](https://github.com/saimedhi/opensearch-py/pull/${{steps.cpr.outputs.pull-request-number}}))\n- Your contribution here." - include: "**CHANGELOG.md" - - name: Commit and Push - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "Update changelog" - branch: automated-api-update - commit_options: '--signoff' \ No newline at end of file From 00d279a6159d062b820669a58f68ab08ca39d029 Mon Sep 17 00:00:00 2001 From: saimedhi Date: Fri, 2 Feb 2024 01:50:32 +0000 Subject: [PATCH 16/16] Updated opensearch-py to reflect the latest OpenSearch API spec (2024-02-02) Signed-off-by: GitHub --- CHANGELOG.md | 2 +- noxfile.py | 2 +- opensearchpy/_async/client/cluster.py | 5 +- opensearchpy/_async/client/security.py | 2 +- opensearchpy/client/__init__.py | 66 ++++++++++++++++++++++++++ opensearchpy/client/cluster.py | 5 +- opensearchpy/client/security.py | 2 +- 7 files changed, 72 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5987341..0f16f5b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Changed - Updated the `get_policy` API in the index_management plugin to allow the policy_id argument as optional ([#633](https://github.com/opensearch-project/opensearch-py/pull/633)) ### Automated API Update -- Your contribution here. +- Updated opensearch-py to reflect the latest OpenSearch API spec. ### Deprecated ### Removed - Removed unnecessary `# -*- coding: utf-8 -*-` headers from .py files ([#615](https://github.com/opensearch-project/opensearch-py/pull/615), [#617](https://github.com/opensearch-project/opensearch-py/pull/617)) diff --git a/noxfile.py b/noxfile.py index df945d2a..3dd8fea0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -74,7 +74,7 @@ def format(session: Any) -> None: session.run("black", *SOURCE_FILES) session.run("python", "utils/license_headers.py", "fix", *SOURCE_FILES) - #session.notify("lint") + # session.notify("lint") @nox.session(python=["3.7"]) # type: ignore diff --git a/opensearchpy/_async/client/cluster.py b/opensearchpy/_async/client/cluster.py index 70d93cf8..c47aef07 100644 --- a/opensearchpy/_async/client/cluster.py +++ b/opensearchpy/_async/client/cluster.py @@ -530,10 +530,7 @@ async def delete_decommission_awareness( """ return await self.transport.perform_request( - "DELETE", - "/_cluster/decommission/awareness/", - params=params, - headers=headers, + "DELETE", "/_cluster/decommission/awareness", params=params, headers=headers ) @query_params() diff --git a/opensearchpy/_async/client/security.py b/opensearchpy/_async/client/security.py index c5b9f2ca..6b8c2026 100644 --- a/opensearchpy/_async/client/security.py +++ b/opensearchpy/_async/client/security.py @@ -98,7 +98,7 @@ async def get_action_groups( """ return await self.transport.perform_request( "GET", - "/_plugins/_security/api/actiongroups/", + "/_plugins/_security/api/actiongroups", params=params, headers=headers, ) diff --git a/opensearchpy/client/__init__.py b/opensearchpy/client/__init__.py index 1caaba88..0dfafab7 100644 --- a/opensearchpy/client/__init__.py +++ b/opensearchpy/client/__init__.py @@ -339,6 +339,72 @@ def create( "PUT", path, params=params, headers=headers, body=body ) + @query_params( + "if_primary_term", + "if_seq_no", + "op_type", + "pipeline", + "refresh", + "require_alias", + "routing", + "timeout", + "version", + "version_type", + "wait_for_active_shards", + ) + def index( + self, + index: Any, + body: Any, + id: Any = None, + params: Any = None, + headers: Any = None, + ) -> Any: + """ + Creates or updates a document in an index. + + + :arg index: Index name. + :arg body: The document + :arg id: Document ID. + :arg if_primary_term: only perform the operation if the last + operation that has changed the document has the specified primary term. + :arg if_seq_no: only perform the operation if the last operation + that has changed the document has the specified sequence number. + :arg op_type: Explicit operation type. Defaults to `index` for + requests with an explicit document ID, and to `create` for requests + without an explicit document ID. Valid choices are index, create. + :arg pipeline: The pipeline id to preprocess incoming documents + with. + :arg refresh: If `true` then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh + to make this operation visible to search, if `false` (the default) then + do nothing with refreshes. Valid choices are true, false, wait_for. + :arg require_alias: When true, requires destination to be an + alias. Default is false. + :arg routing: Routing value. + :arg timeout: Operation timeout. + :arg version: Explicit version number for concurrency control. + :arg version_type: Specific version type. Valid choices are + internal, external, external_gte, force. + :arg wait_for_active_shards: Sets the number of shard copies + that must be active before proceeding with the operation. Defaults to 1, + meaning the primary shard only. Set to `all` for all shard copies, + otherwise set to any non-negative value less than or equal to the total + number of copies for the shard (number of replicas + 1). Default is 1. + """ + for param in (index, body): + if param in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument.") + + return self.transport.perform_request( + "POST" if id in SKIP_IN_PATH else "PUT", + _make_path(index, "_doc", id), + params=params, + headers=headers, + body=body, + ) + @query_params( "_source", "_source_excludes", diff --git a/opensearchpy/client/cluster.py b/opensearchpy/client/cluster.py index fc49f266..6af86a91 100644 --- a/opensearchpy/client/cluster.py +++ b/opensearchpy/client/cluster.py @@ -530,10 +530,7 @@ def delete_decommission_awareness( """ return self.transport.perform_request( - "DELETE", - "/_cluster/decommission/awareness/", - params=params, - headers=headers, + "DELETE", "/_cluster/decommission/awareness", params=params, headers=headers ) @query_params() diff --git a/opensearchpy/client/security.py b/opensearchpy/client/security.py index d7b76a90..66a365fd 100644 --- a/opensearchpy/client/security.py +++ b/opensearchpy/client/security.py @@ -98,7 +98,7 @@ def get_action_groups( """ return self.transport.perform_request( "GET", - "/_plugins/_security/api/actiongroups/", + "/_plugins/_security/api/actiongroups", params=params, headers=headers, )