Class: Elastomer::CLI::Snapshot
- Defined in:
- lib/elastomer/cli/snapshot.rb
Instance Method Summary collapse
- #create(repository, name) ⇒ Object
- #delete(repository, name) ⇒ Object
- #get(repository, name = nil) ⇒ Object
- #list(repository) ⇒ Object
- #restore(repository, name) ⇒ Object
- #status(repository = nil, name = nil) ⇒ Object
Instance Method Details
#create(repository, name) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/elastomer/cli/snapshot.rb', line 13 def create(repository, name) wait = !!.delete(:wait_for_completion) puts "Waiting for snapshot completion..." if wait response = client.snapshot(repository, name).create(, :wait_for_completion => wait, :pretty => true) puts response end |
#delete(repository, name) ⇒ Object
80 81 82 83 |
# File 'lib/elastomer/cli/snapshot.rb', line 80 def delete(repository, name) response = client.snapshot(repository, name).delete puts "Successfully deleted #{name} in #{repository}" end |
#get(repository, name = nil) ⇒ Object
21 22 23 24 |
# File 'lib/elastomer/cli/snapshot.rb', line 21 def get(repository, name=nil) response = client.snapshot(repository, name).get(:pretty => true) puts response end |
#list(repository) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/elastomer/cli/snapshot.rb', line 27 def list(repository) response = client.snapshot(repository).get(:pretty => true) puts Terminal::Table.new( :headings => ['NAME', 'STATE', 'DURATION', 'START TIME', 'INDICES'], :rows => response["snapshots"].collect do |snapshot| [ snapshot["snapshot"], snapshot["state"], "%2.3fs" % (snapshot["duration_in_millis"] / 1000.0), snapshot["start_time"], snapshot["indices"].count, ] end ) end |
#restore(repository, name) ⇒ Object
73 74 75 76 77 |
# File 'lib/elastomer/cli/snapshot.rb', line 73 def restore(repository, name) wait = .delete(:wait_for_completion) response = client.snapshot(repository, name).restore(, :wait_for_completion => wait, :pretty => true) puts response end |
#status(repository = nil, name = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/elastomer/cli/snapshot.rb', line 44 def status(repository=nil, name=nil) response = client.snapshot(repository, name).status(:pretty => true) response["snapshots"].each do |snapshot| puts Terminal::Table.new( :headings => ["SNAPSHOT STATUS", snapshot["snapshot"]], :rows => [ ["Repository", snapshot["repository"]], ["State", snapshot["state"]], ["Start Time", Time.at(snapshot["stats"]["start_time_in_millis"].to_i / 1000)], ["Duration", "%2.3fs" % (snapshot["stats"]["time_in_millis"] / 1000.0)], ["Processed Files", processed_files(snapshot)], ["Processed Bytes", processed_bytes(snapshot)], ["Shard Status", shard_status(snapshot)], ["Shards Failed", snapshot["shards_stats"]["failed"]], ["Total Shards", snapshot["shards_stats"]["total"]], ["Total Indices", snapshot["indices"].size], ] ) end end |