Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
Signed-off-by: saimedhi <[email protected]>
  • Loading branch information
saimedhi committed Jan 25, 2024
1 parent 900ea94 commit dc66171
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 66 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/update_file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Update OpenSearch API
on: [push]
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/[email protected]
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 <[email protected]>
author: opensearchpy-api-update-bot <[email protected]>
- name: Update CHANGELOG
uses: jacobtomlinson/gha-find-replace@v3
if: ${{ steps.cpr.outputs.pull-request-number != '' }}
with:
include: CHANGELOG.md
find: "\\- Your contribution here."
replace: "- Updated opensearch-py to reflect the latest OpenSearch API spec ([#${{steps.cpr.outputs.pull-request-number}}](https://github.com/opensearch-project/opensearch-py/pull/${{steps.cpr.outputs.pull-request-number}}))\n- Your contribution here."
- 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 '[email protected]'
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 Bot
- 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))
Expand Down
67 changes: 1 addition & 66 deletions opensearchpy/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,72 +339,7 @@ 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",
Expand Down

0 comments on commit dc66171

Please sign in to comment.