arvados-cli 0.1.20131212114626 → 0.1.20131212152126
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/arv +55 -20
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 622640ea69fde34097c84b1001d734c7d7d44e5f
|
4
|
+
data.tar.gz: 2aa286553fce18a21cf7d60854daf1937aa767bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b9d83c8aadf5d92cc88f56ad507bee5ad84967605fdfa092a5b401fcabf61b3a616da521c8b5380599d6429d7a8117d6a68a9592361d8f77e187c9a9e108972
|
7
|
+
data.tar.gz: f3218580cf5b0709d2f241d281bc03fcba5ea1302d06cc658300c05570d0159f0d4f5b1f355ff4394e2adb357a641466664d3e4328fc1dc832f62fb3b15e7c15
|
data/bin/arv
CHANGED
@@ -51,6 +51,7 @@ ARVADOS_API_HOST and ARVADOS_API_TOKEN need to be defined as environment variabl
|
|
51
51
|
end
|
52
52
|
|
53
53
|
begin
|
54
|
+
require 'curb'
|
54
55
|
require 'rubygems'
|
55
56
|
require 'google/api_client'
|
56
57
|
require 'json'
|
@@ -64,7 +65,7 @@ rescue LoadError
|
|
64
65
|
|
65
66
|
Please install all required gems:
|
66
67
|
|
67
|
-
gem install google-api-client json
|
68
|
+
gem install activesupport andand curb google-api-client json oj trollop
|
68
69
|
|
69
70
|
EOS
|
70
71
|
end
|
@@ -120,11 +121,11 @@ def to_boolean(s)
|
|
120
121
|
!!(s =~ /^(true|t|yes|y|1)$/i)
|
121
122
|
end
|
122
123
|
|
123
|
-
def help_methods(discovery_document,
|
124
|
-
banner = "\n
|
125
|
-
banner += "The #{
|
124
|
+
def help_methods(discovery_document, resource, method=nil)
|
125
|
+
banner = "\n"
|
126
|
+
banner += "The #{resource} resource type supports the following methods:"
|
126
127
|
banner += "\n\n"
|
127
|
-
discovery_document["resources"][
|
128
|
+
discovery_document["resources"][resource.pluralize]["methods"].
|
128
129
|
each do |k,v|
|
129
130
|
description = ''
|
130
131
|
description = ' ' + v["description"] if v.include?("description")
|
@@ -135,13 +136,13 @@ def help_methods(discovery_document, resource_arg, method=nil)
|
|
135
136
|
|
136
137
|
if not method.nil? and method != '--help' then
|
137
138
|
Trollop::die ("Unknown method #{method.inspect} " +
|
138
|
-
"for resource #{
|
139
|
+
"for resource #{resource.inspect}")
|
139
140
|
end
|
140
141
|
exit 255
|
141
142
|
end
|
142
143
|
|
143
|
-
def help_resources(discovery_document,
|
144
|
-
banner = "\n
|
144
|
+
def help_resources(discovery_document, resource)
|
145
|
+
banner = "\n"
|
145
146
|
banner += "This Arvados instance supports the following resource types:"
|
146
147
|
banner += "\n\n"
|
147
148
|
discovery_document["resources"].each do |k,v|
|
@@ -155,8 +156,8 @@ def help_resources(discovery_document, resource_arg)
|
|
155
156
|
banner += "\n"
|
156
157
|
STDERR.puts banner
|
157
158
|
|
158
|
-
if not
|
159
|
-
Trollop::die "Unknown resource type #{
|
159
|
+
if not resource.nil? and resource != '--help' then
|
160
|
+
Trollop::die "Unknown resource type #{resource.inspect}"
|
160
161
|
end
|
161
162
|
exit 255
|
162
163
|
end
|
@@ -190,10 +191,9 @@ def parse_arguments(discovery_document)
|
|
190
191
|
help_methods(discovery_document, resource, method)
|
191
192
|
end
|
192
193
|
|
193
|
-
discovered_params =
|
194
|
-
|
195
|
-
|
196
|
-
["parameters"])
|
194
|
+
discovered_params = discovery_document\
|
195
|
+
["resources"][resource.pluralize]\
|
196
|
+
["methods"][method]["parameters"]
|
197
197
|
method_opts = Trollop::options do
|
198
198
|
discovered_params.each do |k,v|
|
199
199
|
opts = Hash.new()
|
@@ -247,12 +247,43 @@ if resource_body
|
|
247
247
|
else
|
248
248
|
request_body = {}
|
249
249
|
end
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
250
|
+
|
251
|
+
case api_method
|
252
|
+
when
|
253
|
+
'arvados.users.event_stream',
|
254
|
+
'arvados.jobs.log_stream',
|
255
|
+
'arvados.jobs.log_tail_follow'
|
256
|
+
|
257
|
+
# Special case for methods that respond with data streams rather
|
258
|
+
# than JSON (TODO: use the discovery document instead of a static
|
259
|
+
# list of methods)
|
260
|
+
uri_s = eval(api_method).generate_uri(request_parameters)
|
261
|
+
Curl::Easy.perform(uri_s) do |curl|
|
262
|
+
curl.headers['Accept'] = 'text/plain'
|
263
|
+
curl.headers['Authorization'] = "OAuth2 #{ENV['ARVADOS_API_TOKEN']}"
|
264
|
+
if ENV['ARVADOS_API_HOST_INSECURE']
|
265
|
+
curl.ssl_verify_peer = false
|
266
|
+
curl.ssl_verify_host = false
|
267
|
+
end
|
268
|
+
if global_opts[:verbose]
|
269
|
+
curl.on_header { |data| $stderr.write data }
|
270
|
+
end
|
271
|
+
curl.on_body { |data| $stdout.write data }
|
272
|
+
end
|
273
|
+
exit 0
|
274
|
+
else
|
275
|
+
request_body[:api_token] = ENV['ARVADOS_API_TOKEN']
|
276
|
+
result = client.execute(:api_method => eval(api_method),
|
277
|
+
:parameters => request_parameters,
|
278
|
+
:body => request_body,
|
279
|
+
:authenticated => false)
|
280
|
+
end
|
281
|
+
|
282
|
+
begin
|
283
|
+
results = JSON.parse result.body
|
284
|
+
rescue JSON::ParserError => e
|
285
|
+
abort "Failed to parse server response:\n" + e.to_s
|
286
|
+
end
|
256
287
|
|
257
288
|
if results["errors"] then
|
258
289
|
abort "Error: #{results["errors"][0]}"
|
@@ -264,6 +295,10 @@ elsif global_opts[:json] then
|
|
264
295
|
puts Oj.dump(results)
|
265
296
|
elsif results["items"] and results["kind"].match /list$/i
|
266
297
|
results['items'].each do |i| puts i['uuid'] end
|
298
|
+
elsif results['uuid'].nil?
|
299
|
+
abort("Response did not include a uuid:\n" +
|
300
|
+
Oj.dump(results, :indent => 1) +
|
301
|
+
"\n")
|
267
302
|
else
|
268
303
|
puts results['uuid']
|
269
304
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arvados-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20131212152126
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arvados Authors
|
@@ -94,7 +94,21 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.0.3
|
97
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: curb
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.8'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.8'
|
111
|
+
description: This is the Arvados SDK CLI gem, git revision d9cd657b733d578ac0d2167dd75967aa4f22e0ac
|
98
112
|
email: gem-dev@clinicalfuture.com
|
99
113
|
executables:
|
100
114
|
- arv
|