onering-client 0.0.17 → 0.0.18
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 +28 -0
- metadata +7 -7
data/bin/onering
CHANGED
@@ -32,9 +32,14 @@ def print_format(data, format=nil)
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def global_options(sc)
|
36
|
+
sc.send(:opt, :verbose, '-v', '--verbose', "Print out what the command is doing")
|
37
|
+
end
|
38
|
+
|
35
39
|
subcommander.version = ::Gem.loaded_specs['onering-client'].version.to_s
|
36
40
|
subcommander.desc = ::Gem.loaded_specs['onering-client'].description
|
37
41
|
|
42
|
+
|
38
43
|
subcommand :devices, "Operations related to Onering's assets database" do |devices|
|
39
44
|
api = Onering::API::Devices
|
40
45
|
api.connect({
|
@@ -202,5 +207,28 @@ subcommand :users, "Manage Onering users" do |users|
|
|
202
207
|
end
|
203
208
|
end
|
204
209
|
|
210
|
+
subcommand :call, "Call generic Onering API endpoints" do |call|
|
211
|
+
api = Onering::API::Base
|
212
|
+
api.connect({
|
213
|
+
:host => ENV['ONERING_URL'],
|
214
|
+
:pemfile => ENV['ONERING_PEM']
|
215
|
+
})
|
216
|
+
|
217
|
+
call.usage = "onering call path/to/endpoint"
|
218
|
+
call.arity = 1
|
219
|
+
call.opt :as_txt, '-t', '--as-text', "Return the results as text"
|
220
|
+
call.opt :method, '-m', '--method', "The HTTP method to use for the call (default: GET)"
|
221
|
+
call.opt :opts, '-o', '--option KEY:VALUE', Array, "A comma-separated list of key:value querystrings to pass with the request"
|
222
|
+
|
223
|
+
call.exec do
|
224
|
+
rv = api.request(call[:args].first.to_sym, {
|
225
|
+
:method => (call[:method] || :get),
|
226
|
+
:data => (STDIN.tty? ? nil : ::JSON.load(STDIN.read)),
|
227
|
+
:fields => (Hash[call[:opts].collect{|i| i.split(':',2) }] rescue {})
|
228
|
+
})
|
229
|
+
|
230
|
+
print_format(rv, (call[:as_txt] ? :text : nil)) unless rv.nil? or rv.to_s.strip.chomp.empty?
|
231
|
+
end
|
232
|
+
end
|
205
233
|
|
206
234
|
subcommander.go!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onering-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-01-29 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: subcommander
|
16
|
-
requirement: &
|
16
|
+
requirement: &13409720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13409720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: deep_merge
|
27
|
-
requirement: &
|
27
|
+
requirement: &13409300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13409300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: addressable
|
38
|
-
requirement: &
|
38
|
+
requirement: &13408840 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *13408840
|
47
47
|
description: A Ruby wrapper for Onering
|
48
48
|
email: ghetzel@outbrain.com
|
49
49
|
executables:
|