Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
opensearch-py version 2.2.0
python version 3.9.2
Debian GNU/Linux 11 (bullseye)
Describe the issue:
I’m struggling to understand how to use the Snapshot client for opensearch-py
I’m mostly likely misunderstanding the documentation, but I got the impression that you first initialize the OpenSearch client and pass that to the Snapshot client like below, but I am getting an error [ERROR] AttributeError: ‘Client’ object has no attribute ‘transport’. It sounds like I’m not using the Snapshot class correctly, but I am struggling to find an example.
Am I using this API incorrectly? Does anyone have an example of how the Snapshot client should be used?
from opensearchpy import OpenSearch, RequestsHttpConnection
from opensearchpy.client.snapshot import SnapshotClient
host = '<host link>'
port = 443
auth = ("username", "password")
# create an opensearch client
os_client = OpenSearch(
hosts = [{'host': host, 'port': port}],
http_auth = auth,
use_ssl = True,
verify_certs = True,
connection_class = RequestsHttpConnection)
snapshot_client = SnapshotClient(os_client)
snapshot_client.SnapshotClient.create_repository(
repository='opensearch_backup',
body={
'type': 's3',
'settings': {
'bucket': '<bucket-name>',
'region': '<region>',
'role_arn': '<arn>'
}
}
)