aspera-cli 4.10.0 → 4.11.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 +20 -0
- data/CHANGELOG.md +509 -0
- data/CONTRIBUTING.md +118 -0
- data/README.md +621 -378
- data/bin/ascli +4 -4
- data/bin/asession +11 -11
- data/docs/test_env.conf +28 -19
- data/examples/aoc.rb +4 -4
- data/examples/dascli +11 -9
- data/examples/faspex4.rb +8 -8
- data/examples/node.rb +11 -11
- data/examples/server.rb +9 -9
- 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/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 +110 -110
- data/lib/aspera/cli/plugin.rb +54 -37
- data/lib/aspera/cli/plugins/alee.rb +4 -4
- data/lib/aspera/cli/plugins/aoc.rb +308 -669
- 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 +447 -344
- 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 +110 -112
- data/lib/aspera/cli/plugins/faspex5.rb +67 -46
- data/lib/aspera/cli/plugins/node.rb +364 -288
- 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 +57 -57
- 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 +30 -28
- 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 +65 -67
- data/lib/aspera/fasp/agent_httpgw.rb +72 -68
- 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 +78 -78
- data/lib/aspera/fasp/listener.rb +1 -1
- data/lib/aspera/fasp/parameters.rb +75 -72
- data/lib/aspera/fasp/parameters.yaml +2 -2
- 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 +23 -28
- data/lib/aspera/keychain/macos_security.rb +21 -20
- 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 +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 +41 -41
- data/lib/aspera/proxy_auto_config.rb +16 -16
- data/lib/aspera/rest.rb +56 -60
- 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 +8 -5
- metadata.gz.sig +0 -0
data/lib/aspera/cli/plugin.rb
CHANGED
|
@@ -8,36 +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.add_opt_boolean(:
|
|
39
|
-
options.
|
|
40
|
-
options.set_option(:
|
|
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)
|
|
41
44
|
options.parse_options!
|
|
42
45
|
@@options_created = true # rubocop:disable Style/ClassVars
|
|
43
46
|
end
|
|
@@ -50,19 +53,19 @@ module Aspera
|
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
# TODO
|
|
53
|
-
#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)
|
|
54
57
|
# return get_next_argument('command',expected: command_list)
|
|
55
|
-
#end
|
|
58
|
+
# end
|
|
56
59
|
|
|
57
60
|
# For create and delete operations: execute one actin or multiple if bulk is yes
|
|
58
61
|
# @param params either single id or hash, or array for bulk
|
|
59
62
|
# @param success_msg deleted or created
|
|
60
|
-
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)
|
|
61
64
|
raise 'programming error: missing block' unless block_given?
|
|
62
65
|
params = options.get_option(:bulk) ? single_or_array : [single_or_array]
|
|
63
66
|
raise 'expecting Array for bulk operation' unless params.is_a?(Array)
|
|
64
67
|
Log.log.warn('Empty list given for bulk operation') if params.empty?
|
|
65
|
-
Log.dump(:bulk_create,params)
|
|
68
|
+
Log.dump(:bulk_create, params)
|
|
66
69
|
result_list = []
|
|
67
70
|
params.each do |param|
|
|
68
71
|
# init for delete
|
|
@@ -79,12 +82,12 @@ module Aspera
|
|
|
79
82
|
end
|
|
80
83
|
result_list.push(result)
|
|
81
84
|
end
|
|
82
|
-
display_fields = [id_result,'status']
|
|
85
|
+
display_fields = [id_result, 'status']
|
|
83
86
|
if options.get_option(:bulk)
|
|
84
|
-
return {type: :object_list,data: result_list,fields: display_fields}
|
|
87
|
+
return {type: :object_list, data: result_list, fields: display_fields}
|
|
85
88
|
else
|
|
86
89
|
display_fields = fields unless fields.eql?(:default)
|
|
87
|
-
return {type: :single_object,data: result_list.first,fields: display_fields}
|
|
90
|
+
return {type: :single_object, data: result_list.first, fields: display_fields}
|
|
88
91
|
end
|
|
89
92
|
end
|
|
90
93
|
|
|
@@ -95,7 +98,7 @@ module Aspera
|
|
|
95
98
|
# @param id_default [String] default identifier to use for existing entity commands (show, modify)
|
|
96
99
|
# @param item_list_key [String] result is in a subkey of the json
|
|
97
100
|
# @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)
|
|
101
|
+
def entity_command(command, rest_api, res_class_path, display_fields: nil, id_default: nil, item_list_key: false)
|
|
99
102
|
if INSTANCE_OPS.include?(command)
|
|
100
103
|
begin
|
|
101
104
|
one_res_id = instance_identifier
|
|
@@ -107,7 +110,7 @@ module Aspera
|
|
|
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
116
|
if [:list].include?(command)
|
|
@@ -115,27 +118,27 @@ module Aspera
|
|
|
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|
|
|
126
|
+
return do_bulk_operation(one_res_id, 'deleted') do |one_id|
|
|
124
127
|
rest_api.delete("#{res_class_path}/#{one_id}")
|
|
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')
|
|
134
137
|
data = data[res_class_path]
|
|
135
138
|
end
|
|
136
139
|
if item_list_key
|
|
137
|
-
item_list=data[item_list_key]
|
|
138
|
-
total_count=data['total_count']
|
|
140
|
+
item_list = data[item_list_key]
|
|
141
|
+
total_count = data['total_count']
|
|
139
142
|
if !total_count.nil?
|
|
140
143
|
count_msg = "Items: #{item_list.length}/#{total_count}"
|
|
141
144
|
count_msg = count_msg.bg_red unless item_list.length.eql?(total_count.to_i)
|
|
@@ -148,7 +151,7 @@ module Aspera
|
|
|
148
151
|
when :modify
|
|
149
152
|
property = options.get_option(:property)
|
|
150
153
|
parameters = {property => parameters} unless property.nil?
|
|
151
|
-
rest_api.update(one_res_path,parameters)
|
|
154
|
+
rest_api.update(one_res_path, parameters)
|
|
152
155
|
return Main.result_status('modified')
|
|
153
156
|
else
|
|
154
157
|
raise "unknown action: #{command}"
|
|
@@ -156,22 +159,36 @@ module Aspera
|
|
|
156
159
|
end
|
|
157
160
|
|
|
158
161
|
# 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('_',' ')
|
|
162
|
+
def entity_action(rest_api, res_class_path, **opts)
|
|
163
|
+
# res_name=res_class_path.gsub(%r{^.*/},'').gsub(%r{s$},'').gsub('_',' ')
|
|
161
164
|
command = options.get_next_command(ALL_OPS)
|
|
162
|
-
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
|
|
163
180
|
end
|
|
164
181
|
|
|
165
182
|
# shortcuts helpers for plugin environment
|
|
166
|
-
def options; return @agents[:options];end
|
|
183
|
+
def options; return @agents[:options]; end
|
|
167
184
|
|
|
168
|
-
def transfer; return @agents[:transfer];end
|
|
185
|
+
def transfer; return @agents[:transfer]; end
|
|
169
186
|
|
|
170
|
-
def config; return @agents[:config];end
|
|
187
|
+
def config; return @agents[:config]; end
|
|
171
188
|
|
|
172
|
-
def format; return @agents[:formater];end
|
|
189
|
+
def format; return @agents[:formater]; end
|
|
173
190
|
|
|
174
|
-
def persistency; return @agents[:persistency];end
|
|
191
|
+
def persistency; return @agents[:persistency]; end
|
|
175
192
|
end # Plugin
|
|
176
193
|
end # Cli
|
|
177
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
|