Module: Aspera::Plugins::Node::Api::Scope

Extended by:
Scope
Included in:
Scope
Defined in:
lib/aspera/plugins/node/api.rb

Overview

Format of node scope : node.:

Constant Summary collapse

USER =

Node sub-scopes

'user:all'
ADMIN =
'admin:all'
SEPARATOR =

Separator between node.AK and user:all

':'
NODE_PREFIX =
'node.'

Instance Method Summary collapse

Instance Method Details

#join(access_key:, scope:) ⇒ String

Encode node API scope

Parameters:

  • access_key (String) —

    Access Key

  • scope (String) —

    internal scope

Returns:

  • (String) —

    full node scope



60
61
62
# File 'lib/aspera/plugins/node/api.rb', line 60

def join(access_key:, scope:)
  ["#{NODE_PREFIX}#{access_key}", scope].join(SEPARATOR)
end

#split(scope) ⇒ Hash

Decode node scope into access key and scope

Parameters:

  • scope (String) —

    scope string to split

Returns:

  • (Hash) —

    decoded scope with access key and scope parts



67
68
69
70
71
72
# File 'lib/aspera/plugins/node/api.rb', line 67

def split(scope)
  items = scope.split(Scope::SEPARATOR, 2)
  Aspera.assert(items.length.eql?(2)) { "invalid scope: #{scope}" }
  Aspera.assert(items[0].start_with?(NODE_PREFIX)) { "invalid scope: #{scope}" }
  {access_key: items[0].delete_prefix(NODE_PREFIX), scope: items[1]}
end