estool 0.0.9 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f21a2b92f2c00c0b920935eeeea4b8662ae97d7e
4
- data.tar.gz: e47794d609fa6a0135e812742290c04efd2a7e2b
3
+ metadata.gz: 37793a5579184fc43104c1a9d5ceda2d311a0902
4
+ data.tar.gz: b47cd4d8b68c1cda023f4604f57c77f9cd5ea9a3
5
5
  SHA512:
6
- metadata.gz: d2e4445c5a410a46a3d03e185acf871f4ee0ca9efef5e990197a86db57e0b589da81d4258f229a01be4ed7083cef5b11eff99253849bf7c0007d3e8776e19e5b
7
- data.tar.gz: f3d6f74694d1faa34d7da339b0b78ca04bb484aafd5937a29dc9fe915e1bb1deefb3f933151dc1d62019b81780a0a379d9b802f8c8f34c48ba650a9c3eb9eb35
6
+ metadata.gz: 82205fdcaaa2e2d64d043efa6cc9c2954627b4523c473944654852edeceb6dba8af8545e04c755a79edec988823b329982ab3b59051806aaf44c3add07236ff1
7
+ data.tar.gz: c7be4fe976f8cd0464beb9fb97db843d81df2b42b77f1fb72c8f696c92816401be228f2bc42efa9c5d897d8eb1782ef9768b27ab97b706fd1486a6e64f7de3ca
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'estool/cat'
3
+ require 'estool/index'
3
4
  require 'thor'
4
5
 
5
6
  module Estool
6
7
  class Cli < Thor
7
- register(Estool::Cat, 'cat', 'cat [SUBCOMMAND] [OPTIONS]', 'Utilize Elasticsearch API', )
8
+ register(Estool::Cat, 'cat', 'cat [SUBCOMMAND] [OPTIONS]', 'Display health and status information about the cluster', )
9
+ register(Estool::Index, 'index', 'index [SUBCOMMAND] [OPTIONS]', 'Manage cluster indices', )
8
10
  end
9
11
  end
@@ -0,0 +1,50 @@
1
+ require 'active_support'
2
+ require 'elasticsearch-api'
3
+ require 'estool/connections'
4
+
5
+ module Estool::Actions
6
+ class Index
7
+
8
+ def initialize(command, options)
9
+ @cmd = command
10
+ @data = options.except(:host, :port)
11
+ @server = options.slice(:host, :port)
12
+ end
13
+
14
+ def format_options(data)
15
+ params = {}
16
+ data.each do |k, v|
17
+ case k
18
+ when 'name'
19
+ params.merge!(index: v)
20
+ when 'update'
21
+ params.merge!(update_all_types: v)
22
+ when 'wait'
23
+ params.merge!(wait_for_active_shards: v)
24
+ else
25
+ params.merge!("#{k}": v)
26
+ end
27
+ end
28
+ return params
29
+ end
30
+
31
+ def index(action, options, server)
32
+ client = Estool::Connections.start_conn(server[:host], server[:port])
33
+ Estool::Connections.test_conn(client)
34
+ begin
35
+ puts client.indices.send(action, options)
36
+ rescue ArgumentError => args
37
+ puts "
38
+ #{args}
39
+ Usage: 'estool index help #{action}' for more information
40
+ "
41
+ exit 1
42
+ end
43
+ end
44
+
45
+ def run
46
+ params = format_options(@data)
47
+ index(@cmd, params, @server)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,37 @@
1
+ require 'thor'
2
+ require 'estool/actions/index'
3
+
4
+ module Estool
5
+ class Index < Thor
6
+ class_option 'host', :type => :string,
7
+ :banner => 'Elasticsearch host to connect to',
8
+ :default => 'localhost',
9
+ :aliases => '-H'
10
+ class_option 'port', :type => :string,
11
+ :banner => 'Port to use when connecting to Elasticsearch',
12
+ :default => '9200',
13
+ :aliases => '-p'
14
+ class_option 'name', :type => :string,
15
+ :banner => 'Index name',
16
+ :aliases => '-n',
17
+ :required => true
18
+
19
+ desc 'create [OPTIONS]', 'Create new index'
20
+ method_option 'update', :type => :boolean,
21
+ :banner => 'Update the mapping for all fields with the same name across all types.',
22
+ :default => false,
23
+ :aliases => '-u'
24
+ method_option 'wait', :type => :numeric,
25
+ :banner => 'Wait until specified number of shards is active.',
26
+ :default => 0,
27
+ :aliases => '-w'
28
+ def create
29
+ Estool::Actions::Index.new(:create, options).run
30
+ end
31
+
32
+ desc 'delete [OPTIONS]', 'Delete index'
33
+ def delete
34
+ Estool::Actions::Index.new(:delete, options).run
35
+ end
36
+ end
37
+ end
@@ -1,4 +1,4 @@
1
1
  module Estool
2
2
  ESTOOL_ROOT = File.expand_path("../..", __FILE__)
3
- VERSION = "0.0.9"
4
- end
3
+ VERSION = "0.1.1"
4
+ end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: estool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Hollinger III
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-04 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: elasticsearch
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.0
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: elasticsearch-api
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -57,8 +77,10 @@ files:
57
77
  - bin/estool
58
78
  - lib/estool.rb
59
79
  - lib/estool/actions/cat.rb
80
+ - lib/estool/actions/index.rb
60
81
  - lib/estool/cat.rb
61
82
  - lib/estool/connections.rb
83
+ - lib/estool/index.rb
62
84
  - lib/estool/version.rb
63
85
  homepage: https://github.com/dhollinger/estool
64
86
  licenses:
@@ -83,5 +105,6 @@ rubyforge_project:
83
105
  rubygems_version: 2.4.5.1
84
106
  signing_key:
85
107
  specification_version: 4
86
- summary: Command Line tool for interacting with Elasticsearch
108
+ summary: Command Line tool for interacting with Elasticsearch. Still in Development,
109
+ expect bugs and fast releases until 1.0.0
87
110
  test_files: []