Added the snapshot apis
This commit is contained in:
@@ -7,6 +7,7 @@ from .indices import IndicesClient
|
||||
from .cluster import ClusterClient
|
||||
from .cat import CatClient
|
||||
from .nodes import NodesClient
|
||||
from .snapshot import SnapshotClient
|
||||
from .utils import query_params, _make_path
|
||||
|
||||
logger = logging.getLogger('elasticsearch')
|
||||
@@ -82,6 +83,7 @@ class Elasticsearch(object):
|
||||
self.cluster = ClusterClient(weakref.proxy(self))
|
||||
self.cat = CatClient(weakref.proxy(self))
|
||||
self.nodes = NodesClient(weakref.proxy(self))
|
||||
self.snapshot = SnapshotClient(weakref.proxy(self))
|
||||
|
||||
def __repr__(self):
|
||||
try:
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
from .utils import NamespacedClient, query_params, _make_path
|
||||
|
||||
class SnapshotClient(NamespacedClient):
|
||||
@query_params('master_timeout', 'wait_for_completion')
|
||||
def create(self, repository, snapshot, body=None, params=None):
|
||||
"""
|
||||
Create a snapshot in repository
|
||||
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
|
||||
:arg repository: A repository name
|
||||
:arg snapshot: A snapshot name
|
||||
:arg body: The snapshot definition
|
||||
:arg master_timeout: Explicit operation timeout for connection to master
|
||||
node
|
||||
:arg wait_for_completion: Should this request wait until the operation
|
||||
has completed before returning, default False
|
||||
"""
|
||||
_, data = self.transport.perform_request('PUT', _make_path('_snapshot',
|
||||
repository, snapshot), params=params, body=body)
|
||||
return data
|
||||
|
||||
@query_params('master_timeout')
|
||||
def delete(self, repository, snapshot, params=None):
|
||||
"""
|
||||
Deletes a snapshot from a repository.
|
||||
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
|
||||
:arg repository: A repository name
|
||||
:arg snapshot: A snapshot name
|
||||
:arg master_timeout: Explicit operation timeout for connection to master
|
||||
node
|
||||
"""
|
||||
_, data = self.transport.perform_request('DELETE',
|
||||
_make_path('_snapshot', repository, snapshot), params=params)
|
||||
return data
|
||||
|
||||
@query_params('master_timeout')
|
||||
def get(self, repository, snapshot, params=None):
|
||||
"""
|
||||
Retrieve information about a snapshot.
|
||||
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
|
||||
:arg repository: A comma-separated list of repository names
|
||||
:arg snapshot: A comma-separated list of snapshot names
|
||||
:arg master_timeout: Explicit operation timeout for connection to master
|
||||
node
|
||||
"""
|
||||
_, data = self.transport.perform_request('GET', _make_path('_snapshot',
|
||||
repository, snapshot), params=params)
|
||||
return data
|
||||
|
||||
@query_params('master_timeout', 'timeout')
|
||||
def delete_repository(self, repository, params=None):
|
||||
"""
|
||||
Removes a shared file system repository.
|
||||
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
|
||||
:arg repository: A comma-separated list of repository names
|
||||
:arg master_timeout: Explicit operation timeout for connection to master
|
||||
node
|
||||
:arg timeout: Explicit operation timeout
|
||||
"""
|
||||
_, data = self.transport.perform_request('DELETE',
|
||||
_make_path('_snapshot', repository), params=params)
|
||||
return data
|
||||
|
||||
@query_params('master_timeout')
|
||||
def get_repository(self, repository=None, params=None):
|
||||
"""
|
||||
Return information about registered repositories.
|
||||
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
|
||||
:arg repository: A comma-separated list of repository names
|
||||
:arg master_timeout: Explicit operation timeout for connection to master
|
||||
node
|
||||
"""
|
||||
_, data = self.transport.perform_request('GET', _make_path('_snapshot',
|
||||
repository), params=params)
|
||||
return data
|
||||
|
||||
@query_params('master_timeout', 'timeout')
|
||||
def create_repository(self, repository, body, params=None):
|
||||
"""
|
||||
Registers a shared file system repository.
|
||||
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
|
||||
:arg repository: A repository name
|
||||
:arg body: The repository definition
|
||||
:arg master_timeout: Explicit operation timeout for connection to master
|
||||
node
|
||||
:arg timeout: Explicit operation timeout
|
||||
"""
|
||||
_, data = self.transport.perform_request('PUT', _make_path('_snapshot',
|
||||
repository), params=params, body=body)
|
||||
return data
|
||||
|
||||
@query_params('master_timeout', 'wait_for_completion')
|
||||
def restore(self, repository, snapshot, body=None, params=None):
|
||||
"""
|
||||
Restore a snapshot.
|
||||
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
|
||||
:arg repository: A repository name
|
||||
:arg snapshot: A snapshot name
|
||||
:arg body: Details of what to restore
|
||||
:arg master_timeout: Explicit operation timeout for connection to master
|
||||
node
|
||||
:arg wait_for_completion: Should this request wait until the operation
|
||||
has completed before returning, default False
|
||||
"""
|
||||
_, data = self.transport.perform_request('POST', _make_path('_snapshot',
|
||||
repository, snapshot, '_restore'), params=params, body=body)
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user