Skip to content

Commit

Permalink
fixed integration test fail
Browse files Browse the repository at this point in the history
Signed-off-by: Raman Saparkhan <[email protected]>
  • Loading branch information
roma2023 committed Sep 5, 2023
1 parent dd29ac4 commit 722a173
Showing 1 changed file with 8 additions and 35 deletions.
43 changes: 8 additions & 35 deletions guides/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,18 @@ In this guide, we will look at some snapshot actions that allow you to manage an


## Setup
Let's create a client instance, and an index named `test-index`:
Let's create a client instance, and an index named `movies`:
```python
from opensearchpy import OpenSearch

# connect to OpenSearch

host = 'localhost'
port = 9200
auth = ('admin', 'admin') # For testing only. Don't store credentials in code.

client = OpenSearch(
hosts = [{'host': host, 'port': port}],
http_auth = auth,
use_ssl = True,
verify_certs = False,
ssl_show_warn = False
)

info = client.info()
print(f"Welcome to {info['version']['distribution']} {info['version']['number']}!")

# create an index

index_name = 'test-index'

index_body = {
'settings': {
'index': {
'number_of_shards': 4
}
}
}

response = client.indices.create(
index_name,
body=index_body
hosts=['https://admin:admin@localhost:9200'],
use_ssl=True,
verify_certs=False
)

print(client.info()) # Check server info and make sure the client is connected
client.indices.create(index='movies')
```
## API Actions
### Create Snapshot Repository
Expand All @@ -61,7 +34,7 @@ client.snapshot.create_repository(repository='my_repository', body=repo_body)
To create a snapshot of an index, you can use the `create` method from the `snapshot` API. The following example creates a snapshot named `my_snapshot` for the movies index:

```python
client.snapshot.create(repository='my_repository', snapshot='my_snapshot', body={"indices": "test-index"})
client.snapshot.create(repository='my_repository', snapshot='my_snapshot', body={"indices": "movies"})
```

### Verify Snapshot Repository
Expand Down Expand Up @@ -127,9 +100,9 @@ response = client.snapshot.repository_analyze(repository='my_repository')

## Cleanup

Finally, let's delete the `test-index` index and clean up all the snapshots and the repository:
Finally, let's delete the `movies` index and clean up all the snapshots and the repository:
```python
client.indices.delete(index='test-index')
client.indices.delete(index='movies')
client.snapshot.delete(repository='my_repository', snapshot='my_snapshot')
client.snapshot.delete_repository(repository='my_repository')
```

0 comments on commit 722a173

Please sign in to comment.