aspera-cli 4.24.1 → 4.25.0.pre

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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +1064 -745
  4. data/CONTRIBUTING.md +43 -100
  5. data/README.md +1281 -720
  6. data/bin/ascli +20 -1
  7. data/bin/asession +23 -27
  8. data/lib/aspera/agent/base.rb +10 -21
  9. data/lib/aspera/agent/connect.rb +2 -3
  10. data/lib/aspera/agent/desktop.rb +2 -2
  11. data/lib/aspera/agent/direct.rb +49 -32
  12. data/lib/aspera/agent/factory.rb +31 -0
  13. data/lib/aspera/api/aoc.rb +134 -76
  14. data/lib/aspera/api/cos_node.rb +3 -2
  15. data/lib/aspera/api/faspex.rb +213 -0
  16. data/lib/aspera/api/node.rb +107 -94
  17. data/lib/aspera/ascmd.rb +1 -2
  18. data/lib/aspera/ascp/installation.rb +73 -58
  19. data/lib/aspera/ascp/management.rb +119 -23
  20. data/lib/aspera/assert.rb +39 -11
  21. data/lib/aspera/cli/error.rb +4 -2
  22. data/lib/aspera/cli/extended_value.rb +91 -67
  23. data/lib/aspera/cli/formatter.rb +62 -27
  24. data/lib/aspera/cli/hints.rb +8 -0
  25. data/lib/aspera/cli/info.rb +4 -4
  26. data/lib/aspera/cli/main.rb +76 -84
  27. data/lib/aspera/cli/manager.rb +352 -248
  28. data/lib/aspera/cli/plugins/alee.rb +5 -4
  29. data/lib/aspera/cli/plugins/aoc.rb +175 -195
  30. data/lib/aspera/cli/plugins/ats.rb +4 -4
  31. data/lib/aspera/cli/plugins/base.rb +343 -0
  32. data/lib/aspera/cli/plugins/basic_auth.rb +45 -0
  33. data/lib/aspera/cli/plugins/config.rb +283 -269
  34. data/lib/aspera/cli/plugins/console.rb +27 -22
  35. data/lib/aspera/cli/plugins/cos.rb +3 -3
  36. data/lib/aspera/cli/plugins/factory.rb +78 -0
  37. data/lib/aspera/cli/plugins/faspex.rb +49 -46
  38. data/lib/aspera/cli/plugins/faspex5.rb +113 -225
  39. data/lib/aspera/cli/plugins/faspio.rb +19 -18
  40. data/lib/aspera/cli/plugins/httpgw.rb +14 -13
  41. data/lib/aspera/cli/plugins/node.rb +162 -149
  42. data/lib/aspera/cli/plugins/oauth.rb +48 -0
  43. data/lib/aspera/cli/plugins/orchestrator.rb +129 -45
  44. data/lib/aspera/cli/plugins/preview.rb +30 -50
  45. data/lib/aspera/cli/plugins/server.rb +21 -21
  46. data/lib/aspera/cli/plugins/shares.rb +45 -47
  47. data/lib/aspera/cli/sync_actions.rb +50 -39
  48. data/lib/aspera/cli/transfer_agent.rb +35 -49
  49. data/lib/aspera/cli/transfer_progress.rb +6 -6
  50. data/lib/aspera/cli/version.rb +3 -3
  51. data/lib/aspera/cli/wizard.rb +70 -55
  52. data/lib/aspera/colors.rb +6 -0
  53. data/lib/aspera/command_line_builder.rb +59 -61
  54. data/lib/aspera/command_line_converter.rb +2 -1
  55. data/lib/aspera/coverage.rb +2 -2
  56. data/lib/aspera/data_repository.rb +1 -1
  57. data/lib/aspera/environment.rb +51 -41
  58. data/lib/aspera/faspex_gw.rb +7 -5
  59. data/lib/aspera/faspex_postproc.rb +1 -1
  60. data/lib/aspera/keychain/factory.rb +1 -2
  61. data/lib/aspera/keychain/macos_security.rb +1 -1
  62. data/lib/aspera/log.rb +37 -9
  63. data/lib/aspera/markdown.rb +31 -0
  64. data/lib/aspera/nagios.rb +7 -6
  65. data/lib/aspera/oauth/base.rb +25 -28
  66. data/lib/aspera/oauth/factory.rb +9 -9
  67. data/lib/aspera/oauth/url_json.rb +2 -1
  68. data/lib/aspera/oauth/web.rb +2 -2
  69. data/lib/aspera/preview/file_types.rb +23 -37
  70. data/lib/aspera/products/connect.rb +7 -6
  71. data/lib/aspera/products/desktop.rb +1 -4
  72. data/lib/aspera/products/other.rb +9 -1
  73. data/lib/aspera/products/transferd.rb +0 -1
  74. data/lib/aspera/rest.rb +168 -113
  75. data/lib/aspera/rest_error_analyzer.rb +4 -4
  76. data/lib/aspera/ssh.rb +7 -4
  77. data/lib/aspera/ssl.rb +41 -0
  78. data/lib/aspera/sync/args.schema.yaml +46 -3
  79. data/lib/aspera/sync/conf.schema.yaml +307 -123
  80. data/lib/aspera/sync/database.rb +2 -1
  81. data/lib/aspera/sync/operations.rb +135 -79
  82. data/lib/aspera/temp_file_manager.rb +17 -5
  83. data/lib/aspera/transfer/error.rb +16 -7
  84. data/lib/aspera/transfer/parameters.rb +35 -22
  85. data/lib/aspera/transfer/resumer.rb +74 -0
  86. data/lib/aspera/transfer/spec.rb +5 -5
  87. data/lib/aspera/transfer/spec.schema.yaml +170 -59
  88. data/lib/aspera/transfer/spec_doc.rb +49 -43
  89. data/lib/aspera/uri_reader.rb +2 -2
  90. data/lib/aspera/web_auth.rb +6 -6
  91. data/lib/transferd_pb.rb +2 -2
  92. data.tar.gz.sig +0 -0
  93. metadata +26 -11
  94. metadata.gz.sig +0 -0
  95. data/lib/aspera/cli/basic_auth_plugin.rb +0 -43
  96. data/lib/aspera/cli/plugin.rb +0 -333
  97. data/lib/aspera/cli/plugin_factory.rb +0 -81
  98. data/lib/aspera/resumer.rb +0 -77
  99. data/lib/aspera/transfer/error_info.rb +0 -91
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/cli/basic_auth_plugin'
3
+ require 'aspera/cli/plugins/basic_auth'
4
4
  require 'aspera/cli/special_values'
5
5
  require 'aspera/nagios'
6
6
  require 'aspera/log'
@@ -10,7 +10,8 @@ require 'xmlsimple'
10
10
  module Aspera
11
11
  module Cli
12
12
  module Plugins
13
- class Orchestrator < Cli::BasicAuthPlugin
13
+ # Aspera Orchestrator
14
+ class Orchestrator < BasicAuth
14
15
  STANDARD_PATH = '/aspera/orchestrator'
15
16
  TEST_ENDPOINT = 'api/remote_node_ping'
16
17
  private_constant :STANDARD_PATH, :TEST_ENDPOINT
@@ -23,11 +24,11 @@ module Aspera
23
24
  urls.each do |base_url|
24
25
  next unless base_url.match?('https?://')
25
26
  api = Rest.new(base_url: base_url)
26
- result = api.call(operation: 'GET', subpath: TEST_ENDPOINT, headers: {'Accept' => Rest::MIME_JSON}, query: {format: :json})
27
- next unless result[:data]['remote_orchestrator_info']
28
- url = result[:http].uri.to_s
27
+ data, http = api.read(TEST_ENDPOINT, query: {format: :json}, ret: :both)
28
+ next unless data['remote_orchestrator_info']
29
+ url = http.uri.to_s
29
30
  return {
30
- version: result[:data]['remote_orchestrator_info']['orchestrator-version'],
31
+ version: data['remote_orchestrator_info']['orchestrator-version'],
31
32
  url: url[0..url.index(TEST_ENDPOINT) - 2]
32
33
  }
33
34
  rescue StandardError => e
@@ -37,32 +38,32 @@ module Aspera
37
38
  raise error if error
38
39
  return
39
40
  end
41
+ end
40
42
 
41
- def wizard(object:)
42
- options = object.options
43
- return {
44
- preset_value: {
45
- url: options.get_option(:url, mandatory: true),
46
- username: options.get_option(:username, mandatory: true),
47
- password: options.get_option(:password, mandatory: true)
48
- },
49
- test_args: 'workflow list'
50
- }
51
- end
43
+ # @param wizard [Wizard] The wizard object
44
+ # @param app_url [Wizard] The wizard object
45
+ # @return [Hash] :preset_value, :test_args
46
+ def wizard(wizard, app_url)
47
+ return {
48
+ preset_value: {
49
+ url: app_url,
50
+ username: options.get_option(:username, mandatory: true),
51
+ password: options.get_option(:password, mandatory: true)
52
+ },
53
+ test_args: 'workflow list'
54
+ }
52
55
  end
53
56
 
54
57
  def initialize(**_)
55
58
  super
56
59
  @api_orch = nil
57
60
  options.declare(:result, "Specify result value as: 'work_step:parameter'")
58
- options.declare(:synchronous, 'Wait for completion', values: :bool, default: :no)
59
- options.declare(:ret_style, 'How return type is requested in api', values: %i[header arg ext], default: :arg)
60
- options.declare(:auth_style, 'Authentication type', values: %i[arg_pass head_basic apikey], default: :head_basic)
61
+ options.declare(:synchronous, 'Wait for completion', allowed: Allowed::TYPES_BOOLEAN, default: false)
62
+ options.declare(:ret_style, 'How return type is requested in api', allowed: %i[header arg ext], default: :arg)
63
+ options.declare(:auth_style, 'Authentication type', allowed: %i[arg_pass head_basic apikey], default: :head_basic)
61
64
  options.parse_options!
62
65
  end
63
66
 
64
- ACTIONS = %i[health info workflow plugins processes].freeze
65
-
66
67
  # Call orchestrator API, it's a bit special
67
68
  # @param endpoint [String] the endpoint to call
68
69
  # @param ret_style [Symbol] the return style, :header, :arg, :ext(extension)
@@ -72,28 +73,31 @@ module Aspera
72
73
  # @param http [Boolean] if true, returns the HttpResponse, else
73
74
  def call_ao(endpoint, ret_style: nil, format: 'json', args: nil, xml_arrays: true, http: false)
74
75
  # calls are all GET
75
- call_args = {operation: 'GET', subpath: "api/#{endpoint}"}
76
+ call_args = {operation: 'GET', subpath: "api/#{endpoint}", ret: :both, query: {}}
76
77
  ret_style = options.get_option(:ret_style, mandatory: true) if ret_style.nil?
77
- call_args[:query] = args unless args.nil?
78
+ call_args[:query].merge!(args) unless args.nil?
78
79
  unless format.nil?
79
80
  case ret_style
80
81
  when :header
81
82
  call_args[:headers] = {'Accept' => "application/#{format}"}
82
83
  when :arg
83
- call_args[:query] ||= {}
84
84
  call_args[:query][:format] = format
85
85
  when :ext
86
86
  call_args[:subpath] = "#{call_args[:subpath]}.#{format}"
87
87
  else Aspera.error_unexpected_value(ret_style)
88
88
  end
89
89
  end
90
- result = @api_orch.call(**call_args)
91
- return result[:http] if http
92
- result = format.eql?('xml') ? XmlSimple.xml_in(result[:http].body, {'ForceArray' => xml_arrays}) : result[:data]
90
+ add_query = options.get_option(:query)
91
+ call_args[:query].merge!(add_query.symbolize_keys) unless add_query.nil?
92
+ data, resp = @api_orch.call(**call_args)
93
+ return resp if http
94
+ result = format.eql?('xml') ? XmlSimple.xml_in(resp.body, {'ForceArray' => xml_arrays}) : data
93
95
  Log.dump(:data, result)
94
96
  return result
95
97
  end
96
98
 
99
+ ACTIONS = %i[health info workflows workorders workstep plugins processes monitors].freeze
100
+
97
101
  def execute_action
98
102
  auth_params =
99
103
  case options.get_option(:auth_style, mandatory: true)
@@ -131,37 +135,33 @@ module Aspera
131
135
  rescue StandardError => e
132
136
  nagios.add_critical('node api', e.to_s)
133
137
  end
134
- return nagios.result
138
+ Main.result_object_list(nagios.status_list)
139
+ # 14. Ping the remote Instance
135
140
  when :info
136
141
  result = call_ao('remote_node_ping', format: 'xml', xml_arrays: false)
137
142
  return Main.result_single_object(result)
143
+ # 12. Orchestrator Background Process status
138
144
  when :processes
139
145
  # TODO: Bug ? API has only XML format
140
146
  result = call_ao('processes_status', format: 'xml')
141
147
  return Main.result_object_list(result['process'])
148
+ # 13. Orchestrator Monitor
149
+ when :monitors
150
+ result = call_ao('monitor_snapshot')
151
+ return Main.result_single_object(result['monitor'])
142
152
  when :plugins
143
153
  # TODO: Bug ? only json format on url
144
154
  result = call_ao('plugin_version')
145
155
  return Main.result_object_list(result['Plugin'])
146
- when :workflow
147
- command = options.get_next_command(%i[list status inputs details start export])
156
+ when :workflows
157
+ command = options.get_next_command(%i[list status inputs details start export workorders outputs])
148
158
  case command
149
- when :status
150
- wf_id = instance_identifier
151
- result = call_ao(wf_id.eql?(SpecialValues::ALL) ? 'workflows_status' : "workflows_status/#{wf_id}")
152
- return Main.result_object_list(result['workflows']['workflow'])
159
+ # 1. List all available workflows on the system
153
160
  when :list
154
- result = call_ao('workflows_list/0')
161
+ result = call_ao('workflows_list')
155
162
  return Main.result_object_list(result['workflows']['workflow'], fields: %w[id portable_id name published_status published_revision_id latest_revision_id last_modification])
156
- when :details
157
- result = call_ao("workflow_details/#{instance_identifier}")
158
- return Main.result_object_list(result['workflows']['workflow']['statuses'])
159
- when :inputs
160
- result = call_ao("workflow_inputs_spec/#{instance_identifier}")
161
- return Main.result_single_object(result['workflow_inputs_spec'])
162
- when :export
163
- result = call_ao("export_workflow/#{instance_identifier}", format: nil, http: true)
164
- return Main.result_text(result.body)
163
+ # 2.1 Initiate a workorder - Asynchronous
164
+ # 2.2 Initiate a workorder - Synchronous
165
165
  when :start
166
166
  result = {
167
167
  type: :single_object,
@@ -189,6 +189,69 @@ module Aspera
189
189
  result[:type] = :text if call_params['synchronous']
190
190
  result[:data] = call_ao("initiate/#{wf_id}", args: call_params)
191
191
  return result
192
+ # 3. Fetch input specification for a workflow
193
+ when :inputs
194
+ result = call_ao("workflow_inputs_spec/#{instance_identifier}")
195
+ return Main.result_single_object(result['workflow_inputs_spec'])
196
+ # 4. Check the running status for all workflows
197
+ # 5. Check the running status for a particular workflow
198
+ when :status
199
+ wf_id = instance_identifier
200
+ result = call_ao(wf_id.eql?(SpecialValues::ALL) ? 'workflows_status' : "workflows_status/#{wf_id}")
201
+ return Main.result_object_list(result['workflows']['workflow'])
202
+ # 6. Check the detailed running status for a particular workflow
203
+ when :details
204
+ result = call_ao("workflow_details/#{instance_identifier}")
205
+ return Main.result_object_list(result['workflows']['workflow']['statuses'])
206
+ # 15. Fetch output specification for a particular work flow
207
+ when :outputs
208
+ result = call_ao("workflow_outputs_spec/#{instance_identifier}")
209
+ return Main.result_object_list(result['workflow_outputs_spec']['output'])
210
+ # 19.Fetch all workorders from a workflow
211
+ when :workorders
212
+ result = call_ao("work_orders_list/#{instance_identifier}")
213
+ return Main.result_object_list(result['work_orders'])
214
+ when :export
215
+ result = call_ao("export_workflow/#{instance_identifier}", format: nil, http: true)
216
+ return Main.result_text(result.body)
217
+ end
218
+ when :workorders
219
+ command = options.get_next_command(%i[status cancel reset output])
220
+ case command
221
+ # 7. Check the status for a particular work order
222
+ when :status
223
+ wo_id = instance_identifier
224
+ result = call_ao("work_order_status/#{wo_id}")
225
+ return Main.result_single_object(result['work_order'])
226
+ # 9. Cancel a Work Order
227
+ when :cancel
228
+ wo_id = instance_identifier
229
+ result = call_ao("work_order_cancel/#{wo_id}")
230
+ return Main.result_single_object(result['work_order'])
231
+ # 11. Reset a Work order
232
+ when :reset
233
+ wo_id = instance_identifier
234
+ result = call_ao("work_order_reset/#{wo_id}")
235
+ return Main.result_single_object(result['work_order'])
236
+ # 16. Fetch output of a work order
237
+ when :output
238
+ wo_id = instance_identifier
239
+ result = call_ao("work_order_output/#{wo_id}", format: 'xml')
240
+ return Main.result_object_list(result['variable'])
241
+ end
242
+ when :workstep
243
+ command = options.get_next_command(%i[status cancel])
244
+ case command
245
+ # 8. Check the status of a Step
246
+ when :status
247
+ ws_id = instance_identifier
248
+ result = call_ao("work_step_status/#{ws_id}")
249
+ return Main.result_single_object(result)
250
+ # 10. Cancel a Work Step
251
+ when :cancel
252
+ ws_id = instance_identifier
253
+ result = call_ao("work_step_cancel/#{ws_id}")
254
+ return Main.result_single_object(result)
192
255
  end
193
256
  else Aspera.error_unexpected_value(command)
194
257
  end
@@ -198,3 +261,24 @@ module Aspera
198
261
  end
199
262
  end
200
263
  end
264
+
265
+ # 17.Persist custom data
266
+ # 18.Fetch queued items from queue
267
+ # 20.List Task for a User
268
+ # 21. Fetch Task details
269
+ # 22. Submit Task
270
+ # 23. Control Process
271
+ # engine monitor worker
272
+ # 24. Lookup Queued Item
273
+ # 25. Reorder Queued Items
274
+ # 26. Bulk Reorder Queued Items
275
+ # 27. Queue Item (Add an item to a Queue)
276
+ #
277
+ # Required Input:
278
+ # Optional Input:
279
+ # 28.List all queues
280
+ # 29. Portlet Version
281
+ # 30. Plugin Version
282
+ # 31. Restart Work Order from a Step
283
+ # 32. Delete element from a Managed Queue
284
+ #
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # cspell:ignore trevents
4
- require 'aspera/cli/basic_auth_plugin'
4
+ require 'aspera/cli/plugins/basic_auth'
5
5
  require 'aspera/preview/generator'
6
6
  require 'aspera/preview/options'
7
7
  require 'aspera/preview/utils'
@@ -9,6 +9,7 @@ require 'aspera/preview/file_types'
9
9
  require 'aspera/preview/terminal'
10
10
  require 'aspera/transfer/spec'
11
11
  require 'aspera/persistency_action_once'
12
+ require 'aspera/temp_file_manager'
12
13
  require 'aspera/api/node'
13
14
  require 'aspera/hash_ext'
14
15
  require 'aspera/timer_limiter'
@@ -20,7 +21,7 @@ require 'securerandom'
20
21
  module Aspera
21
22
  module Cli
22
23
  module Plugins
23
- class Preview < Cli::BasicAuthPlugin
24
+ class Preview < BasicAuth
24
25
  # special tag to identify transfers related to generator
25
26
  PREV_GEN_TAG = 'preview_generator'
26
27
  # defined by node API: suffix for folder containing previews
@@ -45,16 +46,15 @@ module Aspera
45
46
  :AK_MARKER_FILE,
46
47
  :LOG_LIMITER_SEC
47
48
 
48
- # option_skip_format has special accessors
49
- attr_accessor :option_previews_folder
50
- attr_accessor :option_folder_reset_cache, :option_skip_folders, :option_overwrite, :option_file_access
49
+ attr_accessor :option_skip_types, :option_previews_folder, :option_folder_reset_cache, :option_skip_folders, :option_overwrite, :option_file_access
51
50
 
52
51
  def initialize(**_)
53
52
  super
54
- @skip_types = []
55
- @default_transfer_spec = nil
56
- # by default generate all supported formats (clone, as altered by options)
57
- @preview_formats_to_generate = Aspera::Preview::Generator::PREVIEW_FORMATS.clone
53
+ @option_skip_types = []
54
+ @option_skip_folders = []
55
+ @option_previews_folder = nil
56
+ @option_overwrite = nil
57
+ @option_folder_reset_cache = nil
58
58
  # options for generation
59
59
  @gen_options = Aspera::Preview::Options.new
60
60
  # used to trigger periodic processing
@@ -63,69 +63,49 @@ module Aspera
63
63
  @filter_block = nil
64
64
  # link CLI options to gen_info attributes
65
65
  options.declare(
66
- :skip_format, 'Skip this preview format (multiple possible)', values: Aspera::Preview::Generator::PREVIEW_FORMATS,
67
- handler: {o: self, m: :option_skip_format}, default: []
66
+ :skip_format, 'Skip this preview format',
67
+ allowed: Aspera::Preview::Generator::PREVIEW_FORMATS
68
68
  )
69
69
  options.declare(
70
70
  :folder_reset_cache, 'Force detection of generated preview by refresh cache',
71
- values: %i[no header read],
71
+ allowed: %i[no header read],
72
72
  handler: {o: self, m: :option_folder_reset_cache},
73
73
  default: :no
74
74
  )
75
- options.declare(:skip_types, 'Skip types in comma separated list', handler: {o: self, m: :option_skip_types})
75
+ options.declare(:skip_types, 'Skip generation for those types of files', handler: {o: self, m: :option_skip_types}, allowed: Allowed::TYPES_SYMBOL_ARRAY + Aspera::Preview::FileTypes::CONVERSION_TYPES)
76
76
  options.declare(:previews_folder, 'Preview folder in storage root', handler: {o: self, m: :option_previews_folder}, default: DEFAULT_PREVIEWS_FOLDER)
77
- options.declare(:temp_folder, 'Path to temp folder', default: Dir.tmpdir)
78
- options.declare(:skip_folders, 'List of folder to skip', handler: {o: self, m: :option_skip_folders}, default: [])
77
+ options.declare(:skip_folders, 'List of folder to skip', handler: {o: self, m: :option_skip_folders}, allowed: Allowed::TYPES_STRING_ARRAY)
79
78
  options.declare(:base, 'Basename of output for for test')
80
79
  options.declare(:scan_path, 'Subpath in folder id to start scan in (default=/)')
81
80
  options.declare(:scan_id, 'Folder id in storage to start scan in, default is access key main folder id')
82
- options.declare(:mimemagic, 'Use Mime type detection of gem mimemagic', values: :bool, default: false)
83
- options.declare(:overwrite, 'When to overwrite result file', values: %i[always never mtime], handler: {o: self, m: :option_overwrite}, default: :mtime)
81
+ options.declare(:mimemagic, 'Use Mime type detection of gem mimemagic', allowed: Allowed::TYPES_BOOLEAN, default: false)
82
+ options.declare(:overwrite, 'When to overwrite result file', handler: {o: self, m: :option_overwrite}, allowed: %i[always never mtime], default: :mtime)
84
83
  options.declare(
85
84
  :file_access, 'How to read and write files in repository',
86
- values: %i[local remote],
85
+ allowed: %i[local remote],
87
86
  handler: {o: self, m: :option_file_access},
88
87
  default: :local
89
88
  )
90
-
91
89
  # add other options for generator (and set default values)
92
90
  Aspera::Preview::Options::DESCRIPTIONS.each do |opt|
93
91
  values = if opt.key?(:values)
94
92
  opt[:values]
95
93
  elsif Cli::Manager::BOOLEAN_SIMPLE.include?(opt[:default])
96
- :bool
94
+ Allowed::TYPES_BOOLEAN
97
95
  end
98
- options.declare(opt[:name], opt[:description].capitalize, values: values, handler: {o: @gen_options, m: opt[:name]}, default: opt[:default])
96
+ options.declare(opt[:name], opt[:description].capitalize, allowed: values, handler: {o: @gen_options, m: opt[:name]}, default: opt[:default])
99
97
  end
100
98
 
101
99
  options.parse_options!
102
- Aspera.assert_type(@option_skip_folders, Array){'skip_folder'}
103
- @tmp_folder = File.join(options.get_option(:temp_folder, mandatory: true), "#{TMP_DIR_PREFIX}.#{SecureRandom.uuid}")
100
+ # by default generate all supported formats (clone, as altered by options)
101
+ @preview_formats_to_generate = Aspera::Preview::Generator::PREVIEW_FORMATS.clone
102
+ skip = options.get_option(:skip_format)
103
+ @preview_formats_to_generate.delete(skip) if skip
104
+ @tmp_folder = File.join(TempFileManager.instance.global_temp, "#{TMP_DIR_PREFIX}.#{SecureRandom.uuid}")
104
105
  FileUtils.mkdir_p(@tmp_folder)
105
106
  Log.log.debug{"tmpdir: #{@tmp_folder}"}
106
107
  end
107
108
 
108
- def option_skip_types=(value)
109
- @skip_types = []
110
- value.split(',').each do |v|
111
- s = v.to_sym
112
- Aspera.assert_values(s, Aspera::Preview::FileTypes::CONVERSION_TYPES){'skip_types'}
113
- @skip_types.push(s)
114
- end
115
- end
116
-
117
- def option_skip_types
118
- return @skip_types.map(&:to_s).join(',')
119
- end
120
-
121
- def option_skip_format=(value)
122
- @preview_formats_to_generate.delete(value)
123
- end
124
-
125
- def option_skip_format
126
- return @preview_formats_to_generate.map(&:to_s).join(',')
127
- end
128
-
129
109
  # /files/id/files is normally cached in redis, but we can discard the cache
130
110
  # but /files/id is not cached
131
111
  def get_folder_entries(file_id, request_args = nil)
@@ -136,7 +116,7 @@ module Aspera
136
116
  subpath: "files/#{file_id}/files",
137
117
  headers: headers,
138
118
  query: request_args
139
- )[:data]
119
+ )
140
120
  end
141
121
 
142
122
  # old version based on folders
@@ -221,8 +201,8 @@ module Aspera
221
201
  'paths' => [{'source' => source_filename}],
222
202
  'tags' => {Transfer::Spec::TAG_RESERVED => {PREV_GEN_TAG => true}}
223
203
  })
224
- # force destination, need to set this in transfer agent else it gets overwritten, not do: t_spec['destination_root']=destination
225
- transfer.option_transfer_spec_deep_merge({'destination_root' => destination})
204
+ # force destination, need to set this in transfer agent else it gets overwritten, do not do: t_spec['destination_root']=destination
205
+ transfer.user_transfer_spec['destination_root'] = destination
226
206
  Main.result_transfer(transfer.start(t_spec))
227
207
  end
228
208
 
@@ -311,7 +291,7 @@ module Aspera
311
291
  next false
312
292
  end
313
293
  # shall we skip it ?
314
- next false if @skip_types.include?(gen_info[:generator].conversion_type)
294
+ next false if @option_skip_types.include?(gen_info[:generator].conversion_type)
315
295
  # ok we need to generate
316
296
  true
317
297
  end
@@ -444,7 +424,7 @@ module Aspera
444
424
  end
445
425
  Aspera::Preview::FileTypes.instance.use_mimemagic = options.get_option(:mimemagic, mandatory: true)
446
426
  # check tools that are anyway required for all cases
447
- Aspera::Preview::Utils.check_tools(@skip_types)
427
+ Aspera::Preview::Utils.check_tools(@option_skip_types)
448
428
  case command
449
429
  when :scan
450
430
  scan_path = options.get_option(:scan_path)
@@ -491,7 +471,7 @@ module Aspera
491
471
  g = Aspera::Preview::Generator.new(source, generated_file_path, @gen_options, @tmp_folder, nil)
492
472
  g.generate
493
473
  if command.eql?(:show)
494
- terminal_options = options.get_option(:query, default: {}).symbolize_keys
474
+ terminal_options = (options.get_option(:query) || {}).symbolize_keys
495
475
  Log.log.debug{"preview: #{generated_file_path}"}
496
476
  formatter.display_status(Aspera::Preview::Terminal.build(File.read(generated_file_path), **terminal_options))
497
477
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # cspell:ignore ascmd zmode zuid zgid fasping
4
- require 'aspera/cli/basic_auth_plugin'
4
+ require 'aspera/cli/plugins/basic_auth'
5
5
  require 'aspera/cli/sync_actions'
6
6
  require 'aspera/transfer/spec'
7
7
  require 'aspera/ascmd'
@@ -14,7 +14,7 @@ module Aspera
14
14
  module Cli
15
15
  module Plugins
16
16
  # Operations on HSTS with SSH/FASP (ascmd/ascp)
17
- class Server < Cli::BasicAuthPlugin
17
+ class Server < BasicAuth
18
18
  include SyncActions
19
19
 
20
20
  SSH_SCHEME = 'ssh'
@@ -67,27 +67,29 @@ module Aspera
67
67
  raise error if error
68
68
  return
69
69
  end
70
+ end
70
71
 
71
- def wizard(object:)
72
- options = object.options
73
- return {
74
- preset_value: {
75
- url: options.get_option(:url, mandatory: true),
76
- username: options.get_option(:username, mandatory: true),
77
- password: options.get_option(:password, mandatory: true)
78
- },
79
- test_args: 'files br /'
80
- }
81
- end
72
+ # @param wizard [Wizard] The wizard object
73
+ # @param app_url [Wizard] The wizard object
74
+ # @return [Hash] :preset_value, :test_args
75
+ def wizard(wizard, app_url)
76
+ return {
77
+ preset_value: {
78
+ url: app_url,
79
+ username: options.get_option(:username, mandatory: true),
80
+ password: options.get_option(:password, mandatory: true)
81
+ },
82
+ test_args: 'files browse /'
83
+ }
82
84
  end
83
85
 
84
86
  def initialize(**_)
85
87
  super
86
88
  @ssh_opts = {}
87
89
  @connection_type = :ssh
88
- options.declare(:ssh_keys, 'SSH key path list (Array or single)')
90
+ options.declare(:ssh_keys, 'SSH key path list', allowed: Allowed::TYPES_STRING_ARRAY)
89
91
  options.declare(:passphrase, 'SSH private key passphrase')
90
- options.declare(:ssh_options, 'SSH options', types: Hash, handler: {o: self, m: :option_ssh_opts})
92
+ options.declare(:ssh_options, 'SSH options', allowed: Hash, handler: {o: self, m: :option_ssh_opts})
91
93
  SyncActions.declare_options(options)
92
94
  options.parse_options!
93
95
  end
@@ -119,7 +121,7 @@ module Aspera
119
121
  ENV['SSH_CLIENT'] = 'local 0 0'
120
122
  @connection_type = :local
121
123
  return server_transfer_spec
122
- elsif transfer.option_transfer_spec['token'].is_a?(String) && server_uri.scheme.eql?(HTTPS_SCHEME)
124
+ elsif transfer.user_transfer_spec['token'].is_a?(String) && server_uri.scheme.eql?(HTTPS_SCHEME)
123
125
  server_transfer_spec['wss_enabled'] = true
124
126
  server_transfer_spec['wss_port'] = server_uri.port
125
127
  @connection_type = :wss
@@ -152,9 +154,7 @@ module Aspera
152
154
  end
153
155
  ssh_key_list = options.get_option(:ssh_keys)
154
156
  if !ssh_key_list.nil?
155
- ssh_key_list = [ssh_key_list] if ssh_key_list.is_a?(String)
156
- Aspera.assert_type(ssh_key_list, Array){'ssh_keys'}
157
- Aspera.assert(ssh_key_list.all?(String))
157
+ Aspera.assert_array_all(ssh_key_list, String){'ssh_keys'}
158
158
  ssh_key_list.map!{ |p| File.expand_path(p)}
159
159
  Log.log.debug{"SSH keys=#{ssh_key_list}"}
160
160
  if !ssh_key_list.empty?
@@ -171,7 +171,7 @@ module Aspera
171
171
  server_transfer_spec['ssh_private_key_passphrase'] = ssh_passphrase
172
172
  end
173
173
  # if user provided transfer spec has a token, we will use bypass keys
174
- cred_set = true if transfer.option_transfer_spec['token'].is_a?(String)
174
+ cred_set = true if transfer.user_transfer_spec['token'].is_a?(String)
175
175
  Aspera.assert(cred_set, type: BadArgument){'Either password, key , or transfer spec token must be provided'}
176
176
  return server_transfer_spec
177
177
  end
@@ -225,7 +225,7 @@ module Aspera
225
225
  end
226
226
  else Aspera.error_unexpected_value(command_nagios)
227
227
  end
228
- return nagios.result
228
+ Main.result_object_list(nagios.status_list)
229
229
  when *TRANSFER_COMMANDS
230
230
  return execute_transfer(command, server_transfer_spec)
231
231
  when *AsCmd::OPERATIONS