onering-client 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/onering CHANGED
@@ -6,30 +6,60 @@
6
6
  # provision [options] [key:value .. ] [pxe profile | ]
7
7
 
8
8
 
9
- require 'rubygems'
10
9
  require 'json'
10
+ require 'rubygems'
11
11
  require 'subcommander'
12
12
  require 'onering'
13
+ require 'yaml'
14
+
15
+ include Subcommander
16
+
13
17
 
14
- Onering::API::Device.connect
18
+ def print_format(data)
19
+ puts YAML.dump(data)
20
+ end
21
+
22
+ subcommander.version = Gem.loaded_specs['onering-client'].version.to_s
23
+ subcommander.desc = Gem.loaded_specs['onering-client'].description
15
24
 
16
- action = ARGV.shift
25
+ #subcommander.opt :server, '-s', '--server', 'Specify the Onering server URL'
17
26
 
18
- case (action && action.to_sym)
19
- when :ls, :list
20
- Onering::API::Device.list(ARGV.shift, (ARGV.empty? ? {} : {
21
- :filter => ARGV
22
- }))
23
- when :s, :search
24
- Onering::API::Device.find(ARGV)
27
+ subcommand :devices, "Operations related to Onering's assets database" do |devices|
28
+ api = Onering::API::Devices
29
+ api.connect
25
30
 
26
- when :save
27
- data = (STDIN.tty? && ARGV.length > 1 ? File.read(File.expand_path(ARGV.last)) : STDIN.read)
31
+ # GET
32
+ devices.subcommand :get, "Get a single node by ID" do |sc|
33
+ sc.usage = "onering devices get ID"
28
34
 
29
- if data
30
- data = JSON.load(data)
31
- Onering::API::Device.save(ARGV.first, data)
35
+ sc.exec do
36
+ print_format api.get(sc[:args].first)
37
+ end
38
+ end
39
+
40
+ # LIST
41
+ devices.subcommand :list, "List field values" do |sc|
42
+ sc.usage = "onering devices list [-f FILTER] FIELD"
43
+ sc.opt :filter, '-f', '--filter FILTER', "A urlquery filter string"
44
+
45
+ sc.exec do
46
+ field = sc[:args].first
47
+ filter = sc[:filter]
48
+
49
+ print_format api.list(field, filter)
50
+ end
51
+ end
52
+
53
+ # FIND
54
+ devices.subcommand :find, "Finds all nodes that match a urlquery filter string" do |sc|
55
+ sc.arity = 1
56
+ sc.usage = "onering devices find FILTER"
57
+
58
+ sc.exec do
59
+ print_format api.find(sc[:args].first)
60
+ end
32
61
  end
33
- else
34
- STDERR.puts "Usage: onering [subcommand] [options]"
35
62
  end
63
+
64
+
65
+ subcommander.go!
@@ -7,6 +7,10 @@ module Onering
7
7
  super(host)
8
8
  end
9
9
 
10
+ def get(id)
11
+ request("devices/#{id}")
12
+ end
13
+
10
14
  def list(field, options={
11
15
  :unique => true,
12
16
  :sort => true,
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onering-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gary Hetzel
@@ -20,8 +20,8 @@ dependencies: []
20
20
 
21
21
  description: A Ruby wrapper for Onering
22
22
  email: ghetzel@outbrain.com
23
- executables: []
24
-
23
+ executables:
24
+ - onering
25
25
  extensions: []
26
26
 
27
27
  extra_rdoc_files: []
@@ -66,4 +66,3 @@ specification_version: 3
66
66
  summary: Onering client API
67
67
  test_files: []
68
68
 
69
- has_rdoc: