aspera-cli 4.24.1 → 4.24.2

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 (87) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +15 -2
  4. data/README.md +745 -436
  5. data/bin/ascli +20 -1
  6. data/bin/asession +23 -27
  7. data/lib/aspera/agent/base.rb +10 -21
  8. data/lib/aspera/agent/connect.rb +2 -3
  9. data/lib/aspera/agent/desktop.rb +2 -2
  10. data/lib/aspera/agent/direct.rb +49 -32
  11. data/lib/aspera/agent/factory.rb +31 -0
  12. data/lib/aspera/api/aoc.rb +79 -49
  13. data/lib/aspera/api/faspex.rb +212 -0
  14. data/lib/aspera/api/node.rb +99 -84
  15. data/lib/aspera/ascp/installation.rb +22 -21
  16. data/lib/aspera/ascp/management.rb +119 -23
  17. data/lib/aspera/assert.rb +14 -8
  18. data/lib/aspera/cli/extended_value.rb +15 -15
  19. data/lib/aspera/cli/formatter.rb +7 -5
  20. data/lib/aspera/cli/hints.rb +8 -0
  21. data/lib/aspera/cli/info.rb +4 -4
  22. data/lib/aspera/cli/main.rb +55 -70
  23. data/lib/aspera/cli/manager.rb +7 -4
  24. data/lib/aspera/cli/plugins/alee.rb +2 -1
  25. data/lib/aspera/cli/plugins/aoc.rb +110 -186
  26. data/lib/aspera/cli/plugins/ats.rb +4 -4
  27. data/lib/aspera/cli/plugins/base.rb +335 -0
  28. data/lib/aspera/cli/plugins/basic_auth.rb +45 -0
  29. data/lib/aspera/cli/plugins/config.rb +249 -220
  30. data/lib/aspera/cli/plugins/console.rb +15 -15
  31. data/lib/aspera/cli/plugins/cos.rb +2 -2
  32. data/lib/aspera/cli/plugins/factory.rb +78 -0
  33. data/lib/aspera/cli/plugins/faspex.rb +17 -20
  34. data/lib/aspera/cli/plugins/faspex5.rb +79 -193
  35. data/lib/aspera/cli/plugins/faspio.rb +14 -13
  36. data/lib/aspera/cli/plugins/httpgw.rb +13 -12
  37. data/lib/aspera/cli/plugins/node.rb +34 -32
  38. data/lib/aspera/cli/plugins/oauth.rb +48 -0
  39. data/lib/aspera/cli/plugins/orchestrator.rb +15 -13
  40. data/lib/aspera/cli/plugins/preview.rb +4 -4
  41. data/lib/aspera/cli/plugins/server.rb +15 -13
  42. data/lib/aspera/cli/plugins/shares.rb +18 -15
  43. data/lib/aspera/cli/sync_actions.rb +1 -1
  44. data/lib/aspera/cli/transfer_agent.rb +24 -20
  45. data/lib/aspera/cli/transfer_progress.rb +6 -6
  46. data/lib/aspera/cli/version.rb +3 -3
  47. data/lib/aspera/cli/wizard.rb +65 -53
  48. data/lib/aspera/colors.rb +6 -0
  49. data/lib/aspera/command_line_builder.rb +45 -50
  50. data/lib/aspera/command_line_converter.rb +2 -1
  51. data/lib/aspera/coverage.rb +1 -1
  52. data/lib/aspera/data_repository.rb +1 -1
  53. data/lib/aspera/environment.rb +10 -7
  54. data/lib/aspera/faspex_gw.rb +6 -4
  55. data/lib/aspera/faspex_postproc.rb +1 -1
  56. data/lib/aspera/keychain/macos_security.rb +1 -1
  57. data/lib/aspera/log.rb +37 -9
  58. data/lib/aspera/nagios.rb +1 -1
  59. data/lib/aspera/oauth/base.rb +17 -10
  60. data/lib/aspera/oauth/factory.rb +8 -8
  61. data/lib/aspera/oauth/web.rb +2 -2
  62. data/lib/aspera/products/connect.rb +4 -3
  63. data/lib/aspera/products/desktop.rb +1 -4
  64. data/lib/aspera/products/other.rb +9 -1
  65. data/lib/aspera/products/transferd.rb +0 -1
  66. data/lib/aspera/rest.rb +126 -83
  67. data/lib/aspera/ssh.rb +3 -3
  68. data/lib/aspera/sync/args.schema.yaml +46 -3
  69. data/lib/aspera/sync/conf.schema.yaml +130 -94
  70. data/lib/aspera/sync/operations.rb +16 -16
  71. data/lib/aspera/temp_file_manager.rb +17 -5
  72. data/lib/aspera/transfer/error.rb +16 -7
  73. data/lib/aspera/transfer/parameters.rb +34 -20
  74. data/lib/aspera/transfer/resumer.rb +74 -0
  75. data/lib/aspera/transfer/spec.rb +4 -3
  76. data/lib/aspera/transfer/spec.schema.yaml +132 -51
  77. data/lib/aspera/transfer/spec_doc.rb +41 -35
  78. data/lib/aspera/uri_reader.rb +1 -1
  79. data/lib/aspera/web_auth.rb +6 -6
  80. data.tar.gz.sig +0 -0
  81. metadata +9 -7
  82. metadata.gz.sig +0 -0
  83. data/lib/aspera/cli/basic_auth_plugin.rb +0 -43
  84. data/lib/aspera/cli/plugin.rb +0 -333
  85. data/lib/aspera/cli/plugin_factory.rb +0 -81
  86. data/lib/aspera/resumer.rb +0 -77
  87. data/lib/aspera/transfer/error_info.rb +0 -91
@@ -1,12 +1,12 @@
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/nagios'
5
5
 
6
6
  module Aspera
7
7
  module Cli
8
8
  module Plugins
9
- class Console < Cli::BasicAuthPlugin
9
+ class Console < BasicAuth
10
10
  STANDARD_PATH = '/aspera/console'
11
11
  DEFAULT_FILTER_AGE_SECONDS = 24 * 3600
12
12
  EXPR_RE = /\A(\S+) (\S+) (.*)\z/
@@ -44,20 +44,20 @@ module Aspera
44
44
  raise error if error
45
45
  return
46
46
  end
47
+ end
47
48
 
48
- # @param object [Plugin] An instance of this class
49
- # @return [Hash] :preset_value, :test_args
50
- def wizard(object:)
51
- options = object.options
52
- return {
53
- preset_value: {
54
- url: options.get_option(:url, mandatory: true),
55
- username: options.get_option(:username, mandatory: true),
56
- password: options.get_option(:password, mandatory: true)
57
- },
58
- test_args: 'transfer list'
59
- }
60
- end
49
+ # @param wizard [Wizard] The wizard object
50
+ # @param app_url [Wizard] The wizard object
51
+ # @return [Hash] :preset_value, :test_args
52
+ def wizard(wizard, app_url)
53
+ return {
54
+ preset_value: {
55
+ url: app_url,
56
+ username: options.get_option(:username, mandatory: true),
57
+ password: options.get_option(:password, mandatory: true)
58
+ },
59
+ test_args: 'transfer list'
60
+ }
61
61
  end
62
62
 
63
63
  def initialize(**_)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/cli/plugin'
3
+ require 'aspera/cli/plugins/base'
4
4
  require 'aspera/cli/plugins/node'
5
5
  require 'aspera/api/cos_node'
6
6
  require 'aspera/assert'
@@ -8,7 +8,7 @@ require 'aspera/assert'
8
8
  module Aspera
9
9
  module Cli
10
10
  module Plugins
11
- class Cos < Cli::Plugin
11
+ class Cos < Base
12
12
  def initialize(**_)
13
13
  super
14
14
  options.declare(:bucket, 'Bucket name')
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'singleton'
4
+ require 'aspera/assert'
5
+ require 'aspera/cli/error'
6
+ require 'aspera/environment'
7
+
8
+ module Aspera
9
+ module Cli
10
+ # Instantiate plugin from well-known locations
11
+ module Plugins
12
+ class Factory
13
+ include Singleton
14
+
15
+ attr_reader :lookup_folders
16
+
17
+ def initialize
18
+ @lookup_folders = []
19
+ # information on plugins
20
+ @plugins = {}
21
+ end
22
+
23
+ # @return list of registered plugins
24
+ def plugin_list
25
+ @plugins.keys
26
+ end
27
+
28
+ # add a folder to the list of folders to look for plugins
29
+ def add_lookup_folder(folder)
30
+ @lookup_folders.unshift(folder)
31
+ end
32
+
33
+ # find plugins in defined paths
34
+ def add_plugins_from_lookup_folders
35
+ @lookup_folders.each do |folder|
36
+ next unless File.directory?(folder)
37
+ # TODO: add gem root to load path ? and require short folder ?
38
+ # $LOAD_PATH.push(folder) if i[:add_path]
39
+ Dir.entries(folder).each do |source|
40
+ next unless source.end_with?(Environment::RB_EXT)
41
+ path = File.join(folder, source)
42
+ plugin_symbol = File.basename(path, Environment::RB_EXT).to_sym
43
+ next if IGNORE_PLUGINS.include?(plugin_symbol)
44
+ req = path.sub(/#{Environment::RB_EXT}$/o, '')
45
+ Aspera.assert(!@plugins.key?(plugin_symbol), type: :warn){"Plugin already registered: #{plugin_symbol}"}
46
+ @plugins[plugin_symbol] = {source: path, require_stanza: req}
47
+ end
48
+ end
49
+ end
50
+
51
+ # @return path to source file of plugin
52
+ def plugin_source(plugin_name_sym)
53
+ Aspera.assert(@plugins.key?(plugin_name_sym), type: NoSuchElement){"plugin not found: #{plugin_name_sym}"}
54
+ @plugins[plugin_name_sym][:source]
55
+ end
56
+
57
+ # @return Class object for plugin
58
+ def plugin_class(plugin_name_sym)
59
+ Aspera.assert(@plugins.key?(plugin_name_sym), type: NoSuchElement){"plugin not found: #{plugin_name_sym}"}
60
+ require @plugins[plugin_name_sym][:require_stanza]
61
+ # Module.nesting[1] is Aspera::Cli::Plugins
62
+ return Object.const_get("#{Module.nesting[1]}::#{plugin_name_sym.to_s.snake_to_capital}")
63
+ end
64
+
65
+ # Create specified plugin
66
+ # @param plugin_name_sym [Symbol] name of plugin
67
+ # @param args [Hash] arguments to pass to plugin constructor
68
+ def create(plugin_name_sym, **args)
69
+ # TODO: check that ancestor is Plugin?
70
+ plugin_class(plugin_name_sym).new(**args)
71
+ end
72
+
73
+ IGNORE_PLUGINS = %i[factory base basic_auth oauth]
74
+ private_constant :IGNORE_PLUGINS
75
+ end
76
+ end
77
+ end
78
+ end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # cspell:ignore passcode xrds workgroups dmembership wmembership
4
- require 'aspera/cli/basic_auth_plugin'
4
+ require 'aspera/cli/plugins/basic_auth'
5
5
  require 'aspera/cli/plugins/node'
6
- require 'aspera/cli/plugins/config'
7
6
  require 'aspera/cli/extended_value'
8
7
  require 'aspera/cli/special_values'
9
8
  require 'aspera/cli/transfer_agent'
@@ -17,12 +16,11 @@ require 'aspera/log'
17
16
  require 'aspera/assert'
18
17
  require 'xmlsimple'
19
18
  require 'json'
20
- require 'cgi'
21
19
 
22
20
  module Aspera
23
21
  module Cli
24
22
  module Plugins
25
- class Faspex < Cli::BasicAuthPlugin
23
+ class Faspex < BasicAuth
26
24
  # required hash key for source in config
27
25
  KEY_NODE = 'node' # value must be hash with url, username, password
28
26
  KEY_PATH = 'path' # value must be same sub-path as in Faspex's node
@@ -74,20 +72,6 @@ module Aspera
74
72
  return
75
73
  end
76
74
 
77
- # @param object [Plugin] An instance of this class
78
- # @return [Hash] :preset_value, :test_args
79
- def wizard(object:)
80
- options = object.options
81
- return {
82
- preset_value: {
83
- url: options.get_option(:url, mandatory: true),
84
- username: options.get_option(:username, mandatory: true),
85
- password: options.get_option(:password, mandatory: true)
86
- },
87
- test_args: 'me'
88
- }
89
- end
90
-
91
75
  # extract elements from faspex public link
92
76
  def get_link_data(public_url)
93
77
  public_uri = URI.parse(public_url)
@@ -122,6 +106,20 @@ module Aspera
122
106
  end
123
107
  end
124
108
 
109
+ # @param wizard [Wizard] The wizard object
110
+ # @param app_url [Wizard] The wizard object
111
+ # @return [Hash] :preset_value, :test_args
112
+ def wizard(wizard, app_url)
113
+ return {
114
+ preset_value: {
115
+ url: app_url,
116
+ username: options.get_option(:username, mandatory: true),
117
+ password: options.get_option(:password, mandatory: true)
118
+ },
119
+ test_args: 'me'
120
+ }
121
+ end
122
+
125
123
  def initialize(**_)
126
124
  super
127
125
  @api_v3 = nil
@@ -227,8 +225,7 @@ module Aspera
227
225
  # no next link
228
226
  break if link.nil?
229
227
  # replace parameters with the ones from next link
230
- params = CGI.parse(URI.parse(link['href']).query)
231
- mailbox_query = params.keys.each_with_object({}){ |i, m| m[i] = params[i].first}
228
+ mailbox_query = Rest.query_to_h(URI.parse(link['href']).query)
232
229
  Log.log.debug{"query: #{mailbox_query}"}
233
230
  break if !max_pages.nil? && (mailbox_query['page'].to_i > max_pages)
234
231
  end