Skip to content

Commit

Permalink
Add documentation for the new API
Browse files Browse the repository at this point in the history
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
  • Loading branch information
Arpit-Bandejiya committed Oct 27, 2022
1 parent add6177 commit ac48aae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
OpenSearch Python Client

- [Welcome!](https://github.com/opensearch-project/opensearch-py#welcome)
- [Getting Started](https://github.com/opensearch-project/opensearch-py#getting-started)
- [User guide](https://github.com/opensearch-project/opensearch-py#user-guide)
- [API Doc](https://opensearch-project.github.io/opensearch-py/)
- [Compatibility with OpenSearch](https://github.com/opensearch-project/opensearch-py#compatibility-with-opensearch)
- [Project Resources](https://github.com/opensearch-project/opensearch-py#project-resources)
Expand Down
39 changes: 36 additions & 3 deletions GETTING_STARTED.md → USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- [Using IAM credentials for authentication](#using-iam-credentials-for-authentication)
- [Pre-requisites to use `AWSV4SignerAuth`](#pre-requisites-to-use-awsv4signerauth)

# Getting Started with the OpenSearch Python Client
# User guide of OpenSearch Python Client

## Setup

Expand All @@ -23,8 +23,9 @@ from opensearchpy import OpenSearch
If you prefer to add the client manually or just want to examine the source code, see [opensearch-py on GitHub](https://github.com/opensearch-project/opensearch-py).


## Sample code

## Example
In the example given below, we create a client, an index with non-default settings, insert a
document in the index, search for the document, delete the document and finally delete the index.
```python
from opensearchpy import OpenSearch

Expand Down Expand Up @@ -119,7 +120,39 @@ response = client.indices.delete(
print('\nDeleting index:')
print(response)
```
## Making API Calls

### Point in Time API calls
```python

# create a point in time on a index
index_name = "test-index"
response = client.create_point_in_time(index=index_name,
keep_alive="1m")

pit_id = response.get("pit_id")
print('\n Point in time ID:')
print(pit_id)

# To list all point in time which are plive in the cluster
response = client.list_all_point_in_time()
print('\n List of all Point in Time:')
print(response)

# delete point in time
body = {
"pit_id": [pit_id]
}

response = client.delete_point_in_time(body=body)
# To delete all point in time
# client.delete_point_in_time(body=None, all=True)

print('\n The deleted point in time:')
print(response)


```
## Using IAM credentials for authentication

Refer the AWS documentation regarding usage of IAM credentials to sign requests to OpenSearch APIs - [Signing HTTP requests to Amazon OpenSearch Service.](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/request-signing.html#request-signing-python)
Expand Down
3 changes: 0 additions & 3 deletions test_opensearchpy/test_client/test_point_in_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
#
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
Expand Down

0 comments on commit ac48aae

Please sign in to comment.