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