Class: Elastomer::Client::Repository
- Inherits:
-
Object
- Object
- Elastomer::Client::Repository
- Defined in:
- lib/elastomer/client/repository.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#create(body, params = {}) ⇒ Object
Create the repository.
-
#defaults ⇒ Object
Internal: Returns a Hash containing default parameters.
-
#delete(params = {}) ⇒ Object
Delete the repository.
-
#exists?(params = {}) ⇒ Boolean
(also: #exist?)
Check for the existence of the repository.
-
#get(params = {}) ⇒ Object
Get repository type and settings.
-
#initialize(client, name = nil) ⇒ Repository
constructor
Create a new index client for making API requests that pertain to the health and management individual indexes.
-
#snapshot(snapshot = nil) ⇒ Object
(also: #snapshots)
Provides access to snapshot API commands.
-
#status(params = {}) ⇒ Object
Get status information on snapshots in progress.
-
#update(body, params = {}) ⇒ Object
Update the repository.
-
#update_params(params, overrides = nil) ⇒ Object
Internal: Add default parameters to the ‘params` Hash and then apply `overrides` to the params if any are given.
Constructor Details
#initialize(client, name = nil) ⇒ Repository
Create a new index client for making API requests that pertain to the health and management individual indexes.
client - Elastomer::Client used for HTTP requests to the server name - The name of the index as a String or an Array of names
15 16 17 18 |
# File 'lib/elastomer/client/repository.rb', line 15 def initialize(client, name = nil) @client = client @name = @client.assert_param_presence(name, 'repository name') unless name.nil? end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
20 21 22 |
# File 'lib/elastomer/client/repository.rb', line 20 def client @client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/elastomer/client/repository.rb', line 20 def name @name end |
Instance Method Details
#create(body, params = {}) ⇒ Object
Create the repository. See www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html#_repositories
body - The repository type and settings as a Hash or a JSON encoded String params - Parameters Hash
Returns the response body as a Hash
47 48 49 50 |
# File 'lib/elastomer/client/repository.rb', line 47 def create(body, params = {}) response = client.put '/_snapshot/{repository}', update_params(params, :body => body, :action => 'repository.create') response.body end |
#defaults ⇒ Object
Internal: Returns a Hash containing default parameters.
122 123 124 |
# File 'lib/elastomer/client/repository.rb', line 122 def defaults { :repository => name } end |
#delete(params = {}) ⇒ Object
Delete the repository. See www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html#_repositories
params - Parameters Hash
Returns the response body as a Hash
92 93 94 95 |
# File 'lib/elastomer/client/repository.rb', line 92 def delete(params = {}) response = client.delete '/_snapshot/{repository}', update_params(params, :action => 'repository.delete') response.body end |
#exists?(params = {}) ⇒ Boolean Also known as: exist?
Check for the existence of the repository. See www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html#_repositories
params - Parameters Hash
Returns true if the repository exists
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/elastomer/client/repository.rb', line 28 def exists?(params = {}) response = client.get '/_snapshot{/repository}', update_params(params, :action => 'repository.exists') response.success? rescue Elastomer::Client::Error => exception if exception. =~ /RepositoryMissingException/ false else raise exception end end |
#get(params = {}) ⇒ Object
Get repository type and settings. See www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html#_repositories
params - Parameters Hash
Returns the response body as a Hash
58 59 60 61 |
# File 'lib/elastomer/client/repository.rb', line 58 def get(params = {}) response = client.get '/_snapshot{/repository}', update_params(params, :action => 'repository.get') response.body end |
#snapshot(snapshot = nil) ⇒ Object Also known as: snapshots
Provides access to snapshot API commands. These commands will be scoped to this repository and the given snapshot name.
snapshot - The snapshot name as a String, or nil for all snapshots.
Returns a Snapshot instance.
103 104 105 |
# File 'lib/elastomer/client/repository.rb', line 103 def snapshot(snapshot = nil) client.snapshot(name, snapshot) end |
#status(params = {}) ⇒ Object
Get status information on snapshots in progress. See www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html#_repositories
params - Parameters Hash
Returns the response body as a Hash
69 70 71 72 |
# File 'lib/elastomer/client/repository.rb', line 69 def status(params = {}) response = client.get '/_snapshot{/repository}/_status', update_params(params, :action => 'repository.status') response.body end |
#update(body, params = {}) ⇒ Object
Update the repository. See www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html#_repositories
body - The repository type and settings as a Hash or a JSON encoded String params - Parameters Hash
Returns the response body as a Hash
81 82 83 84 |
# File 'lib/elastomer/client/repository.rb', line 81 def update(body, params = {}) response = client.put '/_snapshot/{repository}', update_params(params, :body => body, :action => 'repository.update') response.body end |
#update_params(params, overrides = nil) ⇒ Object
Internal: Add default parameters to the ‘params` Hash and then apply `overrides` to the params if any are given.
params - Parameters Hash overrides - Optional parameter overrides as a Hash
Returns a new params Hash.
115 116 117 118 119 |
# File 'lib/elastomer/client/repository.rb', line 115 def update_params(params, overrides = nil) h = defaults.update params h.update overrides unless overrides.nil? h end |