aspera-cli 4.12.0 → 4.13.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +17 -0
  4. data/CONTRIBUTING.md +97 -22
  5. data/README.md +548 -394
  6. data/bin/ascli +3 -3
  7. data/docs/test_env.conf +12 -5
  8. data/lib/aspera/aoc.rb +42 -42
  9. data/lib/aspera/ascmd.rb +4 -3
  10. data/lib/aspera/cli/extended_value.rb +24 -37
  11. data/lib/aspera/cli/formatter.rb +6 -0
  12. data/lib/aspera/cli/info.rb +2 -4
  13. data/lib/aspera/cli/main.rb +6 -0
  14. data/lib/aspera/cli/manager.rb +15 -6
  15. data/lib/aspera/cli/plugin.rb +1 -5
  16. data/lib/aspera/cli/plugins/aoc.rb +23 -6
  17. data/lib/aspera/cli/plugins/config.rb +13 -6
  18. data/lib/aspera/cli/plugins/faspex.rb +4 -3
  19. data/lib/aspera/cli/plugins/faspex5.rb +175 -42
  20. data/lib/aspera/cli/plugins/node.rb +107 -50
  21. data/lib/aspera/cli/plugins/preview.rb +3 -3
  22. data/lib/aspera/cli/plugins/server.rb +11 -1
  23. data/lib/aspera/cli/plugins/sync.rb +3 -3
  24. data/lib/aspera/cli/transfer_agent.rb +24 -10
  25. data/lib/aspera/cli/version.rb +2 -1
  26. data/lib/aspera/command_line_builder.rb +2 -1
  27. data/lib/aspera/cos_node.rb +1 -1
  28. data/lib/aspera/fasp/agent_connect.rb +1 -1
  29. data/lib/aspera/fasp/agent_direct.rb +12 -12
  30. data/lib/aspera/fasp/agent_node.rb +14 -4
  31. data/lib/aspera/fasp/installation.rb +1 -0
  32. data/lib/aspera/fasp/parameters.rb +11 -3
  33. data/lib/aspera/fasp/parameters.yaml +3 -1
  34. data/lib/aspera/fasp/transfer_spec.rb +3 -1
  35. data/lib/aspera/faspex_gw.rb +1 -0
  36. data/lib/aspera/faspex_postproc.rb +2 -2
  37. data/lib/aspera/node.rb +11 -4
  38. data/lib/aspera/oauth.rb +3 -2
  39. data/lib/aspera/preview/file_types.rb +8 -6
  40. data/lib/aspera/preview/generator.rb +23 -11
  41. data/lib/aspera/preview/options.rb +3 -2
  42. data/lib/aspera/preview/terminal.rb +34 -0
  43. data/lib/aspera/preview/utils.rb +8 -8
  44. data/lib/aspera/rest.rb +5 -4
  45. data/lib/aspera/rest_call_error.rb +3 -1
  46. data/lib/aspera/secret_hider.rb +4 -4
  47. data/lib/aspera/sync.rb +39 -33
  48. data/lib/aspera/web_server_simple.rb +22 -18
  49. data.tar.gz.sig +0 -0
  50. metadata +39 -46
  51. metadata.gz.sig +0 -0
  52. data/examples/aoc.rb +0 -30
  53. data/examples/faspex4.rb +0 -94
  54. data/examples/node.rb +0 -96
  55. data/examples/server.rb +0 -93
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aspera-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.0
4
+ version: 4.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Martin
@@ -10,32 +10,34 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIEeDCCAuCgAwIBAgIBATANBgkqhkiG9w0BAQsFADA0MTIwMAYDVQQDDClsYXVy
14
- ZW50Lm1hcnRpbi5hc3BlcmEvREM9ZnIvREM9aWJtL0RDPWNvbTAeFw0yMjA2MTUy
15
- MzQ5NDdaFw0yMzA2MTUyMzQ5NDdaMDQxMjAwBgNVBAMMKWxhdXJlbnQubWFydGlu
16
- LmFzcGVyYS9EQz1mci9EQz1pYm0vREM9Y29tMIIBojANBgkqhkiG9w0BAQEFAAOC
17
- AY8AMIIBigKCAYEAn4dpdgpX97n2d+jsdQFBlvCLpWluceH+0bJ/UfGEm+3m5nwW
18
- Y3TfdcxT45QytqA0cQXu8FeiybkZxSclTK0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CSN
26
+ j35/BUkRFmkKzGkAoyo7DvgZQFg8qoXYQw2HQhL9Bnhh+souo72gLgHnIYtuK0Y3
27
+ AgMBAAGjgZQwgZEwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFPZD
28
+ HBRnWTjzjeZq3Sx/yv7hhY9rMCsGA1UdEQQkMCKBIGxhdXJlbnQubWFydGluLmFz
29
+ cGVyYUBmci5pYm0uY29tMCsGA1UdEgQkMCKBIGxhdXJlbnQubWFydGluLmFzcGVy
30
+ YUBmci5pYm0uY29tMA0GCSqGSIb3DQEBCwUAA4IBgQCtbncBw6IjRWDjiaeH6gmQ
31
+ GrfPX53oAJOMnyjhhgKfLd/PPJIckCxz/Tscsuq9+ZUDTubz2E3ltycdxrz0OOul
32
+ M8cWfkJ4cvdGAGTtqhmv3GGWZwFN8V8WYmmXrgej4o33vx6o8B6uwBn38hvkkAlB
33
+ ixQDORrk0ck1GVUYYo2UmDOlqArf6paaqd7rziY0dntYl0DfFWe7eJYA467FKjM6
34
+ /V3L2mTuHg4nCqC2febbAG+W+n158UrEkIKoOpAvQsykuuRtMaTpSTnYd0kLtQIF
35
+ qNyjadnjZB8iMIedYmEOKApKUJS/9BN1iXHxVbL03AS4o5xMQO3PPjXcwwaybE8G
36
+ sqAiwQUoawi1m3fZ8u3Xx+GmWE7tE9oxnPA48Y44EkiiWozq263f4S2Xa449ODoh
37
+ eTf9kxhVM40wGQOECVNA8UsEEZHD48eF+csUYZtAJOF5oxTI8UyV9T/o6CgO0c9/
38
+ Gzz+Qm5ULOUcPiJLjSpaiTrkiIVYiDGnqNSr6R1Hb1c=
37
39
  -----END CERTIFICATE-----
38
- date: 2023-03-20 00:00:00.000000000 Z
40
+ date: 2023-06-28 00:00:00.000000000 Z
39
41
  dependencies:
40
42
  - !ruby/object:Gem::Dependency
41
43
  name: execjs
@@ -69,36 +71,30 @@ dependencies:
69
71
  name: net-smtp
70
72
  requirement: !ruby/object:Gem::Requirement
71
73
  requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0.1'
75
- - - "<"
74
+ - - "~>"
76
75
  - !ruby/object:Gem::Version
77
- version: '0.4'
76
+ version: '0.3'
78
77
  type: :runtime
79
78
  prerelease: false
80
79
  version_requirements: !ruby/object:Gem::Requirement
81
80
  requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: '0.1'
85
- - - "<"
81
+ - - "~>"
86
82
  - !ruby/object:Gem::Version
87
- version: '0.4'
83
+ version: '0.3'
88
84
  - !ruby/object:Gem::Dependency
89
85
  name: net-ssh
90
86
  requirement: !ruby/object:Gem::Requirement
91
87
  requirements:
92
- - - ">="
88
+ - - "~>"
93
89
  - !ruby/object:Gem::Version
94
- version: '6.0'
90
+ version: '7.0'
95
91
  type: :runtime
96
92
  prerelease: false
97
93
  version_requirements: !ruby/object:Gem::Requirement
98
94
  requirements:
99
- - - ">="
95
+ - - "~>"
100
96
  - !ruby/object:Gem::Version
101
- version: '6.0'
97
+ version: '7.0'
102
98
  - !ruby/object:Gem::Dependency
103
99
  name: ruby-progressbar
104
100
  requirement: !ruby/object:Gem::Requirement
@@ -367,12 +363,8 @@ files:
367
363
  - bin/ascli
368
364
  - bin/asession
369
365
  - docs/test_env.conf
370
- - examples/aoc.rb
371
366
  - examples/dascli
372
- - examples/faspex4.rb
373
- - examples/node.rb
374
367
  - examples/proxy.pac
375
- - examples/server.rb
376
368
  - lib/aspera/aoc.rb
377
369
  - lib/aspera/ascmd.rb
378
370
  - lib/aspera/ats_api.rb
@@ -448,6 +440,7 @@ files:
448
440
  - lib/aspera/preview/generator.rb
449
441
  - lib/aspera/preview/image_error.png
450
442
  - lib/aspera/preview/options.rb
443
+ - lib/aspera/preview/terminal.rb
451
444
  - lib/aspera/preview/utils.rb
452
445
  - lib/aspera/preview/video_error.png
453
446
  - lib/aspera/proxy_auto_config.js
@@ -482,7 +475,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
482
475
  requirements:
483
476
  - - ">="
484
477
  - !ruby/object:Gem::Version
485
- version: '2.4'
478
+ version: '2.6'
486
479
  required_rubygems_version: !ruby/object:Gem::Requirement
487
480
  requirements:
488
481
  - - ">="
@@ -490,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
490
483
  version: '0'
491
484
  requirements:
492
485
  - Read the manual for any requirement
493
- rubygems_version: 3.4.6
486
+ rubygems_version: 3.4.10
494
487
  signing_key:
495
488
  specification_version: 4
496
489
  summary: 'Execute actions using command line on IBM Aspera Server products: Aspera
metadata.gz.sig CHANGED
Binary file
data/examples/aoc.rb DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'aspera/aoc'
5
- require 'aspera/log'
6
-
7
- Aspera::Log.instance.level = :debug
8
-
9
- if !ARGV.length.eql?(3)
10
- Aspera::Log.log.error{"wrong number of args: #{ARGV.length}"}
11
- Aspera::Log.log.error{"Usage: #{$PROGRAM_NAME} <aoc URL> <aoc username> <aoc private key content>"}
12
- Aspera::Log.log.error{"Example: #{$PROGRAM_NAME} https://myorg.ibmaspera.com john@example.com $(cat /home/john/my_key.pem)"}
13
- Process.exit(1)
14
- end
15
-
16
- aoc_url = ARGV[0]
17
- aoc_user = ARGV[1]
18
- aoc_key_value = ARGV[2]
19
-
20
- aoc_api = Aspera::AoC.new(
21
- url: aoc_url,
22
- auth: :jwt,
23
- private_key: aoc_key_value,
24
- username: aoc_user,
25
- scope: 'user:all',
26
- subpath: 'api/v1')
27
-
28
- self_user_data = aoc_api.read('self')
29
-
30
- Aspera::Log.dump('self', self_user_data)
data/examples/faspex4.rb DELETED
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # find Faspex API here: https://developer.ibm.com/apis/catalog/?search=faspex
5
- # this example makes use of class Aspera::Rest for REST calls, alternatively class RestClient of gem rest-client could be used
6
- # this example makes use of class Aspera::Fasp::AgentDirect for transfers, alternatively the official "Transfer SDK" could be used
7
- # Aspera SDK can be downloaded with: `ascli conf ascp install` , it installs in $HOME/.aspera/ascli/sdk
8
- require 'aspera/rest'
9
- require 'aspera/log'
10
- require 'aspera/fasp/agent_direct'
11
-
12
- tmpdir = ENV['tmp'] || Dir.tmpdir || '.'
13
-
14
- # Set high log level for the example, decrease to :warn usually
15
- Aspera::Log.instance.level = :debug
16
-
17
- # Set folder where SDK is installed (mandatory)
18
- # (if ascp is not there, the lib will try to find in usual locations)
19
- # (if data files are not there, they will be created)
20
- Aspera::Fasp::Installation.instance.folder = tmpdir
21
-
22
- if !ARGV.length.eql?(3)
23
- Aspera::Log.log.error{"Wrong number of args: #{ARGV.length}"}
24
- Aspera::Log.log.error{"Usage: #{$PROGRAM_NAME} <faspex URL> <faspex username> <faspex password>"}
25
- Aspera::Log.log.error{"Example: #{$PROGRAM_NAME} https://faspex.com/aspera/faspex john p@sSw0rd"}
26
- Process.exit(1)
27
- end
28
-
29
- faspex_url = ARGV[0] # typically: https://faspex.example.com/aspera/faspex
30
- faspex_user = ARGV[1]
31
- faspex_pass = ARGV[2]
32
-
33
- # uncomment this if certificate is self signed
34
- # Rest.session_cb = lambda{|http|http.verify_mode = OpenSSL::SSL::VERIFY_NONE}
35
-
36
- # 1: Faspex 4 API v3
37
- #---------------
38
-
39
- # create REST API object
40
- api_v3 = Aspera::Rest.new({
41
- base_url: faspex_url,
42
- auth: {
43
- type: :basic,
44
- username: faspex_user,
45
- password: faspex_pass
46
- }})
47
-
48
- # very simple api call
49
- api_v3.read('me')
50
-
51
- # 2: send a package
52
- #---------------
53
-
54
- # create a sample file to send
55
- file_to_send = File.join(tmpdir, 'myfile.bin')
56
- File.write(file_to_send, 'sample data')
57
- # package creation parameters
58
- package_create_params = {'delivery' => {
59
- 'title' => 'test package',
60
- 'recipients' => ['aspera.user1@gmail.com'],
61
- 'sources' => [{'paths' => [file_to_send]}]
62
- }}
63
- pkg_created = api_v3.create('send', package_create_params)[:data]
64
- # get transfer specification (normally: only one)
65
- transfer_spec = pkg_created['xfer_sessions'].first
66
- # set paths of files to send
67
- transfer_spec['paths'] = [{'source' => file_to_send}]
68
- # get local agent (ascp), disable ascp output on stdout to not mix with JSON events
69
- transfer_client = Aspera::Fasp::AgentDirect.new({quiet: true})
70
- # start transfer (asynchronous)
71
- job_id = transfer_client.start_transfer(transfer_spec)
72
- Aspera::Log.dump('job_id', job_id)
73
- # wait for all transfer completion (for the example)
74
- result = transfer_client.wait_for_transfers_completion
75
- # notify of any transfer error
76
- result.reject{|i|i.eql?(:success)}.each do |e|
77
- Aspera::Log.log.error{"A transfer error occurred: #{e.message}"}
78
- end
79
-
80
- # 3: Faspex 4 API v4
81
- #---------------
82
- api_v4 = Aspera::Rest.new({
83
- base_url: faspex_url + '/api',
84
- auth: {
85
- type: :oauth2,
86
- base_url: faspex_url + '/auth/oauth2',
87
- auth: {type: :basic, username: faspex_user, password: faspex_pass},
88
- grant_method: :generic,
89
- generic: {grant_type: 'password'},
90
- scope: 'admin'
91
- }})
92
-
93
- # Use it. Note that Faspex 4 API v4 is totally different from Faspex 4 v3 APIs, see ref in header
94
- Aspera::Log.dump('users', api_v4.read('users')[:data])
data/examples/node.rb DELETED
@@ -1,96 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # Example: transfer a file using one of the provided transfer agents
5
- # location of ascp can be specified with env var "ascp"
6
- # temp folder can be specified with env var "tmp"
7
- require 'aspera/fasp/agent_direct'
8
- require 'aspera/fasp/listener'
9
- require 'aspera/fasp/installation'
10
- require 'aspera/log'
11
- require 'aspera/rest'
12
- require 'aspera/rest_errors_aspera'
13
- require 'json'
14
- require 'tmpdir'
15
-
16
- tmpdir = ENV['tmp'] || Dir.tmpdir || '.'
17
-
18
- raise 'Usage: PASSWORD=<password> $0 https://<address>:<port> <node user>' unless ARGV.length.eql?(2) && ENV.key?('PASSWORD')
19
-
20
- # example : https://node_asperaweb@eudemo.asperademo.com:9092
21
- node_uri = URI.parse(ARGV.shift)
22
- node_user = ARGV.shift
23
- node_pass = ENV['PASSWORD']
24
-
25
- ##############################################################
26
- # generic initialization : configuration of FaspManager
27
-
28
- # set trace level for sample, set to :debug to see complete list of debug information
29
- Aspera::Log.instance.level = :debug
30
-
31
- # register aspera REST call error handlers
32
- Aspera::RestErrorsAspera.register_handlers
33
-
34
- # some required files are generated here (keys, certs)
35
- Aspera::Fasp::Installation.instance.folder = tmpdir
36
- # set path to your copy of ascp binary (else, let the system find)
37
- Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.key?('ascp')
38
- # another way is to detect installed products and use one of them
39
- # Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
40
- # Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
41
- # or install:
42
- #
43
-
44
- # get Transfer Agent
45
- transfer_agent = Aspera::Fasp::AgentDirect.new
46
-
47
- # Note that it would also be possible to start transfers using other agents
48
- # require 'aspera/fasp/connect'
49
- # transfer_agent=Aspera::Fasp::Connect.new
50
- # require 'aspera/fasp/node'
51
- # transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
52
-
53
- ##############################################################
54
- # Optional : register an event listener
55
-
56
- # example of event listener that displays events on stdout
57
- class MyListener < Aspera::Fasp::Listener
58
- # this is the callback called during transfers, here we only display the received information
59
- # but it could be used to get detailed error information, check "type" field is "ERROR"
60
- def event_enhanced(data); $stdout.puts(JSON.generate(data)); $stdout.flush; end # rubocop:disable Style/Semicolon
61
- end
62
-
63
- # register the sample listener to display events
64
- transfer_agent.add_listener(MyListener.new)
65
-
66
- ##############################################################
67
- # Upload with node authorization
68
-
69
- # create rest client for Node API on a public demo system, using public demo credentials
70
- node_api = Aspera::Rest.new({
71
- base_url: node_uri.to_s,
72
- auth: {
73
- type: :basic,
74
- username: node_user,
75
- password: node_pass
76
- }})
77
- # define sample file(s) and destination folder
78
- sources = ["#{tmpdir}/sample_file.txt"]
79
- destination = '/Upload'
80
- # create sample file(s)
81
- sources.each{|p|File.write(p, 'Hello World!')}
82
- # request transfer authorization to node for a single transfer (This is a node api v3 call)
83
- send_result = node_api.create('files/upload_setup', { transfer_requests: [{ transfer_request: { paths: [{ destination: destination }] } }] })[:data]
84
- # we normally have only one transfer spec in list, so just get the first transfer_spec
85
- transfer_spec = send_result['transfer_specs'].first['transfer_spec']
86
- # add list of files to upload
87
- transfer_spec['paths'] = sources.map{|p|{'source' => p}}
88
- # set authentication type to "token" (will trigger use of bypass SSH key)
89
- transfer_spec['authentication'] = 'token'
90
- # from here : same as example 1
91
- transfer_agent.start_transfer(transfer_spec)
92
- # optional: wait for transfer completion helper function to get events
93
- transfer_result = transfer_agent.wait_for_transfers_completion
94
- errors = transfer_result.reject{|i|i.eql?(:success)}
95
- # the transfer was not success, as there is at least one error
96
- raise "Error(s) occurred: #{errors.join(',')}" if !errors.empty?
data/examples/server.rb DELETED
@@ -1,93 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # Example: transfer a file using one of the provided transfer agents
5
- # location of ascp can be specified with env var "ascp"
6
- # temp folder can be specified with env var "tmp"
7
- require 'aspera/fasp/agent_direct'
8
- require 'aspera/fasp/listener'
9
- require 'aspera/fasp/installation'
10
- require 'aspera/log'
11
- require 'aspera/rest'
12
- require 'aspera/rest_errors_aspera'
13
- require 'json'
14
- require 'tmpdir'
15
-
16
- tmpdir = ENV['tmp'] || Dir.tmpdir || '.'
17
-
18
- raise 'Usage: PASSWORD=<password> $0 ssh://<address>:<port> <transfer user>' unless ARGV.length.eql?(2) && ENV.key?('PASSWORD')
19
-
20
- # example : ssh://asperaweb@eudemo.asperademo.com:33001
21
- server_uri = URI.parse(ARGV.shift)
22
- server_user = ARGV.shift
23
- server_pass = ENV['PASSWORD']
24
-
25
- ##############################################################
26
- # generic initialization : configuration of FaspManager
27
-
28
- # set trace level for sample, set to :debug to see complete list of debug information
29
- Aspera::Log.instance.level = :debug
30
-
31
- # register aspera REST call error handlers
32
- Aspera::RestErrorsAspera.register_handlers
33
-
34
- # some required files are generated here (keys, certs)
35
- Aspera::Fasp::Installation.instance.folder = tmpdir
36
- # set path to your copy of ascp binary (else, let the system find)
37
- Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.key?('ascp')
38
- # another way is to detect installed products and use one of them
39
- # Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
40
- # Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
41
- # or install:
42
- #
43
-
44
- # get Transfer Agent
45
- transfer_agent = Aspera::Fasp::AgentDirect.new
46
-
47
- # Note that it would also be possible to start transfers using other agents
48
- # require 'aspera/fasp/connect'
49
- # transfer_agent=Aspera::Fasp::Connect.new
50
- # require 'aspera/fasp/node'
51
- # transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
52
-
53
- ##############################################################
54
- # Optional : register an event listener
55
-
56
- # example of event listener that displays events on stdout
57
- class MyListener < Aspera::Fasp::Listener
58
- # this is the callback called during transfers, here we only display the received information
59
- # but it could be used to get detailed error information, check "type" field is "ERROR"
60
- def event_enhanced(data); $stdout.puts(JSON.generate(data)); $stdout.flush; end # rubocop:disable Style/Semicolon
61
- end
62
-
63
- # register the sample listener to display events
64
- transfer_agent.add_listener(MyListener.new)
65
-
66
- ##############################################################
67
- # first example: download by SSH credentials
68
-
69
- # manually build transfer spec
70
- transfer_spec = {
71
- 'remote_host' => server_uri.host,
72
- 'ssh_port' => server_uri.port,
73
- 'remote_user' => server_user,
74
- 'remote_password' => server_pass,
75
- 'direction' => 'receive',
76
- 'destination_root' => tmpdir,
77
- 'paths' => [{'source' => 'aspera-test-dir-tiny/200KB.1'}]
78
- }
79
- # start transfer in separate thread
80
- # method returns as soon as transfer thread is created
81
- # it des not wait for completion, or even for session startup
82
- transfer_agent.start_transfer(transfer_spec)
83
-
84
- # optional: helper method: wait for completion of transfers
85
- # here we started a single transfer session (no multi session parameter)
86
- # get array of status, one for each session (so, a single value array)
87
- # each status is either :success or "error message"
88
- transfer_result = transfer_agent.wait_for_transfers_completion
89
- $stdout.puts(JSON.generate(transfer_result))
90
- # get list of errors only
91
- errors = transfer_result.reject{|i|i.eql?(:success)}
92
- # the transfer was not success, as there is at least one error
93
- raise "Error(s) occurred: #{errors.join(',')}" if !errors.empty?