Class: Onering::API::Auth

Inherits:
Base
  • Object
show all
Defined in:
lib/onering/plugins/authentication.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_BASE, Base::DEFAULT_CLIENT_PEM, Base::DEFAULT_OPTIONS_FILE, Base::DEFAULT_PATH

Class Method Summary collapse

Methods inherited from Base

connect, echo, make_filter, request

Class Method Details

._check_type(type) ⇒ Object



6
7
8
9
10
# File 'lib/onering/plugins/authentication.rb', line 6

def _check_type(type)
  raise "Invalid authentication module object '#{type}'" unless %w{
    users groups capabilities
  }.include?(type.to_s)
end

.get(type, id = 'current') ⇒ Object



12
13
14
15
# File 'lib/onering/plugins/authentication.rb', line 12

def get(type, id='current')
  _check_type(type)
  request("#{type}/#{id}")
end

.list(type, field = 'id', options = { :unique => true, :sort => true, :filter => nil }) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/onering/plugins/authentication.rb', line 17

def list(type, field='id', options={
  :unique => true,
  :sort   => true,
  :filter => nil
})
  _check_type(type)
  rv = request("#{type}/list").collect{|i| i[field.to_s] }
  rv = rv.uniq if options[:unique]
  rv = rv.sort if options[:sort]
  rv
end

.save(type, id, data) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/onering/plugins/authentication.rb', line 29

def save(type, id, data)
  _check_type(type)
  request("#{type}/#{id}", {
    :method => :post,
    :data   => data
  })
end