asperalm 0.6.15 → 0.6.16

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
  SHA1:
3
- metadata.gz: 1272dd88b96d12004a9e38b82b77a6fda3e0a93f
4
- data.tar.gz: 247d6d38d319ae317f3e033a2135a6a56ec715f9
3
+ metadata.gz: b55c1a7ceae4d637e43cc4bef6d021e47b3d06ef
4
+ data.tar.gz: b0d890ffbde8749ccc1384202c6f78544334f3e3
5
5
  SHA512:
6
- metadata.gz: 66c0a943d17e029612fc9e853d676ad49aadc47971d690be37ec99b34ca5525f2ae04bb1f2c024ff5afbd0b9fcef624b574351b34e1086b330937ae12c8de27f
7
- data.tar.gz: 1d138218b1b16818d0d2a7f11c89b9db672c4c8d0561e6ba997ddc10f7a4cebe8be92de7414a09e2dd77f73307c5f4eb7679e954e3c574b49ed0d21f8ff78a6c
6
+ metadata.gz: 74a50ba29945056ed5c0a06e5219ed28ded68738540c16d2f5fa2886e767f7e90cf55e4b61bf16adaccc05fef56035faec1e114ca436a2a8fe11513fc9c01df1
7
+ data.tar.gz: 11f43f1672e30b48d999ba5797cc72c791884cd80b39fe9c07d6c423af07f5054daba667d3eae066ae28a9a3a665c7cb8db0709c018b7d4703516ef32fb06a99
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.6.15
3
+ Version : 0.6.16
4
4
 
5
5
 
6
6
  _Laurent/2016-2018_
@@ -89,21 +89,22 @@ Once you have ruby and rights to install gems: Install the gem and its dependenc
89
89
  $ gem install asperalm
90
90
  ```
91
91
 
92
- ## FASP
92
+ ## FASP Protocol
93
93
 
94
- For FASP based file transfer, the FASP protocol and a valid license
95
- is required. If the server side is "connect" enabled, one can use
96
- the connect client license.
94
+ Most file transfers will be done using the FASP protocol. This requires one of IBM Asprea transfer server or client with its license file (some are free):
97
95
 
98
- `aslmcli` will detect most of Aspera transfer products in standard locations and use the first one found.
96
+ * IBM Aspera Connect Client
97
+ * IBM Aspera Desktop Client
98
+ * IBM Aspera CLI
99
+ * IBM Aspera High Speed Transfer Server
100
+ * IBM Aspera High Speed Transfer EndPoint
99
101
 
100
- Aspera Connect Client can be installed
101
- by visiting the page: [http://downloads.asperasoft.com/connect2/](http://downloads.asperasoft.com/connect2/)
102
+ For instance, Aspera Connect Client can be installed
103
+ by visiting the page: [http://downloads.asperasoft.com/connect2/](http://downloads.asperasoft.com/connect2/).
102
104
 
103
- It is also possible to use the `ascp` binary from Aspera CLI, or any other transfer product (High Speed Transfer Server, etc...).
105
+ `aslmcli` will detect most of Aspera transfer products in standard locations and use the first one found. Refer to section [Client](#client) for details.
104
106
 
105
- The connect client can be downloaded on command line using `aslmcli`,
106
- see section: [Client](client).
107
+ Several methods are provided on how to effectively start a transfer, refer to section: [Transfer Agents](#agents)
107
108
 
108
109
  # <a name="aslmcli"></a>Tool: `aslmcli`
109
110
 
@@ -124,7 +125,7 @@ The `asperalm` Gem provides a command line interface (CLI) which interacts with
124
125
  * Supports most Aspera server products (on-premise and SaaS)
125
126
  * Options can be provided on command line, in configuration file, in env var, in files (products URL, credentials or any option)
126
127
  * Commands, Option values and Parameters can be provided in short format (must be unique)
127
- * FASP [transfer agent](#agents) can be: FaspManager (local ascp), or Connect Client, or a transfer node
128
+ * FASP [Transfer Agents](#agents) can be: FaspManager (local ascp), or Connect Client, or a transfer node
128
129
  * Transfer parameters can be altered by modification of transferspec, this includes requiring multi-session transfer on nodes
129
130
  * Allows transfers from products to products, essentially at node level (using the node transfer agent)
130
131
  * Supports FaspStream creation (using Node API)
@@ -450,16 +451,16 @@ In order to get traces of execution, use argument : `--log-level=debug`
450
451
 
451
452
  Some actions may require the use of a graphical tool:
452
453
 
453
- * a browser for Aspera Aspera on Cloud authentication
454
+ * a browser for Aspera on Cloud authentication (web auth method)
454
455
  * a text editor for configuration file edition
455
456
 
456
457
  By default the CLI will assume that a graphical environment is available on windows,
457
458
  and on other systems, rely on the presence of the "DISPLAY" environment variable.
458
- It is also possible to force the graphical mode with option --gui-mode :
459
+ It is also possible to force the graphical mode with option --ui :
459
460
 
460
- * `--gui-mode=graphical` forces a graphical environment, a browser will be opened for URLs or
461
+ * `--ui=graphical` forces a graphical environment, a browser will be opened for URLs or
461
462
  a text editor for file edition.
462
- * `--gui-mode=text` forces a text environment, the URL or file path to open is displayed on
463
+ * `--ui=text` forces a text environment, the URL or file path to open is displayed on
463
464
  terminal.
464
465
 
465
466
  ## <a name="agents"></a>Transfer Agents
@@ -474,18 +475,16 @@ This transfer can be done using on of the 3 following methods:
474
475
 
475
476
  `aslmcli` standadizes on the use of a [_transfer-spec_](#_transferspec_) instead of _raw_ ascp options to provide parameters for a transfer session, as a common method for those three Transfer Agents.
476
477
 
477
- ### FASPManager API based (command line)
478
+ ### Direct (ascp/FASPManager API)
478
479
 
479
- By default the CLI will use the Aspera Connect Client FASP part, in this case
480
- it requires the installation of the Aspera Connect Client to be
481
- able to execute FASP based transfers. The CLI will try to automatically locate the
482
- Aspera Protocol (`ascp`). This is option: `--transfer=ascp`. Note that parameters
483
- are always provided with a [_transfer-spec_](#_transferspec_).
480
+ By default the CLI will use a local FASP protocol.
481
+ `aslmcli` will detect locally installed Aspera products.
482
+ Refer to section [Client](#client).
484
483
 
485
- ### Aspera Connect Client GUI
484
+ ### IBM Aspera Connect Client GUI
486
485
 
487
- By specifying option: `--transfer=connect`, the CLI will start transfers in the Aspera
488
- Connect Client.
486
+ By specifying option: `--transfer=connect`, `aslmcli` will start transfers in the Aspera
487
+ Connect Client. This requires the IBM Aspera Connect Client to be installed.
489
488
 
490
489
  ### Aspera Node API : Node to node transfers
491
490
 
@@ -761,7 +760,7 @@ aslmcli shares2 userinfo
761
760
  ```bash
762
761
  $ aslmcli -h
763
762
  NAME
764
- aslmcli -- a command line tool for Aspera Applications (v0.6.15)
763
+ aslmcli -- a command line tool for Aspera Applications (v0.6.16)
765
764
 
766
765
  SYNOPSIS
767
766
  aslmcli COMMANDS [OPTIONS] [ARGS]
@@ -824,7 +823,8 @@ OPTIONS:
824
823
  --username=VALUE username to log in
825
824
  --password=VALUE user's password
826
825
  --value=VALUE extended value for create, update, list filter
827
- --validator=VALUE identifier of validator
826
+ --validator=VALUE identifier of validator (optional for central)
827
+ --id=VALUE entity identifier for update, show, and modify
828
828
 
829
829
  COMMAND: orchestrator
830
830
  SUBCOMMANDS: info, workflow, plugins, processes
@@ -977,11 +977,11 @@ Those are using options:
977
977
 
978
978
  Those can be provided using command line, parameter set, env var, see section above.
979
979
 
980
- Aspera Aspera on Cloud relies on Oauth, refer to the [Aspera on Cloud](#aoc) section.
980
+ Aspera on Cloud relies on Oauth, refer to the [Aspera on Cloud](#aoc) section.
981
981
 
982
- ## <a name="aoc"></a>Aspera Aspera on Cloud, Aspera on Cloud
982
+ ## <a name="aoc"></a>Aspera on Cloud
983
983
 
984
- Aspera Aspera on Cloud uses the more advanced Oauth mechanism for authentication (HTTP Basic authentication is not supported).
984
+ Aspera on Cloud uses the more advanced Oauth mechanism for authentication (HTTP Basic authentication is not supported).
985
985
  This requires additional setup.
986
986
  Several types of OAuth authentication are supported:
987
987
 
@@ -1050,7 +1050,7 @@ Note: Default `auth` method is `web` and default `redirect_uri` is `htt^://local
1050
1050
  Once client has been registered and option preset created: `aslmcli` can be used:
1051
1051
 
1052
1052
  ```bash
1053
- $ aslmcli aspera repo br /
1053
+ $ aslmcli aspera files br /
1054
1054
  Current Workspace: Default Workspace (default)
1055
1055
  empty
1056
1056
  ```
@@ -1065,7 +1065,7 @@ In addition to basic API Client registration, the following steps are required f
1065
1065
 
1066
1066
  #### Key Pair Generation
1067
1067
 
1068
- In order to use JWT for Aspera Aspera on Cloud API client authentication,
1068
+ In order to use JWT for Aspera on Cloud API client authentication,
1069
1069
  a private/public key pair must be generated (without passphrase)
1070
1070
  This can be done using any of the following method:
1071
1071
 
@@ -1185,6 +1185,19 @@ It allows actions (create, update, delete) on "resources": users, group, nodes,
1185
1185
 
1186
1186
  Bulk operations are possible using option `bulk` (yes,no(default)): currently: create only. In that case, the operation expects an Array of Hash instead of a simple Hash using the [Extended Value Syntax](#extended).
1187
1187
 
1188
+ To get more resources when doing request add:
1189
+
1190
+ ```
1191
+ --query=@json:'{"per_page":10000}'
1192
+ ```
1193
+
1194
+ other query parameters can be used:
1195
+ ```
1196
+ --query=@json:'{"member_of_any_workspace":true,}'
1197
+ --query=@json:'{"q":"laurent"}'
1198
+ ```
1199
+
1200
+
1188
1201
  #### Examples
1189
1202
 
1190
1203
  * Bulk creation
@@ -1313,6 +1326,12 @@ $ aslmcli node download /share/sourcefile --to-folder=/destinationfolder --load-
1313
1326
  This will get transfer information from the SHOD instance and tell the Azure ATS instance
1314
1327
  to download files.
1315
1328
 
1329
+ ### Create access key
1330
+
1331
+ ```
1332
+ $ aslmcli node access_key create --value=@json:'{"id":"eudemo-sedemo","secret":"mystrongsecret","storage":{"type":"local","path":"/data/asperafiles"}}'
1333
+ ```
1334
+
1316
1335
  ## <a name="client"></a>Client
1317
1336
 
1318
1337
  The `client` plugin refers to the use of a local FASP client. It provides the following commands:
@@ -1321,9 +1340,38 @@ The `client` plugin refers to the use of a local FASP client. It provides the fo
1321
1340
  * `installation list` : list Aspera transfer products found locally
1322
1341
  * `client location` : list resources used for transfers
1323
1342
 
1324
- ### Examples
1343
+ ### List installed clients
1344
+
1345
+ ```bash
1346
+ $ aslmcli client installation list
1347
+ :..........................:................................................:
1348
+ : name : app_root :
1349
+ :..........................:................................................:
1350
+ : Connect Client : /Users/laurent/Applications/Aspera Connect.app :
1351
+ : Aspera Enterprise Server : /Library/Aspera :
1352
+ :..........................:................................................:
1353
+ ```
1354
+
1355
+ ### List resources used
1356
+
1357
+ ```
1358
+ $ aslmcli client location
1359
+ :........................:............................................................................................:
1360
+ : name : path :
1361
+ :........................:............................................................................................:
1362
+ : bin_folder : /Users/laurent/Applications/Aspera Connect.app/Contents/Resources :
1363
+ : ssh_bypass_key_dsa : /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/asperaweb_id_dsa.openssh :
1364
+ : ssh_bypass_key_rsa : /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/aspera_tokenauth_id_rsa :
1365
+ : fallback_cert : /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/aspera_web_cert.pem :
1366
+ : fallback_key : /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/aspera_web_key.pem :
1367
+ : localhost_cert : /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/localhost.crt :
1368
+ : localhost_key : /Users/laurent/Applications/Aspera Connect.app/Contents/Resources/localhost.key :
1369
+ : plugin_https_port_file : /Users/laurent/Library/Application Support/Aspera/Aspera Connect/var/run/https.uri :
1370
+ : log_folder : /Users/laurent/Library/Logs/Aspera :
1371
+ :........................:............................................................................................:
1372
+ ```
1325
1373
 
1326
- Download the installer for "Aspera Connect Client":
1374
+ ### Installation of Connect Client on command line
1327
1375
 
1328
1376
  ```bash
1329
1377
  $ ./bin/aslmcli client connect list
@@ -1408,7 +1456,7 @@ Aspera Shares supports the "node API" for the file transfer part. (Shares 1 and
1408
1456
 
1409
1457
  ## Aspera Transfer Service
1410
1458
 
1411
- Aka Aspera Aspera on Cloud, Aspera on Cloud...
1459
+ Aka Aspera on Cloud, Aspera on Cloud...
1412
1460
 
1413
1461
  ### First time use
1414
1462
 
@@ -1457,7 +1505,7 @@ for k in $(aslmcli ats access_key list --field=id --format=csv);do aslmcli ats a
1457
1505
 
1458
1506
  ## Preview
1459
1507
 
1460
- The preview plugin provides generation of previews for Aspera Aspera on Cloud.
1508
+ The preview plugin provides generation of previews for Aspera on Cloud.
1461
1509
 
1462
1510
  The tool requires the following external tools:
1463
1511
 
@@ -1467,7 +1515,7 @@ The tool requires the following external tools:
1467
1515
  * Libreoffice : `libreoffice`
1468
1516
 
1469
1517
  ### Preview Command
1470
- The `preview` plugin allows generation of preview files for Aspera Aspera on Cloud for on-premise nodes. (thumbnails and video previews)
1518
+ The `preview` plugin allows generation of preview files for Aspera on Cloud for on-premise nodes. (thumbnails and video previews)
1471
1519
 
1472
1520
  The preview generator creates/updates a preview for files located on
1473
1521
  an access key main "storage root". Several candidate detection methods are supported.
@@ -0,0 +1,39 @@
1
+ module Asperalm
2
+ module Cli
3
+ class Helper
4
+ global_ops=[:create,:list]
5
+ individual_ops=[:modify,:delete,:show]
6
+ all_ops=[global_ops,individual_ops].flatten
7
+
8
+ # implement generic rest operations on given resource path
9
+ def self.entity_action(rest_api,res_class_path,display_fields)
10
+ res_name=res_class_path.gsub(%r{.*/},'').gsub(%r{^s$},'').gsub('_',' ')
11
+ command=Main.tool.options.get_next_argument('command',all_ops)
12
+ if individual_ops.include?(command)
13
+ one_res_id=Main.tool.options.get_option(:id,:mandatory)
14
+ one_res_path="#{res_class_path}/#{one_res_id}"
15
+ end
16
+ if [:create,:modify].include?(command)
17
+ parameters=Main.tool.options.get_option(:value,:mandatory)
18
+ end
19
+ if [:list].include?(command)
20
+ parameters=Main.tool.options.get_option(:value,:optional)
21
+ end
22
+ case command
23
+ when :create
24
+ return {:type => :key_val_list, :data=>rest_api.create(res_class_path,parameters)[:data], :fields=>display_fields}
25
+ when :show
26
+ return {:type => :key_val_list, :data=>rest_api.read(one_res_path)[:data], :fields=>display_fields}
27
+ when :list
28
+ return {:type => :hash_array, :data=>rest_api.read(res_class_path,parameters)[:data], :fields=>display_fields}
29
+ when :modify
30
+ rest_api.update(one_res_path,parameters)
31
+ return Main.result_status('modified')
32
+ when :delete
33
+ rest_api.delete(one_res_path)
34
+ return Main.result_status("deleted")
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -22,7 +22,7 @@ module Asperalm
22
22
  singleton_class.send(:alias_method, :tool, :instance)
23
23
  def self.version;return @@TOOL_VERSION;end
24
24
  private
25
- @@TOOL_VERSION='0.6.15'
25
+ @@TOOL_VERSION='0.6.16'
26
26
  # first level command for the main tool
27
27
  @@MAIN_PLUGIN_NAME_SYM=:config
28
28
  # name of application, also foldername where config is stored
@@ -46,6 +46,7 @@ module Asperalm
46
46
  RUBY_FILE_EXT='.rb'
47
47
  FIELDS_ALL='ALL'
48
48
  FIELDS_DEFAULT='DEF'
49
+ ASPERA_PLUGIN_S=:aspera.to_s
49
50
 
50
51
  def save_presets_to_config_file
51
52
  raise "no configuration loaded" if @available_presets.nil?
@@ -70,12 +71,12 @@ module Asperalm
70
71
  end
71
72
 
72
73
  # returns default parameters for a plugin from loaded config file
73
- # try to find: conffile[conffile["config"][:default][plugin_sym]]
74
+ # try to find: conffile[conffile["default"][plugin_str]]
74
75
  def add_plugin_default_preset(plugin_sym)
75
76
  default_config_name=get_plugin_default_config_name(plugin_sym)
76
77
  Log.log.debug("add_plugin_default_preset:#{plugin_sym}:#{default_config_name}")
77
78
  return if default_config_name.nil?
78
- @opt_mgr.add_option_preset(@available_presets[default_config_name])
79
+ @opt_mgr.add_option_preset(@available_presets[default_config_name],:unshift)
79
80
  end
80
81
 
81
82
  def self.result_none
@@ -491,7 +492,7 @@ module Asperalm
491
492
  config_tested_version='0.6.14'
492
493
  if Gem::Version.new(version) <= Gem::Version.new(config_tested_version)
493
494
  old_plugin_name='files'
494
- new_plugin_name='aspera'
495
+ new_plugin_name=ASPERA_PLUGIN_S
495
496
  if @available_presets[@@CONFIG_FILE_KEY_DEFAULT].is_a?(Hash) and @available_presets[@@CONFIG_FILE_KEY_DEFAULT].has_key?(old_plugin_name)
496
497
  @available_presets[@@CONFIG_FILE_KEY_DEFAULT][new_plugin_name]=@available_presets[@@CONFIG_FILE_KEY_DEFAULT][old_plugin_name]
497
498
  @available_presets[@@CONFIG_FILE_KEY_DEFAULT].delete(old_plugin_name)
@@ -504,7 +505,7 @@ module Asperalm
504
505
  @available_presets[@@MAIN_PLUGIN_NAME_SYM.to_s][@@CONFIG_FILE_KEY_VERSION]=@@TOOL_VERSION
505
506
  save_presets_to_config_file
506
507
  Log.log.warn("Saving automatic conversion.")
507
- end
508
+ end
508
509
  rescue => e
509
510
  new_name="#{@option_config_file}.pre#{@@TOOL_VERSION}.manual_conversion_needed"
510
511
  File.rename(@option_config_file,new_name)
@@ -516,6 +517,9 @@ module Asperalm
516
517
 
517
518
  protected
518
519
 
520
+ DEFAULT_PRESET='aspera_default'
521
+ DEFAULT_REDIRECT='http://localhost:12345'
522
+
519
523
  # "config" plugin
520
524
  def execute_action
521
525
  action=@opt_mgr.get_next_argument('action',[:genkey,:plugins,:flush_tokens,:list,:overview,:open,:echo,:id,:documentation])
@@ -597,6 +601,20 @@ module Asperalm
597
601
  return {:data => @available_presets.keys, :type => :value_list, :name => 'name'}
598
602
  when :overview
599
603
  return {:type=>:hash_array,:data=>self.class.flatten_all_config(@available_presets)}
604
+ when :aspera_setup # TODO
605
+ @available_presets[@@CONFIG_FILE_KEY_DEFAULT]||=Hash.new
606
+ raise CliError,"a default configuration already exists" if @available_presets[@@CONFIG_FILE_KEY_DEFAULT].has_key?(ASPERA_PLUGIN_S)
607
+ raise CliError,"preset already exists: #{DEFAULT_PRESET}" if @available_presets.has_key?(DEFAULT_PRESET)
608
+ @available_presets[@@CONFIG_FILE_KEY_DEFAULT][ASPERA_PLUGIN_S]=DEFAULT_PRESET
609
+ @opt_mgr.set_option(:interactive,:yes)
610
+ @opt_mgr.add_opt_simple(:url,"URL of application, e.g. http://org.asperafiles.com")
611
+ @opt_mgr.parse_options!
612
+ @available_presets[DEFAULT_PRESET]={
613
+ :url.to_s=>@opt_mgr.get_option(:url,:mandatory),
614
+ :redirect_uri.to_s=>DEFAULT_REDIRECT,
615
+ :client_id.to_s=>@opt_mgr.get_option(:client_id,:mandatory),
616
+ }
617
+ raise "todo"
600
618
  end
601
619
  end
602
620
 
@@ -138,8 +138,8 @@ module Asperalm
138
138
  # ask optional options if not provided and in interactive
139
139
  @ask_missing_optional=false
140
140
  # those must be set before parse, parse consumes those defined only
141
- @unprocessed_defaults={}
142
- @unprocessed_env={}
141
+ @unprocessed_defaults=[]
142
+ @unprocessed_env=[]
143
143
  # Note: was initially inherited but it is prefered to have specific methods
144
144
  @parser=OptionParser.new
145
145
  @parser.program_name=program_name
@@ -151,7 +151,7 @@ module Asperalm
151
151
  env_prefix=@parser.program_name.upcase+'_'
152
152
  ENV.each do |k,v|
153
153
  if k.start_with?(env_prefix)
154
- @unprocessed_env[k[env_prefix.length..-1].downcase.to_sym]=v
154
+ @unprocessed_env.push([k[env_prefix.length..-1].downcase.to_sym,v])
155
155
  end
156
156
  end
157
157
  Log.log.debug("env=#{@unprocessed_env}".red)
@@ -289,13 +289,13 @@ module Asperalm
289
289
  if result.nil?
290
290
  if !@ask_missing_mandatory
291
291
  if is_type.eql?(:mandatory)
292
- raise CliBadArgument,"Missing option in context: #{option_symbol}"
292
+ raise CliBadArgument,"Missing mandatory option: #{option_symbol}"
293
293
  end
294
294
  else # ask_missing_mandatory
295
295
  if @ask_missing_optional or is_type.eql?(:mandatory)
296
296
  expected=:single
297
297
  #print "please enter: #{option_symbol.to_s}"
298
- if @declared_options[option_symbol].has_key?(:values)
298
+ if @declared_options.has_key?(option_symbol) and @declared_options[option_symbol].has_key?(:values)
299
299
  expected=@declared_options[option_symbol][:values]
300
300
  end
301
301
  result=get_interactive(:option,option_symbol.to_s,expected)
@@ -307,11 +307,11 @@ module Asperalm
307
307
  end
308
308
 
309
309
  # param must be hash
310
- def add_option_preset(preset_hash)
310
+ def add_option_preset(preset_hash,op=:push)
311
311
  Log.log.debug("add_option_preset=#{preset_hash}")
312
312
  raise "internal error: setting default with no hash: #{preset_hash.class}" if !preset_hash.is_a?(Hash)
313
313
  # incremental override
314
- preset_hash.each{|k,v|@unprocessed_defaults[k.to_sym]=v}
314
+ preset_hash.each{|k,v|@unprocessed_defaults.send(op,[k.to_sym,v])}
315
315
  end
316
316
 
317
317
  # generate command line option from option symbol
@@ -422,7 +422,8 @@ module Asperalm
422
422
  end
423
423
 
424
424
  def apply_options_preset(preset,where,force=false)
425
- preset.each do |k,v|
425
+ preset.each do |pair|
426
+ k,v=*pair
426
427
  if @declared_options.has_key?(k)
427
428
  # constrained parameters as string are revert to symbol
428
429
  if @declared_options[k].has_key?(:values) and v.is_a?(String)
@@ -403,7 +403,7 @@ module Asperalm
403
403
  when :contact; default_fields=["email","name","source_id","source_type"]
404
404
  end
405
405
  query=Main.tool.options.get_option(:query,:optional)
406
- Log.log.debug("#{query}".bg_red)
406
+ Log.log.debug("Query=#{query}".bg_red)
407
407
  return {:type=>:hash_array,:data=>@api_files_admin.read(resource_class_path,query)[:data],:fields=>default_fields}
408
408
  when :show
409
409
  object=@api_files_admin.read(resource_instance_path)[:data]
@@ -1,4 +1,5 @@
1
1
  require 'asperalm/cli/main'
2
+ require 'asperalm/cli/helper'
2
3
  require 'asperalm/cli/basic_auth_plugin'
3
4
  require "base64"
4
5
 
@@ -17,7 +18,8 @@ module Asperalm
17
18
  def declare_options
18
19
  super_declare_options
19
20
  Main.tool.options.add_opt_simple(:value,"extended value for create, update, list filter")
20
- Main.tool.options.add_opt_simple(:validator,"identifier of validator")
21
+ Main.tool.options.add_opt_simple(:validator,"identifier of validator (optional for central)")
22
+ Main.tool.options.add_opt_simple(:id,"entity identifier for update, show, and modify")
21
23
  #Main.tool.options.set_option(:value,'@json:{"active_only":false}')
22
24
  end
23
25
 
@@ -172,34 +174,6 @@ module Asperalm
172
174
  end
173
175
  end
174
176
 
175
- def generic_operations; [:create,:list,:id];end
176
-
177
- # implement generic rest operations on given resource path
178
- def resource_action(api_node,res_class_path,display_fields)
179
- res_name=res_class_path.gsub(%r{.*/},'').gsub(%r{^s$},'').gsub('_',' ')
180
- command=Main.tool.options.get_next_argument('command',[ :list, :create, :id ])
181
- case command
182
- when :create
183
- return {:type => :other_struct, :data=>api_node.create(res_class_path,Main.tool.options.get_option(:value,:mandatory))[:data], :fields=>display_fields}
184
- when :list
185
- return {:type => :hash_array, :data=>api_node.read(res_class_path)[:data], :fields=>display_fields}
186
- when :id
187
- one_res_id=Main.tool.options.get_next_argument("#{res_name} id")
188
- one_res_path="#{res_class_path}/#{one_res_id}"
189
- command=Main.tool.options.get_next_argument('command',[ :delete, :show, :modify ])
190
- case command
191
- when :modify
192
- api_node.update(one_res_path,Main.tool.options.get_option(:value,:mandatory))
193
- return Main.result_status('modified')
194
- when :delete
195
- api_node.delete(one_res_path)
196
- return {:type => :empty}
197
- when :show
198
- return {:type => :key_val_list, :data=>api_node.read(one_res_path)[:data], :fields=>display_fields}
199
- end
200
- end
201
- end
202
-
203
177
  def action_list; self.class.common_actions.clone.concat([ :postprocess,:stream, :transfer, :cleanup, :forward, :access_key, :watch_folder, :service, :async, :central ]);end
204
178
 
205
179
  def execute_action
@@ -208,27 +182,22 @@ module Asperalm
208
182
  case command
209
183
  when *self.class.common_actions; return self.class.execute_common(command,api_node)
210
184
  when :async
211
- command=Main.tool.options.get_next_argument('command',[ :list, :id ])
185
+ command=Main.tool.options.get_next_argument('command',[:list,:summary,:counters])
186
+ if [:summary,:counters].include?(command)
187
+ asyncid=Main.tool.options.get_option(:id,:mandatory)
188
+ end
212
189
  case command
213
190
  when :list
214
191
  resp=api_node.read('async/list')[:data]['sync_ids']
215
192
  return { :type => :value_list, :data => resp, :name=>'id' }
216
- when :id
217
- asyncid=Main.tool.options.get_next_argument("async id")
218
- command=Main.tool.options.get_next_argument('command',[ :delete,:summary,:counters ])
219
- case command
220
- when :summary
221
- resp=api_node.create('async/summary',{"syncs"=>[asyncid]})[:data]["sync_summaries"].first
222
- return Main.result_none if resp.nil?
223
- return { :type => :key_val_list, :data => resp }
224
- when :delete
225
- # delete POST /async/delete '{"syncs":["4"]}'
226
- raise "not implemented"
227
- when :counters
228
- resp=api_node.create('async/counters',{"syncs"=>[asyncid]})[:data]["sync_counters"].first[asyncid].last
229
- return Main.result_none if resp.nil?
230
- return { :type => :key_val_list, :data => resp }
231
- end
193
+ when :summary
194
+ resp=api_node.create('async/summary',{"syncs"=>[asyncid]})[:data]["sync_summaries"].first
195
+ return Main.result_none if resp.nil?
196
+ return { :type => :key_val_list, :data => resp }
197
+ when :counters
198
+ resp=api_node.create('async/counters',{"syncs"=>[asyncid]})[:data]["sync_counters"].first[asyncid].last
199
+ return Main.result_none if resp.nil?
200
+ return { :type => :key_val_list, :data => resp }
232
201
  end
233
202
  when :stream
234
203
  command=Main.tool.options.get_next_argument('command',[ :list, :create, :show, :modify, :cancel ])
@@ -256,26 +225,32 @@ module Asperalm
256
225
  end
257
226
  when :transfer
258
227
  command=Main.tool.options.get_next_argument('command',[ :list, :cancel, :show ])
228
+ res_class_path='ops/transfers'
229
+ if [:cancel, :show].include?(command)
230
+ one_res_id=Main.tool.options.get_option(:id,:mandatory)
231
+ one_res_path="#{res_class_path}/#{one_res_id}"
232
+ end
259
233
  case command
260
234
  when :list
261
235
  # could use ? :subpath=>'transfers'
262
- resp=api_node.read('ops/transfers',Main.tool.options.get_option(:value,:optional))
236
+ resp=api_node.read(res_class_path,Main.tool.options.get_option(:value,:optional))
263
237
  return { :type => :hash_array, :data => resp[:data], :fields=>['id','status','remote_user','remote_host'], :textify => lambda { |table_data| Node.textify_transfer_list(table_data) } } # TODO
264
238
  when :cancel
265
- trid=Main.tool.options.get_next_argument("transfer id")
266
- resp=api_node.cancel('ops/transfers/'+trid)
239
+ resp=api_node.cancel(one_res_path)
267
240
  return { :type=>:other_struct, :data => resp[:data] }
268
241
  when :show
269
- trid=Main.tool.options.get_next_argument("transfer id")
270
- resp=api_node.read('ops/transfers/'+trid)
242
+ resp=api_node.read(one_res_path)
271
243
  return { :type=>:other_struct, :data => resp[:data] }
272
244
  else
273
245
  raise "error"
274
246
  end
275
247
  when :access_key
276
- return resource_action(api_node,'access_keys',['id','root_file_id','storage','license'])
248
+ return Helper.entity_action(api_node,'access_keys',['id','root_file_id','storage','license'])
277
249
  when :service
278
- command=Main.tool.options.get_next_argument('command',[ :list, :create, :id])
250
+ command=Main.tool.options.get_next_argument('command',[ :list, :create, :delete])
251
+ if [:delete].include?(command)
252
+ svcid=Main.tool.options.get_option(:id,:mandatory)
253
+ end
279
254
  case command
280
255
  when :list
281
256
  resp=api_node.read('rund/services')
@@ -286,23 +261,18 @@ module Asperalm
286
261
  params=Main.tool.options.get_next_argument("Run creation data (structure)")
287
262
  resp=api_node.create('rund/services',params)
288
263
  return Main.result_status("#{resp[:data]['id']} created")
289
- when :id
290
- svcid=Main.tool.options.get_next_argument("service id")
291
- command=Main.tool.options.get_next_argument('command',[ :delete, :modify ])
292
- case command
293
- when :delete
294
- resp=api_node.delete("rund/services/#{svcid}")
295
- return Main.result_status("#{svcid} deleted")
296
- else
297
- raise "error"
298
- end
299
- else
300
- raise "error"
264
+ when :delete
265
+ resp=api_node.delete("rund/services/#{svcid}")
266
+ return Main.result_status("#{svcid} deleted")
301
267
  end
302
268
  when :watch_folder
303
269
  res_class_path='v3/watchfolders'
304
- #return resource_action(api_node,'v3/watchfolders',nil)
305
- command=Main.tool.options.get_next_argument('command',[ :list, :create, :id])
270
+ #return Helper.entity_action(api_node,'v3/watchfolders',nil)
271
+ command=Main.tool.options.get_next_argument('command',[ :create, :list, :show, :modify, :delete, :state])
272
+ if [:show,:modify,:delete,:state].include?(command)
273
+ one_res_id=Main.tool.options.get_option(:id,:mandatory)
274
+ one_res_path="#{res_class_path}/#{one_res_id}"
275
+ end
306
276
  case command
307
277
  when :create
308
278
  resp=api_node.create(res_class_path,Main.tool.options.get_option(:value,:mandatory))
@@ -311,22 +281,16 @@ module Asperalm
311
281
  resp=api_node.read(res_class_path,Main.tool.options.get_option(:value,:optional))
312
282
  # :fields=>['id','root_file_id','storage','license']
313
283
  return { :type=>:value_list, :data => resp[:data]['ids'], :name=>'id' }
314
- when :id
315
- one_res_id=Main.tool.options.get_next_argument("watch folder id")
316
- one_res_path="#{res_class_path}/#{one_res_id}"
317
- command=Main.tool.options.get_next_argument('command',[ :delete, :show, :update, :state ])
318
- case command
319
- when :show
320
- return {:type=>:key_val_list, :data=>api_node.read(one_res_path)[:data]}
321
- when :update
322
- api_node.update(one_res_path,Main.tool.options.get_option(:value,:mandatory))
323
- return Main.result_status("#{one_res_id} updated")
324
- when :delete
325
- api_node.delete(one_res_path)
326
- return Main.result_status("#{one_res_id} deleted")
327
- when :state
328
- return { :type=>:key_val_list, :data => api_node.read("#{one_res_path}/state")[:data] }
329
- end
284
+ when :show
285
+ return {:type=>:key_val_list, :data=>api_node.read(one_res_path)[:data]}
286
+ when :modify
287
+ api_node.update(one_res_path,Main.tool.options.get_option(:value,:mandatory))
288
+ return Main.result_status("#{one_res_id} updated")
289
+ when :delete
290
+ api_node.delete(one_res_path)
291
+ return Main.result_status("#{one_res_id} deleted")
292
+ when :state
293
+ return { :type=>:key_val_list, :data => api_node.read("#{one_res_path}/state")[:data] }
330
294
  end
331
295
  when :central
332
296
  command=Main.tool.options.get_next_argument('command',[ :session,:file])
@@ -344,13 +308,13 @@ module Asperalm
344
308
  return {:type=>:hash_array,:data=>resp[:data]["session_info_result"]["session_info"],:fields=>["session_uuid","status","transport","direction","bytes_transferred"]}
345
309
  end
346
310
  when :file
347
- command=Main.tool.options.get_next_argument('command',[ :list, :update])
311
+ command=Main.tool.options.get_next_argument('command',[ :list, :modify])
348
312
  case command
349
313
  when :list
350
314
  request_data.deep_merge!({"validation"=>validation}) unless validation.nil?
351
315
  resp=api_node.create('services/rest/transfers/v1/files',request_data)
352
316
  return {:type=>:hash_array,:data=>resp[:data]["file_transfer_info_result"]["file_transfer_info"],:fields=>["session_uuid","file_id","status","path"]}
353
- when :update
317
+ when :modify
354
318
  request_data.deep_merge!(validation) unless validation.nil?
355
319
  api_node.update('services/rest/transfers/v1/files',request_data)
356
320
  return Main.result_status('updated')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asperalm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.15
4
+ version: 0.6.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-16 00:00:00.000000000 Z
11
+ date: 2018-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xml-simple
@@ -196,6 +196,7 @@ files:
196
196
  - docs/diagrams.txt
197
197
  - lib/asperalm/ascmd.rb
198
198
  - lib/asperalm/cli/basic_auth_plugin.rb
199
+ - lib/asperalm/cli/helper.rb
199
200
  - lib/asperalm/cli/main.rb
200
201
  - lib/asperalm/cli/manager.rb
201
202
  - lib/asperalm/cli/plugin.rb