asperalm 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0062d5e2d6853ff55feb94b3b43422b1af7315e0fed5a5562a054b2a5fb37372
4
- data.tar.gz: 8f05d719fde7dd6cbfc931f5fdd8a30a3da54ee3fe8837ef61b58053c286c2f1
3
+ metadata.gz: 050a8ebf038713fb21e118397726b14927a1d7d7bb24b836ebd8aab6951081f3
4
+ data.tar.gz: 3574427b4fc27bac85d6031e2334e8957f2161f7cebb8820f9d653f11214e874
5
5
  SHA512:
6
- metadata.gz: 936c22702cf3fd979d386cf84283ed71854e8b4377929a14bc2310b282bc9d00d3c53638478efa9dfd33a720e0816c74f1337823091e5fa627d0a36f91b6cc71
7
- data.tar.gz: 2880417947b50e288c47e9969b690f21a11a9bf76f16f6561ad9491ff48c45fbf205fc5a3031c07237ebcbd2b7098851121f2293312cd041de41d797e24fcf26
6
+ metadata.gz: 2a206b225210468d2ea61664297183f321d0a560dec31758be4ef8abe17820f53f7f756b44b4883c7bef11abbbe33624116848065e4d86f668d3700fcfdf877b
7
+ data.tar.gz: ab78fb0b96fe227edf8d9a59106fe70ce47dc13fa270c27103b47b2f91fb218729b4a9a66873785bd22cfd7dea86b19859aafb4117eef52e20cb56398c98cde1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Asperalm - Laurent's Aspera Command Line Interface and Ruby Library
2
2
 
3
- Version : 0.7.3
3
+ Version : 0.7.4
4
4
 
5
5
 
6
6
  _Laurent/2016-2018_
@@ -34,7 +34,7 @@ Once the gem is installed, the `aslmcli` shall be accessible:
34
34
 
35
35
  ```bash
36
36
  $ aslmcli --version
37
- 0.7.3
37
+ 0.7.4
38
38
 
39
39
  ```
40
40
 
@@ -502,7 +502,7 @@ This can also be provisioned in a config file:
502
502
  2$ aslmcli config id shares06 set username john
503
503
  3$ aslmcli config id shares06 set password 4sp3ra
504
504
  4$ aslmcli config id default set shares shares06
505
- 5$ aslmcli config show
505
+ 5$ aslmcli config overview
506
506
  6$ aslmcli shares repo browse /
507
507
  ```
508
508
 
@@ -514,7 +514,7 @@ $ aslmcli config id shares06 init @json:'{"url":"https://10.25.0.6","username":"
514
514
  ```
515
515
 
516
516
  The fourth command defines this option preset as the default option preset for the
517
- specified application ("shares"). The 5th command dumps the configuration file.
517
+ specified application ("shares"). The 5th command displays the content of configuration file in table format.
518
518
  Alternative option presets can be used with option "-P<option preset>"
519
519
  (or --load-params=<option preset>)
520
520
 
@@ -773,6 +773,7 @@ aslmcli --no-default node --url=my_url_here --username=my_username_here --passwo
773
773
  aslmcli --version)
774
774
  aslmcli -Pnode_lmdk08 --url=my_url_here --username=my_username_here node acc create --value=@json:'{"id":"aoc_1","secret":"_my_pass_","storage":{"type":"local","path":"/"}}'
775
775
  aslmcli -Pnode_lmdk08 --url=my_url_here --username=my_username_here node acc delete --id=aoc_1
776
+ aslmcli -h
776
777
  aslmcli aspera admin ats access_key --id=testkey2 delete
777
778
  aslmcli aspera admin ats access_key --id=testkey2 node browse /
778
779
  aslmcli aspera admin ats access_key --id=testkey3 delete
@@ -888,7 +889,7 @@ aslmcli shares2 userinfo
888
889
  ```bash
889
890
  $ aslmcli -h
890
891
  NAME
891
- aslmcli -- a command line tool for Aspera Applications (v0.7.3)
892
+ aslmcli -- a command line tool for Aspera Applications (v0.7.4)
892
893
 
893
894
  SYNOPSIS
894
895
  aslmcli COMMANDS [OPTIONS] [ARGS]
@@ -953,8 +954,151 @@ OPTIONS:
953
954
  --url=VALUE URL of application, e.g. https://org.asperafiles.com
954
955
  --username=VALUE username to log in
955
956
  --password=VALUE user's password
956
- ERROR: Other: INTERNAL ERROR: option id already declared. only accessor can be redeclared and ignored
957
- Use '--log-level=debug' to get more details.
957
+ --value=VALUE extended value for create, update, list filter
958
+ --validator=VALUE identifier of validator (optional for central)
959
+ --id=VALUE entity identifier for update, show, and modify
960
+
961
+ COMMAND: orchestrator
962
+ SUBCOMMANDS: info, workflow, plugins, processes
963
+ OPTIONS:
964
+ --url=VALUE URL of application, e.g. https://org.asperafiles.com
965
+ --username=VALUE username to log in
966
+ --password=VALUE user's password
967
+ --params=VALUE parameters hash table, use @json:{"param":"value"}
968
+ --result=VALUE specify result value as: 'work step:parameter'
969
+ --id=VALUE workflow identifier
970
+ --synchronous=ENUM work step:parameter expected as result: yes, no
971
+
972
+ COMMAND: aspera
973
+ SUBCOMMANDS: packages, files, faspexgw, admin, user, organization
974
+ OPTIONS:
975
+ --ats-id=VALUE ATS key identifier (ats_xxx)
976
+ --params=VALUE Parameters access key creation (@json:)
977
+ --cloud=VALUE Cloud provider
978
+ --region=VALUE Cloud region
979
+ --download-mode=ENUM download mode: fasp, node_http
980
+ --auth=ENUM type of Oauth authentication: body_userpass, header_userpass, web, jwt, url_token
981
+ --bulk=ENUM bulk operation: yes, no
982
+ --url=VALUE URL of application, e.g. http://org.asperafiles.com
983
+ --username=VALUE username to log in
984
+ --password=VALUE user's password
985
+ --client-id=VALUE API client identifier in application
986
+ --client-secret=VALUE API client passcode
987
+ --redirect-uri=VALUE API client redirect URI
988
+ --private-key=VALUE RSA private key PEM value for JWT (prefix file path with @val:@file:)
989
+ --workspace=VALUE name of workspace
990
+ --recipient=VALUE package recipient
991
+ --title=VALUE package title
992
+ --note=VALUE package note
993
+ --secret=VALUE access key secret for node
994
+ --query=VALUE list filter (extended value: encode_www_form)
995
+ --id=VALUE resource identifier
996
+ --eid=VALUE identifier
997
+ --name=VALUE resource name
998
+ --link=VALUE link to shared resource
999
+ --public-token=VALUE token value of public link
1000
+ --value=VALUE extended value for create, update, list filter
1001
+
1002
+ COMMAND: xnode
1003
+ SUBCOMMANDS: postprocess, cleanup, forward
1004
+ OPTIONS:
1005
+ --url=VALUE URL of application, e.g. https://org.asperafiles.com
1006
+ --username=VALUE username to log in
1007
+ --password=VALUE user's password
1008
+ --filter-transfer=VALUE Ruby expression for filter at transfer level (cleanup)
1009
+ --filter-file=VALUE Ruby expression for filter at file level (cleanup)
1010
+ --persistency=VALUE persistency file (cleanup,forward)
1011
+
1012
+ COMMAND: ats
1013
+ SUBCOMMANDS: cluster, access_key
1014
+ OPTIONS:
1015
+ --id=VALUE Access key identifier, or server id, or api key id
1016
+ --secret=VALUE Access key secret
1017
+ --ats-id=VALUE ATS key identifier (ats_xxx)
1018
+ --params=VALUE Parameters access key creation (@json:)
1019
+ --cloud=VALUE Cloud provider
1020
+ --region=VALUE Cloud region
1021
+
1022
+ COMMAND: client
1023
+ SUBCOMMANDS: current, available, connect
1024
+ OPTIONS:
1025
+
1026
+ COMMAND: faspex
1027
+ SUBCOMMANDS: admin, package, dropbox, recv_publink, source, me
1028
+ OPTIONS:
1029
+ --url=VALUE URL of application, e.g. https://org.asperafiles.com
1030
+ --username=VALUE username to log in
1031
+ --password=VALUE user's password
1032
+ --recipient=VALUE package recipient
1033
+ --title=VALUE package title
1034
+ --note=VALUE package note
1035
+ --metadata=VALUE package metadata hash value (use @json:)
1036
+ --source-name=VALUE create package from remote source (by name)
1037
+ --storage=VALUE Faspex local storage definition
1038
+ --box=ENUM package box: inbox, sent, archive
1039
+
1040
+ COMMAND: shares2
1041
+ SUBCOMMANDS: repository, organization, project, team, share, appinfo, userinfo
1042
+ OPTIONS:
1043
+ --url=VALUE URL of application, e.g. https://org.asperafiles.com
1044
+ --username=VALUE username to log in
1045
+ --password=VALUE user's password
1046
+ --organization=VALUE organization
1047
+ --project=VALUE project
1048
+ --share=VALUE share
1049
+
1050
+ COMMAND: preview
1051
+ SUBCOMMANDS: scan, events, folder, check, test
1052
+ OPTIONS:
1053
+ --url=VALUE URL of application, e.g. https://org.asperafiles.com
1054
+ --username=VALUE username to log in
1055
+ --password=VALUE user's password
1056
+ --file-access=ENUM how to read and write files in repository: local, remote
1057
+ --skip-types=VALUE skip types in comma separated list
1058
+ --overwrite=ENUM when to generate preview file: always, never, mtime
1059
+ --previews-folder=VALUE preview folder in files
1060
+ --iteration-file=VALUE path to iteration memory file
1061
+ --folder-reset-cache=ENUM reset folder cache: no, header, read
1062
+ --temp-folder=VALUE path to temp folder
1063
+ --skip-folders=VALUE list of folder to skip
1064
+ --video=ENUM method to generate video: reencode, clips, preview
1065
+ --vid-offset-seconds=VALUE generation parameter
1066
+ --vid-size=VALUE generation parameter
1067
+ --vid-framecount=VALUE generation parameter
1068
+ --vid-blendframes=VALUE generation parameter
1069
+ --vid-framepause=VALUE generation parameter
1070
+ --vid-fps=VALUE generation parameter
1071
+ --vid-mp4-size-reencode=VALUE
1072
+ generation parameter
1073
+ --clips-offset-seconds=VALUE generation parameter
1074
+ --clips-size=VALUE generation parameter
1075
+ --clips-length=VALUE generation parameter
1076
+ --clips-count=VALUE generation parameter
1077
+ --thumb-mp4-size=VALUE generation parameter
1078
+ --thumb-img-size=VALUE generation parameter
1079
+ --thumb-offset-fraction=VALUE
1080
+ generation parameter
1081
+ --validate-mime=ENUM use magic number validation: yes, no
1082
+ --check-extension=ENUM check extra file extensions: yes, no
1083
+
1084
+ COMMAND: server
1085
+ SUBCOMMANDS: nodeadmin, userdata, configurator, download, upload, browse, delete, rename, ls, rm, mv, du, info, mkdir, cp, df, md5sum
1086
+ OPTIONS:
1087
+ --url=VALUE URL of application, e.g. https://org.asperafiles.com
1088
+ --username=VALUE username to log in
1089
+ --password=VALUE user's password
1090
+ --ssh-keys=VALUE PATH_ARRAY is @json:'["path1","path2"]'
1091
+
1092
+ COMMAND: console
1093
+ SUBCOMMANDS: transfer
1094
+ OPTIONS:
1095
+ --url=VALUE URL of application, e.g. https://org.asperafiles.com
1096
+ --username=VALUE username to log in
1097
+ --password=VALUE user's password
1098
+ --filter-from=DATE only after date
1099
+ --filter-to=DATE only before date
1100
+
1101
+ Documentation : http://www.rubydoc.info/gems/asperalm
958
1102
 
959
1103
 
960
1104
  ```
@@ -1364,7 +1508,7 @@ $ aslmcli client available
1364
1508
  ### List current resources used
1365
1509
 
1366
1510
  ```
1367
- $ aslmcli current
1511
+ $ aslmcli client current
1368
1512
  :........................:............................................................................................:
1369
1513
  : name : path :
1370
1514
  :........................:............................................................................................:
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.7.4
@@ -1,4 +1,3 @@
1
- require 'asperalm/cli/main'
2
1
  require 'asperalm/rest'
3
2
 
4
3
  module Asperalm
@@ -7,19 +6,19 @@ module Asperalm
7
6
  class BasicAuthPlugin < Plugin
8
7
  # returns a Rest object with basic auth
9
8
  def basic_auth_api(subpath=nil)
10
- api_url=Main.tool.options.get_option(:url,:mandatory)
9
+ api_url=self.manager.options.get_option(:url,:mandatory)
11
10
  api_url=api_url+'/'+subpath unless subpath.nil?
12
11
  return Rest.new({
13
12
  :base_url => api_url,
14
13
  :auth_type => :basic,
15
- :basic_username => Main.tool.options.get_option(:username,:mandatory),
16
- :basic_password => Main.tool.options.get_option(:password,:mandatory)})
14
+ :basic_username => self.manager.options.get_option(:username,:mandatory),
15
+ :basic_password => self.manager.options.get_option(:password,:mandatory)})
17
16
  end
18
17
 
19
18
  def declare_options
20
- Main.tool.options.add_opt_simple(:url,"URL of application, e.g. https://org.asperafiles.com")
21
- Main.tool.options.add_opt_simple(:username,"username to log in")
22
- Main.tool.options.add_opt_simple(:password,"user's password")
19
+ self.manager.options.add_opt_simple(:url,"URL of application, e.g. https://org.asperafiles.com")
20
+ self.manager.options.add_opt_simple(:username,"username to log in")
21
+ self.manager.options.add_opt_simple(:password,"user's password")
23
22
  end
24
23
  end # BasicAuthPlugin
25
24
  end # Cli
@@ -33,7 +33,7 @@ module Asperalm
33
33
  # name of application, also foldername where config is stored
34
34
  @@PROGRAM_NAME = 'aslmcli'
35
35
  @@GEM_NAME = 'asperalm'
36
- # folder in $HOME for the application
36
+ # folder in $HOME for application files (config, cache)
37
37
  @@ASPERA_HOME_FOLDER_NAME='.aspera'
38
38
  # folder containing custom plugins in `config_folder`
39
39
  @@ASPERA_PLUGINS_FOLDERNAME='plugins'
@@ -223,7 +223,7 @@ module Asperalm
223
223
  # local options
224
224
  def create_opt_mgr
225
225
  @opt_mgr=Manager.new(@@PROGRAM_NAME)
226
- Plugin.set_refs(@opt_mgr,self)
226
+ Plugin.manager=self
227
227
  @opt_mgr.parser.banner = "NAME\n\t#{@@PROGRAM_NAME} -- a command line tool for Aspera Applications (v#{self.class.gem_version})\n\n"
228
228
  @opt_mgr.parser.separator "SYNOPSIS"
229
229
  @opt_mgr.parser.separator "\t#{@@PROGRAM_NAME} COMMANDS [OPTIONS] [ARGS]"
@@ -335,7 +335,6 @@ module Asperalm
335
335
  Log.log.debug("(#{keep_last})[#{is_simple_hash}] -#{source.values}- \n-#{source}-")
336
336
  return source if keep_last and is_simple_hash
337
337
  source.each do |k,v|
338
- #Process.exit(1)
339
338
  if v.is_a?(Hash) and ( !keep_last or !is_simple_hash )
340
339
  flatten_sub_hash_rec(v,keep_last,prefix+k.to_s+'.',dest)
341
340
  else
@@ -484,7 +483,7 @@ module Asperalm
484
483
  if all_plugins
485
484
  # list plugins that have a "require" field, i.e. all but main plugin
486
485
  plugin_sym_list.select { |s| !@plugins[s][:require_stanza].nil? }.each do |plugin_name_sym|
487
- # override main option parser...
486
+ # override main option parser with a brand new
488
487
  @opt_mgr=Manager.new(@@PROGRAM_NAME)
489
488
  @opt_mgr.parser.banner = ""
490
489
  get_plugin_instance(plugin_name_sym)
@@ -493,7 +492,7 @@ module Asperalm
493
492
  end
494
493
  #STDERR.puts(@opt_mgr.parser)
495
494
  STDERR.puts "\nDocumentation : #{@@HELP_URL}"
496
- Process.exit 1
495
+ Process.exit(0)
497
496
  end
498
497
 
499
498
  def process_exception_exit(e,reason,propose_help=:none)
@@ -503,7 +502,7 @@ module Asperalm
503
502
  raise e
504
503
  else
505
504
  STDERR.puts "Use '--log-level=debug' to get more details." if propose_help.eql?(:debug)
506
- Process.exit 1
505
+ Process.exit(1)
507
506
  end
508
507
  end
509
508
 
@@ -2,9 +2,9 @@ module Asperalm
2
2
  module Cli
3
3
  # base class for plugins modules
4
4
  class Plugin
5
- def self.set_refs(optmgr,main)
6
- @@optmgr=optmgr
7
- @@main=main
5
+ # set reference to CLI manager
6
+ def self.manager=(manager)
7
+ @@manager=manager
8
8
  end
9
9
 
10
10
  def self.result_none
@@ -52,13 +52,18 @@ module Asperalm
52
52
  end
53
53
  end
54
54
 
55
- attr_reader :optmgr
56
- attr_reader :main
55
+ # helper : get CLI manager
56
+ def manager
57
+ @@manager
58
+ end
59
+
60
+ # helper : get CLI option parser
61
+ def options
62
+ @@manager.options
63
+ end
57
64
 
58
65
  def initialize
59
- # main is used for .options
60
- @optmgr=@@optmgr
61
- @main=@@main
66
+ super()
62
67
  end
63
68
 
64
69
  def declare_options
@@ -15,34 +15,34 @@ module Asperalm
15
15
  @ats=Ats.new
16
16
  @ats.declare_options(true)
17
17
 
18
- self.optmgr.add_opt_list(:download_mode,[:fasp, :node_http ],"download mode")
19
- self.optmgr.add_opt_list(:auth,Oauth.auth_types,"type of Oauth authentication")
20
- self.optmgr.add_opt_boolean(:bulk,"bulk operation")
21
- #self.optmgr.add_opt_boolean(:long,"long display")
22
- self.optmgr.add_opt_simple(:url,"URL of application, e.g. http://org.asperafiles.com")
23
- self.optmgr.add_opt_simple(:username,"username to log in")
24
- self.optmgr.add_opt_simple(:password,"user's password")
25
- self.optmgr.add_opt_simple(:client_id,"API client identifier in application")
26
- self.optmgr.add_opt_simple(:client_secret,"API client passcode")
27
- self.optmgr.add_opt_simple(:redirect_uri,"API client redirect URI")
28
- self.optmgr.add_opt_simple(:private_key,"RSA private key PEM value for JWT (prefix file path with @val:@file:)")
29
- self.optmgr.add_opt_simple(:workspace,"name of workspace")
30
- self.optmgr.add_opt_simple(:recipient,"package recipient")
31
- self.optmgr.add_opt_simple(:title,"package title")
32
- self.optmgr.add_opt_simple(:note,"package note")
33
- self.optmgr.add_opt_simple(:secret,"access key secret for node")
34
- self.optmgr.add_opt_simple(:query,"list filter (extended value: encode_www_form)")
35
- self.optmgr.add_opt_simple(:id,"resource identifier")
36
- self.optmgr.add_opt_simple(:eid,"identifier")
37
- self.optmgr.add_opt_simple(:name,"resource name")
38
- self.optmgr.add_opt_simple(:link,"link to shared resource")
39
- self.optmgr.add_opt_simple(:public_token,"token value of public link")
40
- self.optmgr.add_opt_simple(:value,"extended value for create, update, list filter")
41
- self.optmgr.set_option(:download_mode,:fasp)
42
- self.optmgr.set_option(:bulk,:no)
43
- #self.optmgr.set_option(:long,:no)
44
- self.optmgr.set_option(:redirect_uri,'http://localhost:12345')
45
- self.optmgr.set_option(:auth,:web)
18
+ self.options.add_opt_list(:download_mode,[:fasp, :node_http ],"download mode")
19
+ self.options.add_opt_list(:auth,Oauth.auth_types,"type of Oauth authentication")
20
+ self.options.add_opt_boolean(:bulk,"bulk operation")
21
+ #self.options.add_opt_boolean(:long,"long display")
22
+ self.options.add_opt_simple(:url,"URL of application, e.g. http://org.asperafiles.com")
23
+ self.options.add_opt_simple(:username,"username to log in")
24
+ self.options.add_opt_simple(:password,"user's password")
25
+ self.options.add_opt_simple(:client_id,"API client identifier in application")
26
+ self.options.add_opt_simple(:client_secret,"API client passcode")
27
+ self.options.add_opt_simple(:redirect_uri,"API client redirect URI")
28
+ self.options.add_opt_simple(:private_key,"RSA private key PEM value for JWT (prefix file path with @val:@file:)")
29
+ self.options.add_opt_simple(:workspace,"name of workspace")
30
+ self.options.add_opt_simple(:recipient,"package recipient")
31
+ self.options.add_opt_simple(:title,"package title")
32
+ self.options.add_opt_simple(:note,"package note")
33
+ self.options.add_opt_simple(:secret,"access key secret for node")
34
+ self.options.add_opt_simple(:query,"list filter (extended value: encode_www_form)")
35
+ self.options.add_opt_simple(:id,"resource identifier")
36
+ self.options.add_opt_simple(:eid,"identifier")
37
+ self.options.add_opt_simple(:name,"resource name")
38
+ self.options.add_opt_simple(:link,"link to shared resource")
39
+ self.options.add_opt_simple(:public_token,"token value of public link")
40
+ self.options.add_opt_simple(:value,"extended value for create, update, list filter")
41
+ self.options.set_option(:download_mode,:fasp)
42
+ self.options.set_option(:bulk,:no)
43
+ #self.options.set_option(:long,:no)
44
+ self.options.set_option(:redirect_uri,'http://localhost:12345')
45
+ self.options.set_option(:auth,:web)
46
46
  end
47
47
 
48
48
  # returns a node API for access key
@@ -50,16 +50,16 @@ module Asperalm
50
50
  # if secret present: use it
51
51
  def get_files_node_api(node_info,node_scope=nil)
52
52
  # if no scope, or secret provided on command line ...
53
- if node_scope.nil? or !self.optmgr.get_option(:secret,:optional).nil?
53
+ if node_scope.nil? or !self.options.get_option(:secret,:optional).nil?
54
54
  return Rest.new({
55
55
  :base_url =>node_info['url'],
56
56
  :auth_type =>:basic,
57
57
  :basic_username=>node_info['access_key'],
58
- :basic_password=>self.optmgr.get_option(:secret,:mandatory),
58
+ :basic_password=>self.options.get_option(:secret,:mandatory),
59
59
  :headers =>{'X-Aspera-AccessKey'=>node_info['access_key']
60
60
  }})
61
61
  end
62
- Log.log.warn("ignoring secret, using bearer token") if !self.optmgr.get_option(:secret,:optional).nil?
62
+ Log.log.warn("ignoring secret, using bearer token") if !self.options.get_option(:secret,:optional).nil?
63
63
  return Rest.new(@api_files_user.params.merge({
64
64
  :base_url => node_info['url'],
65
65
  :oauth_scope => FilesApi.node_scope(node_info['access_key'],node_scope),
@@ -134,20 +134,20 @@ module Asperalm
134
134
  PATH_SEPARATOR='/'
135
135
 
136
136
  def execute_node_action(home_node_id,home_file_id)
137
- command_repo=self.optmgr.get_next_argument('command',[ :access_key, :browse, :mkdir, :rename, :delete, :upload, :download, :node, :file ])
137
+ command_repo=self.options.get_next_argument('command',[ :access_key, :browse, :mkdir, :rename, :delete, :upload, :download, :node, :file ])
138
138
  case command_repo
139
139
  when :access_key
140
140
  node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id)
141
141
  node_api=get_files_node_api(node_info,FilesApi::SCOPE_NODE_USER)
142
142
  return Plugin.entity_action(node_api,'access_keys',['id','root_file_id','storage','license'],:eid)
143
143
  when :browse
144
- thepath=self.optmgr.get_next_argument("path")
144
+ thepath=self.options.get_next_argument("path")
145
145
  node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id,thepath)
146
146
  node_api=get_files_node_api(node_info,FilesApi::SCOPE_NODE_USER)
147
147
  items=node_api.read("files/#{file_id}/files")[:data]
148
148
  return {:type=>:hash_array,:data=>items,:fields=>['name','type','recursive_size','size','modified_time','access_level']}
149
149
  when :mkdir
150
- thepath=self.optmgr.get_next_argument("path")
150
+ thepath=self.options.get_next_argument("path")
151
151
  containing_folder_path = thepath.split(PATH_SEPARATOR)
152
152
  new_folder=containing_folder_path.pop
153
153
  node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id,containing_folder_path.join(PATH_SEPARATOR))
@@ -155,52 +155,52 @@ module Asperalm
155
155
  result=node_api.create("files/#{file_id}/files",{:name=>new_folder,:type=>:folder})[:data]
156
156
  return Plugin.result_status("created: #{result['name']} (id=#{result['id']})")
157
157
  when :rename
158
- thepath=self.optmgr.get_next_argument("source path")
159
- newname=self.optmgr.get_next_argument("new name")
158
+ thepath=self.options.get_next_argument("source path")
159
+ newname=self.options.get_next_argument("new name")
160
160
  node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id,thepath)
161
161
  node_api=get_files_node_api(node_info,FilesApi::SCOPE_NODE_USER)
162
162
  result=node_api.update("files/#{file_id}",{:name=>newname})[:data]
163
163
  return Plugin.result_status("renamed #{thepath} to #{newname}")
164
164
  when :delete
165
- thepath=self.optmgr.get_next_argument("path")
165
+ thepath=self.options.get_next_argument("path")
166
166
  node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id,thepath)
167
167
  node_api=get_files_node_api(node_info,FilesApi::SCOPE_NODE_USER)
168
168
  result=node_api.delete("files/#{file_id}")[:data]
169
169
  return Plugin.result_status("deleted: #{thepath}")
170
170
  when :upload
171
- filelist = self.optmgr.get_next_argument("file list",:multiple)
171
+ filelist = self.options.get_next_argument("file list",:multiple)
172
172
  Log.log.debug("file list=#{filelist}")
173
- node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id,@main.destination_folder('send'))
173
+ node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id,self.manager.destination_folder('send'))
174
174
  tspec=info_to_tspec('files','send',node_info,file_id)
175
175
  tspec['paths']=filelist.map { |i| {'source'=>i} }
176
- return @main.start_transfer(tspec,:node_gen4)
176
+ return self.manager.start_transfer(tspec,:node_gen4)
177
177
  when :download
178
- source_file=self.optmgr.get_next_argument('source')
179
- case self.optmgr.get_option(:download_mode,:mandatory)
178
+ source_file=self.options.get_next_argument('source')
179
+ case self.options.get_option(:download_mode,:mandatory)
180
180
  when :fasp
181
181
  file_path = source_file.split(PATH_SEPARATOR)
182
182
  file_name = file_path.pop
183
183
  node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id,file_path.join(PATH_SEPARATOR))
184
184
  tspec=info_to_tspec('files','receive',node_info,file_id)
185
185
  tspec['paths']=[{'source'=>file_name}]
186
- return @main.start_transfer(tspec,:node_gen4)
186
+ return self.manager.start_transfer(tspec,:node_gen4)
187
187
  when :node_http
188
188
  file_path = source_file.split(PATH_SEPARATOR)
189
189
  file_name = file_path.last
190
190
  node_info,file_id = find_nodeinfo_and_fileid(home_node_id,home_file_id,source_file)
191
191
  node_api=get_files_node_api(node_info,FilesApi::SCOPE_NODE_USER)
192
- node_api.call({:operation=>'GET',:subpath=>"files/#{file_id}/content",:save_to_file=>File.join(@main.destination_folder('receive'),file_name)})
192
+ node_api.call({:operation=>'GET',:subpath=>"files/#{file_id}/content",:save_to_file=>File.join(self.manager.destination_folder('receive'),file_name)})
193
193
  return Plugin.result_status("downloaded: #{file_name}")
194
194
  end # download_mode
195
195
  when :node
196
196
  # Note: other "common" actions are unauthorized with user scope
197
- command_legacy=self.optmgr.get_next_argument('command',Node.simple_actions)
197
+ command_legacy=self.options.get_next_argument('command',Node.simple_actions)
198
198
  # TODO: shall we support all methods here ? what if there is a link ?
199
199
  node_info=@api_files_user.read("nodes/#{home_node_id}")[:data]
200
200
  node_api=get_files_node_api(node_info,FilesApi::SCOPE_NODE_USER)
201
201
  return Node.new.execute_common(command_legacy,node_api)
202
202
  when :file
203
- fileid=self.optmgr.get_next_argument("file id")
203
+ fileid=self.options.get_next_argument("file id")
204
204
  node_info,file_id = find_nodeinfo_and_fileid(home_node_id,fileid)
205
205
  node_api=get_files_node_api(node_info,FilesApi::SCOPE_NODE_USER)
206
206
  items=node_api.read("files/#{file_id}")[:data]
@@ -223,7 +223,7 @@ module Asperalm
223
223
  # @home_node_id
224
224
  # returns nil
225
225
  def init_apis
226
- public_link_url=self.optmgr.get_option(:link,:optional)
226
+ public_link_url=self.options.get_option(:link,:optional)
227
227
 
228
228
  # if auth is a public link, option "link" is a shortcut for options: url, auth, public_token
229
229
  unless public_link_url.nil?
@@ -236,37 +236,37 @@ module Asperalm
236
236
  if url_token_value.nil?
237
237
  raise CliArgument,"link option must be url with 'token' parameter"
238
238
  end
239
- self.optmgr.set_option(:url,'https://'+uri.host)
240
- self.optmgr.set_option(:public_token,url_token_value)
241
- self.optmgr.set_option(:auth,:url_token)
242
- self.optmgr.set_option(:client_id,FilesApi.random.first)
243
- self.optmgr.set_option(:client_secret,FilesApi.random.last)
239
+ self.options.set_option(:url,'https://'+uri.host)
240
+ self.options.set_option(:public_token,url_token_value)
241
+ self.options.set_option(:auth,:url_token)
242
+ self.options.set_option(:client_id,FilesApi.random.first)
243
+ self.options.set_option(:client_secret,FilesApi.random.last)
244
244
  end
245
245
 
246
246
  # Connection paramaters (url and auth) to Aspera on Cloud
247
247
  # pre populate rest parameters based on URL
248
248
  aoc_rest_params=
249
- FilesApi.base_rest_params(self.optmgr.get_option(:url,:mandatory)).merge({
250
- :oauth_type => self.optmgr.get_option(:auth,:mandatory),
251
- :oauth_client_id => self.optmgr.get_option(:client_id,:mandatory),
252
- :oauth_client_secret => self.optmgr.get_option(:client_secret,:mandatory)
249
+ FilesApi.base_rest_params(self.options.get_option(:url,:mandatory)).merge({
250
+ :oauth_type => self.options.get_option(:auth,:mandatory),
251
+ :oauth_client_id => self.options.get_option(:client_id,:mandatory),
252
+ :oauth_client_secret => self.options.get_option(:client_secret,:mandatory)
253
253
  })
254
254
 
255
255
  # fill other auth parameters based on Oauth method
256
256
  case aoc_rest_params[:oauth_type]
257
257
  when :web
258
258
  aoc_rest_params.merge!({
259
- :oauth_redirect_uri => self.optmgr.get_option(:redirect_uri,:mandatory)
259
+ :oauth_redirect_uri => self.options.get_option(:redirect_uri,:mandatory)
260
260
  })
261
261
  when :jwt
262
- private_key_PEM_string=self.optmgr.get_option(:private_key,:mandatory)
262
+ private_key_PEM_string=self.options.get_option(:private_key,:mandatory)
263
263
  aoc_rest_params.merge!({
264
- :oauth_jwt_subject => self.optmgr.get_option(:username,:mandatory),
264
+ :oauth_jwt_subject => self.options.get_option(:username,:mandatory),
265
265
  :oauth_jwt_private_key_obj => OpenSSL::PKey::RSA.new(private_key_PEM_string)
266
266
  })
267
267
  when :url_token
268
268
  aoc_rest_params.merge!({
269
- :oauth_url_token => self.optmgr.get_option(:public_token,:mandatory),
269
+ :oauth_url_token => self.options.get_option(:public_token,:mandatory),
270
270
  })
271
271
  else raise "ERROR: unsupported auth method"
272
272
  end
@@ -281,7 +281,7 @@ module Asperalm
281
281
  url_token_data=@api_files_user.read("url_tokens")[:data].first
282
282
  @default_workspace_id=url_token_data['data']['workspace_id']
283
283
  @user_id='todo' # TODO : @org_data ?
284
- self.optmgr.set_option(:id,url_token_data['data']['package_id'])
284
+ self.options.set_option(:id,url_token_data['data']['package_id'])
285
285
  @home_node_id=url_token_data['data']['node_id']
286
286
  @home_file_id=url_token_data['data']['file_id']
287
287
  url_token_data=nil # no more needed
@@ -292,7 +292,7 @@ module Asperalm
292
292
  @user_id=self_data['id']
293
293
  end
294
294
 
295
- ws_name=self.optmgr.get_option(:workspace,:optional)
295
+ ws_name=self.options.get_option(:workspace,:optional)
296
296
  if ws_name.nil?
297
297
  Log.log.debug("using default workspace".green)
298
298
  if @default_workspace_id.eql?(nil)
@@ -327,7 +327,7 @@ module Asperalm
327
327
  end
328
328
 
329
329
  def do_bulk_operation(params,success,&do_action)
330
- params=[params] unless self.optmgr.get_option(:bulk)
330
+ params=[params] unless self.options.get_option(:bulk)
331
331
  raise "expecting Array" unless params.is_a?(Array)
332
332
  result=[]
333
333
  params.each do |p|
@@ -341,10 +341,10 @@ module Asperalm
341
341
 
342
342
  def execute_action
343
343
  init_apis
344
- command=self.optmgr.get_next_argument('command',action_list)
345
- if self.optmgr.get_option(:format,:optional).eql?(:table) and !command.eql?(:admin)
344
+ command=self.options.get_next_argument('command',action_list)
345
+ if self.options.get_option(:format,:optional).eql?(:table) and !command.eql?(:admin)
346
346
  default_ws=@workspace_id == @default_workspace_id ? ' (default)' : ''
347
- @main.display_status "Current Workspace: #{@workspace_name.red}#{default_ws}"
347
+ self.manager.display_status "Current Workspace: #{@workspace_name.red}#{default_ws}"
348
348
  end
349
349
 
350
350
  # display name of default workspace
@@ -354,7 +354,7 @@ module Asperalm
354
354
  when :organization
355
355
  return { :type=>:key_val_list, :data =>@org_data }
356
356
  when :user
357
- command=self.optmgr.get_next_argument('command',[ :workspaces,:info ])
357
+ command=self.options.get_next_argument('command',[ :workspaces,:info ])
358
358
  case command
359
359
  when :workspaces
360
360
  return {:type=>:hash_array,:data=>@api_files_user.read("workspaces")[:data],:fields=>['id','name']}
@@ -362,26 +362,26 @@ module Asperalm
362
362
  # return {:type=>:hash_array,:data=>@api_files_user.read("client_settings/")[:data]}
363
363
  when :info
364
364
  resource_instance_path="users/#{@user_id}"
365
- command=self.optmgr.get_next_argument('command',[ :show,:modify ])
365
+ command=self.options.get_next_argument('command',[ :show,:modify ])
366
366
  case command
367
367
  when :show
368
368
  object=@api_files_admn.read(resource_instance_path)[:data]
369
369
  return { :type=>:key_val_list, :data =>object }
370
370
  when :modify
371
- changes=self.optmgr.get_next_argument('modified parameters (hash)')
371
+ changes=self.options.get_next_argument('modified parameters (hash)')
372
372
  @api_files_admn.update(resource_instance_path,changes)
373
373
  return Plugin.result_status('modified')
374
374
  end
375
375
  end
376
376
  when :packages
377
- command_pkg=self.optmgr.get_next_argument('command',[ :send, :recv, :list, :show ])
377
+ command_pkg=self.options.get_next_argument('command',[ :send, :recv, :list, :show ])
378
378
  case command_pkg
379
379
  when :send
380
380
  # list of files to include in package
381
- filelist = self.optmgr.get_next_argument("file list",:multiple)
381
+ filelist = self.options.get_next_argument("file list",:multiple)
382
382
 
383
383
  # lookup users
384
- recipient_data=self.optmgr.get_option(:recipient,:mandatory).split(',').map { |recipient|
384
+ recipient_data=self.options.get_option(:recipient,:mandatory).split(',').map { |recipient|
385
385
  user_lookup=@api_files_user.read("contacts",{'current_workspace_id'=>@workspace_id,'q'=>recipient})[:data]
386
386
  raise CliBadArgument,"no such user: #{recipient}" unless !user_lookup.nil? and user_lookup.length == 1
387
387
  recipient_user_id=user_lookup.first
@@ -389,7 +389,7 @@ module Asperalm
389
389
  }
390
390
 
391
391
  # create a new package with one file
392
- the_package=@api_files_user.create("packages",{"workspace_id"=>@workspace_id,"name"=>self.optmgr.get_option(:title,:mandatory),"file_names"=>filelist,"note"=>self.optmgr.get_option(:note,:mandatory),"recipients"=>recipient_data})[:data]
392
+ the_package=@api_files_user.create("packages",{"workspace_id"=>@workspace_id,"name"=>self.options.get_option(:title,:mandatory),"file_names"=>filelist,"note"=>self.options.get_option(:note,:mandatory),"recipients"=>recipient_data})[:data]
393
393
 
394
394
  # get node information for the node on which package must be created
395
395
  node_info=@api_files_user.read("nodes/#{the_package['node_id']}")[:data]
@@ -400,19 +400,19 @@ module Asperalm
400
400
  tspec=info_to_tspec('packages','send',node_info,the_package['contents_file_id'])
401
401
  tspec['tags']['aspera']['files'].merge!({"package_id" => the_package['id'], "package_operation" => "upload"})
402
402
  tspec['paths']=filelist.map { |i| {'source'=>i} }
403
- return @main.start_transfer(tspec,:node_gen4)
403
+ return self.manager.start_transfer(tspec,:node_gen4)
404
404
  when :recv
405
- package_id=self.optmgr.get_option(:id,:mandatory)
405
+ package_id=self.options.get_option(:id,:mandatory)
406
406
  the_package=@api_files_user.read("packages/#{package_id}")[:data]
407
407
  node_info=@api_files_user.read("nodes/#{the_package['node_id']}")[:data]
408
408
  tspec=info_to_tspec('packages','receive',node_info,the_package['contents_file_id'])
409
409
  tspec['tags']['aspera']['files'].merge!({"package_id" => the_package['id'], "package_operation" => "download"})
410
410
  tspec['paths']=[{'source'=>'.'}]
411
- return @main.start_transfer(tspec,:node_gen4)
411
+ return self.manager.start_transfer(tspec,:node_gen4)
412
412
  when :show
413
- package_id=self.optmgr.get_next_argument('package ID')
413
+ package_id=self.options.get_next_argument('package ID')
414
414
  the_package=@api_files_user.read("packages/#{package_id}")[:data]
415
- # if self.optmgr.get_option(:long)
415
+ # if self.options.get_option(:long)
416
416
  # node_info,file_id = find_nodeinfo_and_fileid(the_package['node_id'],the_package['contents_file_id'])
417
417
  # node_api=get_files_node_api(node_info,FilesApi::SCOPE_NODE_USER)
418
418
  # items=node_api.read("files/#{file_id}/files")[:data]
@@ -431,7 +431,7 @@ module Asperalm
431
431
  require 'asperalm/faspex_gw'
432
432
  FaspexGW.instance.start_server(@api_files_user,@workspace_id)
433
433
  when :admin
434
- command_admin=self.optmgr.get_next_argument('command',[ :ats, :resource, :events, :set_client_key, :usage_reports, :search_nodes ])
434
+ command_admin=self.options.get_next_argument('command',[ :ats, :resource, :events, :set_client_key, :usage_reports, :search_nodes ])
435
435
  case command_admin
436
436
  when :ats
437
437
  @ats.ats_api_public = @ats.ats_api_secure = Rest.new(@api_files_admn.params.clone.merge!({
@@ -441,7 +441,7 @@ module Asperalm
441
441
 
442
442
  return @ats.execute_action_gen
443
443
  when :search_nodes
444
- ak=self.optmgr.get_next_argument('access_key')
444
+ ak=self.options.get_next_argument('access_key')
445
445
  nodes=@api_files_admn.read("search_nodes",{'q'=>'access_key:"'+ak+'"'})[:data]
446
446
  return {:type=>:other_struct,:data=>nodes}
447
447
  when :events
@@ -463,12 +463,12 @@ module Asperalm
463
463
  #transfers=api_node.make_request_ex({:operation=>'GET',:subpath=>'ops/transfers',:args=>{'count'=>25,'filter'=>'id'}})
464
464
  #transfers=api_node.read("events") # after_time=2016-05-01T23:53:09Z
465
465
  when :set_client_key
466
- the_client_id=self.optmgr.get_next_argument('client_id')
467
- the_private_key=self.optmgr.get_next_argument('private_key')
466
+ the_client_id=self.options.get_next_argument('client_id')
467
+ the_private_key=self.options.get_next_argument('private_key')
468
468
  @api_files_admn.update("clients/#{the_client_id}",{:jwt_grant_enabled=>true, :public_key=>OpenSSL::PKey::RSA.new(the_private_key).public_key.to_s})
469
469
  return Plugin.result_success
470
470
  when :resource
471
- resource_type=self.optmgr.get_next_argument('resource',[:self,:user,:group,:client,:contact,:dropbox,:node,:operation,:package,:saml_configuration, :workspace, :dropbox_membership,:short_link])
471
+ resource_type=self.options.get_next_argument('resource',[:self,:user,:group,:client,:contact,:dropbox,:node,:operation,:package,:saml_configuration, :workspace, :dropbox_membership,:short_link])
472
472
  resource_class_path=resource_type.to_s+case resource_type;when :dropbox;'es';when :self;'';else; 's';end
473
473
  singleton_object=[:self].include?(resource_type)
474
474
  global_operations=[:create,:list]
@@ -476,11 +476,11 @@ module Asperalm
476
476
  supported_operations.push(:modify,:delete,*global_operations) unless singleton_object
477
477
  supported_operations.push(:do) if resource_type.eql?(:node)
478
478
  supported_operations.push(:shared_folders) if resource_type.eql?(:workspace)
479
- command=self.optmgr.get_next_argument('command',supported_operations)
479
+ command=self.options.get_next_argument('command',supported_operations)
480
480
  # require identifier for non global commands
481
481
  if !singleton_object and !global_operations.include?(command)
482
- res_id=self.optmgr.get_option(:id)
483
- res_name=self.optmgr.get_option(:name)
482
+ res_id=self.options.get_option(:id)
483
+ res_name=self.options.get_option(:name)
484
484
  if res_id.nil?
485
485
  raise "Use either id or name" if res_name.nil?
486
486
  matching=@api_files_admn.read(resource_class_path,{:q=>res_name})[:data]
@@ -495,7 +495,7 @@ module Asperalm
495
495
  resource_instance_path=resource_class_path if singleton_object
496
496
  case command
497
497
  when :create
498
- list_or_one=self.optmgr.get_next_argument("creation data (Hash)")
498
+ list_or_one=self.options.get_next_argument("creation data (Hash)")
499
499
  return do_bulk_operation(list_or_one,'created')do|params|
500
500
  raise "expecting Hash" unless params.is_a?(Hash)
501
501
  @api_files_admn.create(resource_class_path,params)[:data]
@@ -507,7 +507,7 @@ module Asperalm
507
507
  when :operation; default_fields=nil
508
508
  when :contact; default_fields=["email","name","source_id","source_type"]
509
509
  end
510
- query=self.optmgr.get_option(:query,:optional)
510
+ query=self.options.get_option(:query,:optional)
511
511
  Log.log.debug("Query=#{query}".bg_red)
512
512
  begin
513
513
  URI.encode_www_form(query) unless query.nil?
@@ -520,7 +520,7 @@ module Asperalm
520
520
  fields=object.keys.select{|k|!k.eql?('certificate')}
521
521
  return { :type=>:key_val_list, :data =>object, :fields=>fields }
522
522
  when :modify
523
- changes=self.optmgr.get_next_argument('modified parameters (hash)')
523
+ changes=self.options.get_next_argument('modified parameters (hash)')
524
524
  @api_files_admn.update(resource_instance_path,changes)
525
525
  return Plugin.result_status('modified')
526
526
  when :delete