aspera-cli 4.9.0 → 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/BUGS.md +20 -0
- data/CHANGELOG.md +509 -0
- data/CONTRIBUTING.md +118 -0
- data/README.md +1241 -916
- data/bin/ascli +4 -4
- data/bin/asession +11 -11
- data/docs/test_env.conf +32 -21
- data/examples/aoc.rb +4 -4
- data/examples/dascli +16 -9
- data/examples/faspex4.rb +8 -8
- data/examples/node.rb +12 -12
- data/examples/server.rb +10 -10
- data/lib/aspera/aoc.rb +273 -266
- data/lib/aspera/ascmd.rb +56 -54
- data/lib/aspera/ats_api.rb +4 -4
- data/lib/aspera/cli/basic_auth_plugin.rb +15 -12
- data/lib/aspera/cli/extended_value.rb +5 -5
- data/lib/aspera/cli/formater.rb +64 -64
- data/lib/aspera/cli/info.rb +2 -2
- data/lib/aspera/cli/listener/line_dump.rb +1 -1
- data/lib/aspera/cli/listener/logger.rb +1 -1
- data/lib/aspera/cli/listener/progress.rb +5 -6
- data/lib/aspera/cli/listener/progress_multi.rb +14 -19
- data/lib/aspera/cli/main.rb +66 -67
- data/lib/aspera/cli/manager.rb +112 -110
- data/lib/aspera/cli/plugin.rb +57 -36
- data/lib/aspera/cli/plugins/alee.rb +4 -4
- data/lib/aspera/cli/plugins/aoc.rb +309 -670
- data/lib/aspera/cli/plugins/ats.rb +44 -46
- data/lib/aspera/cli/plugins/bss.rb +10 -10
- data/lib/aspera/cli/plugins/config.rb +497 -378
- data/lib/aspera/cli/plugins/console.rb +12 -12
- data/lib/aspera/cli/plugins/cos.rb +18 -20
- data/lib/aspera/cli/plugins/faspex.rb +112 -114
- data/lib/aspera/cli/plugins/faspex5.rb +71 -46
- data/lib/aspera/cli/plugins/node.rb +379 -283
- data/lib/aspera/cli/plugins/orchestrator.rb +46 -46
- data/lib/aspera/cli/plugins/preview.rb +122 -114
- data/lib/aspera/cli/plugins/server.rb +137 -83
- data/lib/aspera/cli/plugins/shares.rb +30 -29
- data/lib/aspera/cli/plugins/sync.rb +13 -33
- data/lib/aspera/cli/transfer_agent.rb +60 -59
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/colors.rb +3 -3
- data/lib/aspera/command_line_builder.rb +27 -27
- data/lib/aspera/cos_node.rb +22 -20
- data/lib/aspera/data_repository.rb +1 -1
- data/lib/aspera/environment.rb +35 -15
- data/lib/aspera/fasp/agent_base.rb +15 -15
- data/lib/aspera/fasp/agent_connect.rb +23 -21
- data/lib/aspera/fasp/agent_direct.rb +66 -64
- data/lib/aspera/fasp/agent_httpgw.rb +141 -78
- data/lib/aspera/fasp/agent_node.rb +23 -21
- data/lib/aspera/fasp/agent_trsdk.rb +20 -20
- data/lib/aspera/fasp/error.rb +3 -2
- data/lib/aspera/fasp/error_info.rb +11 -8
- data/lib/aspera/fasp/installation.rb +79 -79
- data/lib/aspera/fasp/listener.rb +1 -1
- data/lib/aspera/fasp/parameters.rb +86 -71
- data/lib/aspera/fasp/parameters.yaml +7 -4
- data/lib/aspera/fasp/resume_policy.rb +8 -8
- data/lib/aspera/fasp/transfer_spec.rb +35 -2
- data/lib/aspera/fasp/uri.rb +7 -7
- data/lib/aspera/faspex_gw.rb +7 -5
- data/lib/aspera/hash_ext.rb +3 -3
- data/lib/aspera/id_generator.rb +5 -5
- data/lib/aspera/keychain/encrypted_hash.rb +38 -105
- data/lib/aspera/keychain/macos_security.rb +128 -57
- data/lib/aspera/log.rb +7 -7
- data/lib/aspera/nagios.rb +19 -18
- data/lib/aspera/node.rb +209 -35
- data/lib/aspera/oauth.rb +37 -36
- data/lib/aspera/open_application.rb +19 -11
- data/lib/aspera/persistency_action_once.rb +4 -4
- data/lib/aspera/persistency_folder.rb +16 -15
- data/lib/aspera/preview/file_types.rb +8 -8
- data/lib/aspera/preview/generator.rb +67 -67
- data/lib/aspera/preview/utils.rb +27 -27
- data/lib/aspera/proxy_auto_config.js +41 -41
- data/lib/aspera/proxy_auto_config.rb +21 -14
- data/lib/aspera/rest.rb +72 -67
- data/lib/aspera/rest_call_error.rb +2 -1
- data/lib/aspera/rest_error_analyzer.rb +18 -17
- data/lib/aspera/rest_errors_aspera.rb +16 -16
- data/lib/aspera/secret_hider.rb +15 -13
- data/lib/aspera/ssh.rb +11 -10
- data/lib/aspera/sync.rb +158 -44
- data/lib/aspera/temp_file_manager.rb +2 -2
- data/lib/aspera/uri_reader.rb +4 -4
- data/lib/aspera/web_auth.rb +14 -13
- data.tar.gz.sig +0 -0
- metadata +11 -36
- metadata.gz.sig +0 -0
data/lib/aspera/cli/plugin.rb
CHANGED
@@ -8,34 +8,39 @@ module Aspera
|
|
8
8
|
GLOBAL_OPS = %i[create list].freeze
|
9
9
|
# operations with id
|
10
10
|
INSTANCE_OPS = %i[modify delete show].freeze
|
11
|
-
ALL_OPS = [GLOBAL_OPS,INSTANCE_OPS
|
11
|
+
ALL_OPS = [].concat(GLOBAL_OPS, INSTANCE_OPS).freeze
|
12
12
|
# max number of items for list command
|
13
13
|
MAX_ITEMS = 'max'
|
14
14
|
# max number of pages for list command
|
15
15
|
MAX_PAGES = 'pmax'
|
16
|
+
# used when all resources are selected
|
17
|
+
VAL_ALL = 'ALL'
|
16
18
|
|
17
|
-
#AGENTS=%i[options transfer config formater persistency].freeze
|
19
|
+
# AGENTS=%i[options transfer config formater persistency].freeze
|
18
20
|
|
19
21
|
# global for inherited classes
|
20
22
|
@@options_created = false # rubocop:disable Style/ClassVars
|
21
23
|
|
22
24
|
def initialize(env)
|
23
25
|
raise 'must be Hash' unless env.is_a?(Hash)
|
24
|
-
#env.each_key {|k| raise "wrong agent key #{k}" unless AGENTS.include?(k)}
|
26
|
+
# env.each_key {|k| raise "wrong agent key #{k}" unless AGENTS.include?(k)}
|
25
27
|
@agents = env
|
26
28
|
# check presence in descendant of mandatory method and constant
|
27
|
-
raise StandardError,"missing method 'execute_action' in #{self.class}" unless respond_to?(:execute_action)
|
28
|
-
raise StandardError,'ACTIONS shall be redefined by subclass' unless self.class.constants.include?(:ACTIONS)
|
29
|
+
raise StandardError, "missing method 'execute_action' in #{self.class}" unless respond_to?(:execute_action)
|
30
|
+
raise StandardError, 'ACTIONS shall be redefined by subclass' unless self.class.constants.include?(:ACTIONS)
|
29
31
|
options.parser.separator('')
|
30
32
|
options.parser.separator("COMMAND: #{self.class.name.split('::').last.downcase}")
|
31
|
-
options.parser.separator("SUBCOMMANDS: #{self.class.const_get(:ACTIONS).map(&:to_s).join(' ')}")
|
33
|
+
options.parser.separator("SUBCOMMANDS: #{self.class.const_get(:ACTIONS).map(&:to_s).sort.join(' ')}")
|
32
34
|
options.parser.separator('OPTIONS:')
|
33
35
|
return if @@options_created
|
34
|
-
options.add_opt_simple(:
|
35
|
-
options.add_opt_simple(:
|
36
|
-
options.add_opt_simple(:
|
37
|
-
options.
|
38
|
-
options.
|
36
|
+
options.add_opt_simple(:query, 'additional filter for API calls (extended value) (some commands)')
|
37
|
+
options.add_opt_simple(:value, 'extended value for create, update, list filter')
|
38
|
+
options.add_opt_simple(:property, 'name of property to set')
|
39
|
+
options.add_opt_simple(:id, "resource identifier (#{INSTANCE_OPS.join(',')})")
|
40
|
+
options.add_opt_boolean(:bulk, 'Bulk operation (only some)')
|
41
|
+
options.add_opt_boolean(:bfail, 'Bulk operation error handling')
|
42
|
+
options.set_option(:bulk, :no)
|
43
|
+
options.set_option(:bfail, :yes)
|
39
44
|
options.parse_options!
|
40
45
|
@@options_created = true # rubocop:disable Style/ClassVars
|
41
46
|
end
|
@@ -48,19 +53,19 @@ module Aspera
|
|
48
53
|
end
|
49
54
|
|
50
55
|
# TODO
|
51
|
-
#def get_next_id_command(instance_ops: INSTANCE_OPS,global_ops: GLOBAL_OPS)
|
56
|
+
# def get_next_id_command(instance_ops: INSTANCE_OPS,global_ops: GLOBAL_OPS)
|
52
57
|
# return get_next_argument('command',expected: command_list)
|
53
|
-
#end
|
58
|
+
# end
|
54
59
|
|
55
60
|
# For create and delete operations: execute one actin or multiple if bulk is yes
|
56
61
|
# @param params either single id or hash, or array for bulk
|
57
62
|
# @param success_msg deleted or created
|
58
|
-
def do_bulk_operation(single_or_array,success_msg,id_result: 'id',fields: :default)
|
63
|
+
def do_bulk_operation(single_or_array, success_msg, id_result: 'id', fields: :default)
|
59
64
|
raise 'programming error: missing block' unless block_given?
|
60
65
|
params = options.get_option(:bulk) ? single_or_array : [single_or_array]
|
61
66
|
raise 'expecting Array for bulk operation' unless params.is_a?(Array)
|
62
67
|
Log.log.warn('Empty list given for bulk operation') if params.empty?
|
63
|
-
Log.dump(:bulk_create,params)
|
68
|
+
Log.dump(:bulk_create, params)
|
64
69
|
result_list = []
|
65
70
|
params.each do |param|
|
66
71
|
# init for delete
|
@@ -72,16 +77,17 @@ module Aspera
|
|
72
77
|
result = res if param.is_a?(Hash)
|
73
78
|
result['status'] = success_msg
|
74
79
|
rescue StandardError => e
|
80
|
+
raise e if options.get_option(:bfail)
|
75
81
|
result['status'] = e.to_s
|
76
82
|
end
|
77
83
|
result_list.push(result)
|
78
84
|
end
|
79
|
-
display_fields = [id_result,'status']
|
85
|
+
display_fields = [id_result, 'status']
|
80
86
|
if options.get_option(:bulk)
|
81
|
-
return {type: :object_list,data: result_list,fields: display_fields}
|
87
|
+
return {type: :object_list, data: result_list, fields: display_fields}
|
82
88
|
else
|
83
89
|
display_fields = fields unless fields.eql?(:default)
|
84
|
-
return {type: :single_object,data: result_list.first,fields: display_fields}
|
90
|
+
return {type: :single_object, data: result_list.first, fields: display_fields}
|
85
91
|
end
|
86
92
|
end
|
87
93
|
|
@@ -92,7 +98,7 @@ module Aspera
|
|
92
98
|
# @param id_default [String] default identifier to use for existing entity commands (show, modify)
|
93
99
|
# @param item_list_key [String] result is in a subkey of the json
|
94
100
|
# @return result suitable for CLI result
|
95
|
-
def entity_command(command,rest_api,res_class_path,display_fields: nil,id_default: nil,item_list_key: false)
|
101
|
+
def entity_command(command, rest_api, res_class_path, display_fields: nil, id_default: nil, item_list_key: false)
|
96
102
|
if INSTANCE_OPS.include?(command)
|
97
103
|
begin
|
98
104
|
one_res_id = instance_identifier
|
@@ -104,7 +110,7 @@ module Aspera
|
|
104
110
|
end
|
105
111
|
# parameters mandatory for create/modify
|
106
112
|
if %i[create modify].include?(command)
|
107
|
-
parameters = options.get_option(:value,is_type: :mandatory)
|
113
|
+
parameters = options.get_option(:value, is_type: :mandatory)
|
108
114
|
end
|
109
115
|
# parameters optional for list
|
110
116
|
if [:list].include?(command)
|
@@ -112,27 +118,27 @@ module Aspera
|
|
112
118
|
end
|
113
119
|
case command
|
114
120
|
when :create
|
115
|
-
return do_bulk_operation(parameters,'created',fields: display_fields) do |params|
|
121
|
+
return do_bulk_operation(parameters, 'created', fields: display_fields) do |params|
|
116
122
|
raise 'expecting Hash' unless params.is_a?(Hash)
|
117
|
-
rest_api.create(res_class_path,params)[:data]
|
123
|
+
rest_api.create(res_class_path, params)[:data]
|
118
124
|
end
|
119
125
|
when :delete
|
120
|
-
return do_bulk_operation(one_res_id,'deleted') do |one_id|
|
126
|
+
return do_bulk_operation(one_res_id, 'deleted') do |one_id|
|
121
127
|
rest_api.delete("#{res_class_path}/#{one_id}")
|
122
128
|
{'id' => one_id}
|
123
129
|
end
|
124
130
|
when :show
|
125
131
|
return {type: :single_object, data: rest_api.read(one_res_path)[:data], fields: display_fields}
|
126
132
|
when :list
|
127
|
-
resp = rest_api.read(res_class_path,parameters)
|
133
|
+
resp = rest_api.read(res_class_path, parameters)
|
128
134
|
data = resp[:data]
|
129
135
|
# TODO: not generic : which application is this for ?
|
130
136
|
if resp[:http]['Content-Type'].start_with?('application/vnd.api+json')
|
131
137
|
data = data[res_class_path]
|
132
138
|
end
|
133
139
|
if item_list_key
|
134
|
-
item_list=data[item_list_key]
|
135
|
-
total_count=data['total_count']
|
140
|
+
item_list = data[item_list_key]
|
141
|
+
total_count = data['total_count']
|
136
142
|
if !total_count.nil?
|
137
143
|
count_msg = "Items: #{item_list.length}/#{total_count}"
|
138
144
|
count_msg = count_msg.bg_red unless item_list.length.eql?(total_count.to_i)
|
@@ -140,11 +146,12 @@ module Aspera
|
|
140
146
|
end
|
141
147
|
data = item_list
|
142
148
|
end
|
143
|
-
return {type: :object_list, data: data, fields: display_fields}
|
149
|
+
return {type: :object_list, data: data, fields: display_fields} if data.empty? || data.first.is_a?(Hash)
|
150
|
+
return {type: :value_list, data: data, name: 'id'}
|
144
151
|
when :modify
|
145
152
|
property = options.get_option(:property)
|
146
153
|
parameters = {property => parameters} unless property.nil?
|
147
|
-
rest_api.update(one_res_path,parameters)
|
154
|
+
rest_api.update(one_res_path, parameters)
|
148
155
|
return Main.result_status('modified')
|
149
156
|
else
|
150
157
|
raise "unknown action: #{command}"
|
@@ -152,22 +159,36 @@ module Aspera
|
|
152
159
|
end
|
153
160
|
|
154
161
|
# implement generic rest operations on given resource path
|
155
|
-
def entity_action(rest_api,res_class_path
|
156
|
-
#res_name=res_class_path.gsub(%r{^.*/},'').gsub(%r{s$},'').gsub('_',' ')
|
162
|
+
def entity_action(rest_api, res_class_path, **opts)
|
163
|
+
# res_name=res_class_path.gsub(%r{^.*/},'').gsub(%r{s$},'').gsub('_',' ')
|
157
164
|
command = options.get_next_command(ALL_OPS)
|
158
|
-
return entity_command(command,rest_api,res_class_path
|
165
|
+
return entity_command(command, rest_api, res_class_path, **opts)
|
166
|
+
end
|
167
|
+
|
168
|
+
# query for list operation
|
169
|
+
def option_url_query(default)
|
170
|
+
query = options.get_option(:query)
|
171
|
+
query = default if query.nil?
|
172
|
+
Log.log.debug{"Query=#{query}".bg_red}
|
173
|
+
begin
|
174
|
+
# check it is suitable
|
175
|
+
URI.encode_www_form(query) unless query.nil?
|
176
|
+
rescue StandardError => e
|
177
|
+
raise CliBadArgument, "query must be an extended value which can be encoded with URI.encode_www_form. Refer to manual. (#{e.message})"
|
178
|
+
end
|
179
|
+
return query
|
159
180
|
end
|
160
181
|
|
161
182
|
# shortcuts helpers for plugin environment
|
162
|
-
def options; return @agents[:options];end
|
183
|
+
def options; return @agents[:options]; end
|
163
184
|
|
164
|
-
def transfer; return @agents[:transfer];end
|
185
|
+
def transfer; return @agents[:transfer]; end
|
165
186
|
|
166
|
-
def config; return @agents[:config];end
|
187
|
+
def config; return @agents[:config]; end
|
167
188
|
|
168
|
-
def format; return @agents[:formater];end
|
189
|
+
def format; return @agents[:formater]; end
|
169
190
|
|
170
|
-
def persistency; return @agents[:persistency];end
|
191
|
+
def persistency; return @agents[:persistency]; end
|
171
192
|
end # Plugin
|
172
193
|
end # Cli
|
173
194
|
end # Aspera
|
@@ -6,16 +6,16 @@ require 'aspera/aoc'
|
|
6
6
|
module Aspera
|
7
7
|
module Cli
|
8
8
|
module Plugins
|
9
|
-
class Alee < BasicAuthPlugin
|
9
|
+
class Alee < Aspera::Cli::BasicAuthPlugin
|
10
10
|
ACTIONS = %i[entitlement].freeze
|
11
11
|
|
12
12
|
def execute_action
|
13
13
|
command = options.get_next_command(ACTIONS)
|
14
14
|
case command
|
15
15
|
when :entitlement
|
16
|
-
entitlement_id = options.get_option(:username,is_type: :mandatory)
|
17
|
-
customer_id = options.get_option(:password,is_type: :mandatory)
|
18
|
-
api_metering = AoC.metering_api(entitlement_id,customer_id)
|
16
|
+
entitlement_id = options.get_option(:username, is_type: :mandatory)
|
17
|
+
customer_id = options.get_option(:password, is_type: :mandatory)
|
18
|
+
api_metering = AoC.metering_api(entitlement_id, customer_id)
|
19
19
|
return {type: :single_object, data: api_metering.read('entitlement')[:data]}
|
20
20
|
end
|
21
21
|
end
|