[ARVADOS] updated: 20f1e7eaf6053d52210002720e2b0a0c26e5169e
git at public.curoverse.com
git at public.curoverse.com
Wed Jan 8 17:12:55 EST 2014
Summary of changes:
sdk/cli/bin/arv-tag | 83 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 57 insertions(+), 26 deletions(-)
via 20f1e7eaf6053d52210002720e2b0a0c26e5169e (commit)
from 79ee8eac7e5731b27375cc7f06cac109f26287ea (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 20f1e7eaf6053d52210002720e2b0a0c26e5169e
Author: Tim Pierce <twp at curoverse.com>
Date: Wed Jan 8 17:12:46 2014 -0500
Bug fixes (API requires request to be delivered in request_body)
diff --git a/sdk/cli/bin/arv-tag b/sdk/cli/bin/arv-tag
index 9b3339b..67def84 100755
--- a/sdk/cli/bin/arv-tag
+++ b/sdk/cli/bin/arv-tag
@@ -13,27 +13,43 @@ def usage
end
def tag_add(tag, obj_uuid)
- request_body = {}
- request_body[:api_token] = ENV['ARVADOS_API_TOKEN']
-
- return $client.execute(:api_method => $arvados.links.create,
- :parameters => {
- :name => tag,
- :link_class => :tag,
- :head_uuid => obj_uuid,
- },
- :body => request_body,
- :authenticated => false)
+ request_body = {
+ :api_token => ENV['ARVADOS_API_TOKEN'],
+ :link => {
+ :name => tag,
+ :link_class => :tag,
+ :head_uuid => obj_uuid,
+ }
+ }
+
+ result = $client.execute(:api_method => $arvados.links.create,
+ :body => request_body,
+ :authenticated => false)
+
+ begin
+ results = JSON.parse result.body
+ rescue JSON::ParserError => e
+ $stderr.puts "Failed to parse server response:\n" + e.to_s
+ return nil
+ end
+
+ if results["errors"] then
+ $stderr.puts "Error: #{results["errors"][0]}"
+ return nil
+ end
+
+ return results
end
def tag_remove(tag, obj_uuid=nil)
- request_body = {}
- request_body[:api_token] = ENV['ARVADOS_API_TOKEN']
-
- params = { :name => tag, :link_class => :tag }
- if obj_uuid then
- params[:head_uuid] = obj_uuid
- end
+ request_body = {
+ :api_token => ENV['ARVADOS_API_TOKEN'],
+ :link => {
+ :name => tag,
+ :link_class => :tag,
+ :head_uuid => obj_uuid,
+ }
+ }
return $client.execute(:api_method => $arvados.links.destroy,
:parameters => params,
@@ -102,6 +118,18 @@ class Google::APIClient
end
end
+global_opts = Trollop::options do
+ banner "arvados cli client"
+ opt :dry_run, "Don't actually do anything", :short => "-n"
+ opt :verbose, "Print some things on stderr", :short => "-v"
+ opt :uuid, "Return the UUIDs of the objects in the response, one per line (default)", :short => nil
+ opt :json, "Return the entire response received from the API server, as a JSON object", :short => "-j"
+ opt :human, "Return the response received from the API server, as a JSON object with whitespace added for human consumption", :short => "-h"
+ opt :pretty, "Synonym of --human", :short => nil
+ opt :yaml, "Return the response received from the API server, in YAML format", :short => "-y"
+ stop_on ['add', 'remove']
+end
+
p = Trollop::Parser.new do
opt(:all,
"Remove this tag from all objects under your ownership. Only valid with `tag remove'.",
@@ -158,14 +186,17 @@ elsif global_opts[:yaml] then
puts results.to_yaml
elsif global_opts[:json] then
puts Oj.dump(results)
-elsif results["items"] and results["kind"].match /list$/i
- results['items'].each do |i| puts i['uuid'] end
-elsif results['uuid'].nil?
- abort("Response did not include a uuid:\n" +
- Oj.dump(results, :indent => 1) +
- "\n")
else
- results.each do |result|
- puts result['uuid']
+ results.each do |r|
+ next if r == nil
+ if r["items"] and r["kind"].match /list$/i
+ r['items'].each do |i| puts i['uuid'] end
+ elsif r['uuid'].nil?
+ abort("Response did not include a uuid:\n" +
+ Oj.dump(r, :indent => 1) +
+ "\n")
+ else
+ puts r['uuid']
+ end
end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list