aspera-cli 4.19.0 → 4.21.1

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 (91) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +46 -0
  4. data/CONTRIBUTING.md +18 -4
  5. data/README.md +886 -510
  6. data/bin/asession +27 -20
  7. data/examples/build_exec +65 -76
  8. data/examples/build_exec_rubyc +40 -0
  9. data/examples/get_proto_file.rb +7 -0
  10. data/lib/aspera/agent/alpha.rb +18 -24
  11. data/lib/aspera/agent/base.rb +2 -18
  12. data/lib/aspera/agent/connect.rb +34 -15
  13. data/lib/aspera/agent/direct.rb +44 -54
  14. data/lib/aspera/agent/httpgw.rb +2 -3
  15. data/lib/aspera/agent/node.rb +11 -21
  16. data/lib/aspera/agent/{trsdk.rb → transferd.rb} +27 -51
  17. data/lib/aspera/api/alee.rb +15 -0
  18. data/lib/aspera/api/aoc.rb +139 -105
  19. data/lib/aspera/api/ats.rb +1 -1
  20. data/lib/aspera/api/cos_node.rb +1 -1
  21. data/lib/aspera/api/httpgw.rb +15 -10
  22. data/lib/aspera/api/node.rb +70 -32
  23. data/lib/aspera/ascmd.rb +56 -48
  24. data/lib/aspera/ascp/installation.rb +166 -70
  25. data/lib/aspera/ascp/management.rb +30 -8
  26. data/lib/aspera/assert.rb +10 -5
  27. data/lib/aspera/cli/formatter.rb +166 -162
  28. data/lib/aspera/cli/hints.rb +2 -1
  29. data/lib/aspera/cli/info.rb +12 -10
  30. data/lib/aspera/cli/main.rb +28 -13
  31. data/lib/aspera/cli/manager.rb +7 -2
  32. data/lib/aspera/cli/plugin.rb +17 -31
  33. data/lib/aspera/cli/plugins/alee.rb +3 -3
  34. data/lib/aspera/cli/plugins/aoc.rb +246 -208
  35. data/lib/aspera/cli/plugins/ats.rb +16 -14
  36. data/lib/aspera/cli/plugins/config.rb +154 -94
  37. data/lib/aspera/cli/plugins/console.rb +3 -3
  38. data/lib/aspera/cli/plugins/cos.rb +1 -0
  39. data/lib/aspera/cli/plugins/faspex.rb +15 -23
  40. data/lib/aspera/cli/plugins/faspex5.rb +64 -50
  41. data/lib/aspera/cli/plugins/faspio.rb +2 -2
  42. data/lib/aspera/cli/plugins/httpgw.rb +1 -1
  43. data/lib/aspera/cli/plugins/node.rb +174 -109
  44. data/lib/aspera/cli/plugins/orchestrator.rb +14 -13
  45. data/lib/aspera/cli/plugins/preview.rb +8 -9
  46. data/lib/aspera/cli/plugins/server.rb +5 -9
  47. data/lib/aspera/cli/plugins/shares.rb +2 -2
  48. data/lib/aspera/cli/sync_actions.rb +2 -2
  49. data/lib/aspera/cli/transfer_agent.rb +12 -14
  50. data/lib/aspera/cli/transfer_progress.rb +37 -17
  51. data/lib/aspera/cli/version.rb +1 -1
  52. data/lib/aspera/command_line_builder.rb +4 -5
  53. data/lib/aspera/coverage.rb +13 -1
  54. data/lib/aspera/environment.rb +75 -25
  55. data/lib/aspera/faspex_gw.rb +2 -2
  56. data/lib/aspera/json_rpc.rb +1 -1
  57. data/lib/aspera/keychain/macos_security.rb +7 -12
  58. data/lib/aspera/log.rb +3 -4
  59. data/lib/aspera/node_simulator.rb +230 -112
  60. data/lib/aspera/oauth/base.rb +64 -83
  61. data/lib/aspera/oauth/factory.rb +52 -6
  62. data/lib/aspera/oauth/generic.rb +4 -8
  63. data/lib/aspera/oauth/jwt.rb +6 -3
  64. data/lib/aspera/oauth/url_json.rb +1 -2
  65. data/lib/aspera/oauth/web.rb +5 -2
  66. data/lib/aspera/persistency_action_once.rb +16 -8
  67. data/lib/aspera/persistency_folder.rb +20 -2
  68. data/lib/aspera/preview/generator.rb +1 -1
  69. data/lib/aspera/preview/utils.rb +11 -17
  70. data/lib/aspera/products/alpha.rb +30 -0
  71. data/lib/aspera/products/connect.rb +48 -0
  72. data/lib/aspera/products/other.rb +82 -0
  73. data/lib/aspera/products/transferd.rb +54 -0
  74. data/lib/aspera/rest.rb +116 -87
  75. data/lib/aspera/secret_hider.rb +2 -2
  76. data/lib/aspera/ssh.rb +31 -24
  77. data/lib/aspera/transfer/faux_file.rb +4 -4
  78. data/lib/aspera/transfer/parameters.rb +16 -17
  79. data/lib/aspera/transfer/spec.rb +12 -12
  80. data/lib/aspera/transfer/spec.yaml +22 -20
  81. data/lib/aspera/transfer/sync.rb +2 -10
  82. data/lib/aspera/transfer/uri.rb +3 -3
  83. data/lib/aspera/uri_reader.rb +1 -1
  84. data/lib/aspera/web_auth.rb +166 -17
  85. data/lib/aspera/web_server_simple.rb +4 -3
  86. data/lib/transferd_pb.rb +86 -0
  87. data/lib/transferd_services_pb.rb +84 -0
  88. data.tar.gz.sig +0 -0
  89. metadata +58 -22
  90. metadata.gz.sig +0 -0
  91. data/lib/aspera/ascp/products.rb +0 -156
@@ -24,10 +24,7 @@ module Aspera
24
24
 
25
25
  class << self
26
26
  def declare_generic_options(options)
27
- options.declare(:query, 'Additional filter for for some commands (list/delete)', types: Hash)
28
- options.declare(
29
- :value, 'Value for create, update, list filter', types: Hash,
30
- deprecation: '(4.14) Use positional value for create/modify or option: query for list/delete')
27
+ options.declare(:query, 'Additional filter for for some commands (list/delete)', types: [Hash, Array])
31
28
  options.declare(:property, 'Name of property to set (modify operation)')
32
29
  options.declare(:bulk, 'Bulk operation (only some)', values: :bool, default: :no)
33
30
  options.declare(:bfail, 'Bulk operation error handling', values: :bool, default: :yes)
@@ -36,21 +33,25 @@ module Aspera
36
33
 
37
34
  attr_accessor(*INIT_PARAMS)
38
35
 
39
- def initialize(options:, transfer:, config:, formatter:, persistency:, only_manual:)
36
+ def initialize(options:, transfer:, config:, formatter:, persistency:, only_manual:, man_header: true)
37
+ # check presence in descendant of mandatory method and constant
38
+ Aspera.assert(respond_to?(:execute_action)){"Missing method 'execute_action' in #{self.class}"}
39
+ Aspera.assert(self.class.constants.include?(:ACTIONS)){"Missing constant 'ACTIONS' in #{self.class}"}
40
40
  @options = options
41
41
  @transfer = transfer
42
42
  @config = config
43
43
  @formatter = formatter
44
44
  @persistency = persistency
45
45
  @only_manual = only_manual
46
- # check presence in descendant of mandatory method and constant
47
- Aspera.assert(respond_to?(:execute_action)){"Missing method 'execute_action' in #{self.class}"}
48
- Aspera.assert(self.class.constants.include?(:ACTIONS)){'ACTIONS shall be redefined by subclass'}
46
+ add_manual_header if man_header
47
+ end
48
+
49
+ def add_manual_header(has_options = true)
49
50
  # manual header for all plugins
50
51
  options.parser.separator('')
51
52
  options.parser.separator("COMMAND: #{self.class.name.split('::').last.downcase}")
52
53
  options.parser.separator("SUBCOMMANDS: #{self.class.const_get(:ACTIONS).map(&:to_s).sort.join(' ')}")
53
- options.parser.separator('OPTIONS:')
54
+ options.parser.separator('OPTIONS:') if has_options
54
55
  end
55
56
 
56
57
  # @return a hash of instance variables
@@ -156,7 +157,7 @@ module Aspera
156
157
  when :create
157
158
  raise 'cannot create singleton' if is_singleton
158
159
  return do_bulk_operation(command: command, descr: 'data', fields: display_fields) do |params|
159
- rest_api.create(res_class_path, params)[:data]
160
+ rest_api.create(res_class_path, params)
160
161
  end
161
162
  when :delete
162
163
  raise 'cannot delete singleton' if is_singleton
@@ -171,9 +172,9 @@ module Aspera
171
172
  {'id' => one_id}
172
173
  end
173
174
  when :show
174
- return {type: :single_object, data: rest_api.read(one_res_path)[:data], fields: display_fields}
175
+ return {type: :single_object, data: rest_api.read(one_res_path), fields: display_fields}
175
176
  when :list
176
- resp = rest_api.read(res_class_path, query_read_delete)
177
+ resp = rest_api.call(operation: 'GET', subpath: res_class_path, headers: {'Accept' => 'application/json'}, query: query_read_delete)
177
178
  return Main.result_empty if resp[:http].code == '204'
178
179
  data = resp[:data]
179
180
  # TODO: not generic : which application is this for ?
@@ -214,45 +215,30 @@ module Aspera
214
215
  return entity_command(command, rest_api, res_class_path, **opts, &block)
215
216
  end
216
217
 
217
- # query parameters in URL suitable for REST list/GET and delete/DELETE
218
+ # query parameters in URL suitable for REST: list/GET and delete/DELETE
218
219
  def query_read_delete(default: nil)
219
220
  query = options.get_option(:query)
220
221
  # dup default, as it could be frozen
221
222
  query = default.dup if query.nil?
222
- Log.log.debug{"Query=#{query}".bg_red}
223
+ Log.log.debug{"query_read_delete=#{query}".bg_red}
223
224
  begin
224
225
  # check it is suitable
225
226
  URI.encode_www_form(query) unless query.nil?
226
227
  rescue StandardError => e
227
- raise Cli::BadArgument, "Query must be an extended value which can be encoded with URI.encode_www_form. Refer to manual. (#{e.message})"
228
+ raise Cli::BadArgument, "Query must be an extended value (Hash, Array) which can be encoded with URI.encode_www_form. Refer to manual. (#{e.message})"
228
229
  end
229
230
  return query
230
231
  end
231
232
 
232
- # TODO: when deprecation of `value` is completed: remove this method, replace with options.get_option(:query)
233
- # deprecation: 4.14
234
- def query_option(mandatory: false, default: nil)
235
- option = :value
236
- value = options.get_option(option, mandatory: false)
237
- if value.nil?
238
- option = :query
239
- value = options.get_option(option, mandatory: mandatory, default: default)
240
- end
241
- return value
242
- end
243
-
244
233
  # Retrieves an extended value from command line, used for creation or modification of entities
245
234
  # @param command [Symbol] command name for error message
246
235
  # @param type [Class] expected type of value, either a Class, an Array of Class
247
236
  # @param bulk [Boolean] if true, value must be an Array of <type>
248
237
  # @param default [Object] default value if not provided
249
- # TODO: when deprecation of `value` is completed: remove line with :value
250
238
  def value_create_modify(command:, description: nil, type: Hash, bulk: false, default: nil)
251
- value = options.get_option(:value)
252
- Log.log.warn("option `value` is deprecated. Use positional parameter for #{command}") unless value.nil?
253
239
  value = options.get_next_argument(
254
240
  "parameters for #{command}#{description.nil? ? '' : " (#{description})"}", mandatory: default.nil?,
255
- validation: bulk ? Array : type) if value.nil?
241
+ validation: bulk ? Array : type)
256
242
  value = default if value.nil?
257
243
  unless type.nil?
258
244
  type = [type] unless type.is_a?(Array)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/api/aoc'
3
+ require 'aspera/api/alee'
4
4
  require 'aspera/nagios'
5
5
 
6
6
  module Aspera
@@ -16,7 +16,7 @@ module Aspera
16
16
  nagios = Nagios.new
17
17
  begin
18
18
  api = Api::Alee.new(nil, nil, version: 'ping')
19
- result = api.call(operation: 'GET', subpath: '')
19
+ result = api.call(operation: 'GET')
20
20
  raise "unexpected response: #{result[:http].body}" unless result[:http].body.eql?('pong')
21
21
  nagios.add_ok('api', 'answered ok')
22
22
  rescue StandardError => e
@@ -27,7 +27,7 @@ module Aspera
27
27
  entitlement_id = options.get_option(:username, mandatory: true)
28
28
  customer_id = options.get_option(:password, mandatory: true)
29
29
  api_metering = Api::Alee.new(entitlement_id, customer_id)
30
- return {type: :single_object, data: api_metering.read('entitlement')[:data]}
30
+ return {type: :single_object, data: api_metering.read('entitlement')}
31
31
  end
32
32
  end
33
33
  end