Class: LMC::Authority
- Inherits:
-
Object
- Object
- LMC::Authority
- Defined in:
- lib/lmc/authority.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
Instance Method Summary collapse
-
#initialize(data, account) ⇒ Authority
constructor
A new instance of Authority.
- #rights ⇒ Object
-
#save ⇒ Object
returns itself, allows chaining.
- #to_json(*a) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data, account) ⇒ Authority
Returns a new instance of Authority.
7 8 9 10 11 |
# File 'lib/lmc/authority.rb', line 7 def initialize(data, account) @cloud = account.cloud apply_data(data) @account = account end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
5 6 7 |
# File 'lib/lmc/authority.rb', line 5 def account @account end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/lmc/authority.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/lmc/authority.rb', line 5 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/lmc/authority.rb', line 5 def type @type end |
#visibility ⇒ Object
Returns the value of attribute visibility.
5 6 7 |
# File 'lib/lmc/authority.rb', line 5 def visibility @visibility end |
Instance Method Details
#rights ⇒ Object
13 14 15 16 17 18 |
# File 'lib/lmc/authority.rb', line 13 def rights # GET /accounts/{accountId}/authorities/{authorityId}/rights @cloud.auth_for_account @account response = @cloud.get ['cloud-service-auth', 'accounts', @account.id, 'authorities', @id, 'rights'] response.body.to_s end |
#save ⇒ Object
returns itself, allows chaining
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lmc/authority.rb', line 21 def save response = if @id.nil? Cloud.instance.post ['cloud-service-auth', 'accounts', @account.id, 'authorities'], self else raise 'editing authorities not supported' # @cloud.put ["cloud-service-auth", "principals", @id], self end apply_data(response.body) self end |
#to_json(*a) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/lmc/authority.rb', line 32 def to_json(*a) { 'name' => @name, 'type' => @type, 'visibility' => @visibility }.to_json(*a) end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/lmc/authority.rb', line 40 def to_s "#{@name} (#{@type}/#{@visibility})" end |