Class: Aspera::Transfer::Spec
- Inherits:
-
Object
- Object
- Aspera::Transfer::Spec
- Defined in:
- lib/aspera/transfer/spec.rb
Overview
Parameters for Transfer Spec Parameters are generated from JSON Schema.
Constant Summary collapse
- ACCESS_KEY_TRANSFER_USER =
default transfer username for access key based transfers
'xfer'- SSH_PORT =
default ports for SSH and UDP
33_001- UDP_PORT =
33_001- AK_TSPEC_BASE =
base transfer spec for access keys
{ 'remote_user' => ACCESS_KEY_TRANSFER_USER, 'ssh_port' => SSH_PORT, 'fasp_port' => UDP_PORT }.freeze
- WSS_FIELDS =
fields for WSS
%w[wss_enabled wss_port].freeze
- EXCLUDE_TIMES =
Modification times of the source files:
IntegerorString, seestringify_exclude_times %w[exclude_newer_than exclude_older_than].freeze
- TRANSPORT_FIELDS =
all fields for transport
(%w[remote_host] + AK_TSPEC_BASE.keys + WSS_FIELDS).freeze
- TAG_RESERVED =
reserved tag for Aspera
'aspera'- SPECIFIC =
Specific fields to not display
%w{token paths direction source_root destination_root}.freeze
- DOC_OVERVIEW =
Value of agent for documentation with one column per agent
:overview- SCHEMA =
CommandLineBuilder.read_schema(Schema::Registry::TRANSFER_SPEC, ascp: true)
Class Method Summary collapse
-
.direction_to_transfer_type(direction) ⇒ Object
translate send/receive to upload/download.
-
.doc_options(agent = nil) ⇒ Hash
Options of
Schema::Documentationfor the transfer spec: supported agents andascpoptions. - .fix_transferd_resume_policy(transfer_spec) ⇒ Object
-
.integer_exclude_times(transfer_spec) ⇒ Object
Parameters
exclude_newer_thanandexclude_older_thanas anInteger: Connect ignores a string, or a negative number. -
.resolve_target_rate(transfer_spec) ⇒ Object
Resolve pseudo-parameter
target_rate(bps) intotarget_rate_kbps(rounded down), overriding it if both are present. -
.stringify_exclude_times(transfer_spec) ⇒ Object
Parameters
exclude_newer_thanandexclude_older_thangiven as anIntegerare sent as aString: the Node API ignores a number,transferdrefuses it, andascpreads a text anyway. -
.transfer_type_to_direction(transfer_type) ⇒ Object
translate upload/download to send/receive.
Class Method Details
.direction_to_transfer_type(direction) ⇒ Object
translate send/receive to upload/download
55 56 57 |
# File 'lib/aspera/transfer/spec.rb', line 55 def direction_to_transfer_type(direction) XFER_DIR_TO_TYPE.fetch(direction) end |
.doc_options(agent = nil) ⇒ Hash
Options of Schema::Documentation for the transfer spec: supported agents and ascp options
97 98 99 100 101 102 103 104 105 |
# File 'lib/aspera/transfer/spec.rb', line 97 def (agent = nil) return {annotate: ->(node, formatter) { doc_lines(node, formatter, agent: agent) }} unless agent.eql?(DOC_OVERVIEW) { annotate: ->(node, formatter) { doc_lines(node, formatter, agents_line: false) }, extra_columns: Agent::Factory::ALL.sort_by { |_, names| names[:short] }.to_h do |sym, names| [names[:short].to_s, ->(node, formatter) { formatter.tick(CommandLineBuilder.supported_by_agent(sym, node)) }] end } end |
.fix_transferd_resume_policy(transfer_spec) ⇒ Object
89 90 91 92 |
# File 'lib/aspera/transfer/spec.rb', line 89 def fix_transferd_resume_policy(transfer_spec) # Fix discrepancy in transfer spec transfer_spec['resume_policy'] = POLICY_FIX[transfer_spec['resume_policy']] if transfer_spec.key?('resume_policy') end |
.integer_exclude_times(transfer_spec) ⇒ Object
Parameters exclude_newer_than and exclude_older_than as an Integer: Connect ignores a string, or a negative number
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/aspera/transfer/spec.rb', line 77 def integer_exclude_times(transfer_spec) EXCLUDE_TIMES.each do |key| next unless transfer_spec.key?(key) value = transfer_spec[key] value = Integer(value, 10, exception: false) if value.is_a?(String) Aspera.assert(value.is_a?(Integer) && !value.negative?, type: ParameterError) do "agent connect: #{key} must be a time after the epoch (positive integer), not #{transfer_spec[key].inspect}" end transfer_spec[key] = value end end |
.resolve_target_rate(transfer_spec) ⇒ Object
Resolve pseudo-parameter target_rate (bps) into target_rate_kbps (rounded down), overriding it if both are present.
61 62 63 64 65 |
# File 'lib/aspera/transfer/spec.rb', line 61 def resolve_target_rate(transfer_spec) return unless transfer_spec.key?('target_rate') rate = transfer_spec.delete('target_rate') transfer_spec['target_rate_kbps'] = Units::Decimal.rate_string_to_bps(rate) / 1000 unless rate.nil? end |
.stringify_exclude_times(transfer_spec) ⇒ Object
Parameters exclude_newer_than and exclude_older_than given as an Integer are sent as a String:
the Node API ignores a number, transferd refuses it, and ascp reads a text anyway.
70 71 72 |
# File 'lib/aspera/transfer/spec.rb', line 70 def stringify_exclude_times(transfer_spec) EXCLUDE_TIMES.each { |key| transfer_spec[key] = transfer_spec[key].to_s if transfer_spec[key].is_a?(Integer) } end |
.transfer_type_to_direction(transfer_type) ⇒ Object
translate upload/download to send/receive
50 51 52 |
# File 'lib/aspera/transfer/spec.rb', line 50 def transfer_type_to_direction(transfer_type) XFER_TYPE_TO_DIR.fetch(transfer_type) end |