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
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
14 15 16 17 18 19 |
# File 'lib/lmc/authority.rb', line 14 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
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lmc/authority.rb', line 22 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
33 34 35 36 37 38 39 |
# File 'lib/lmc/authority.rb', line 33 def to_json(*a) { 'name' => @name, 'type' => @type, 'visibility' => @visibility }.to_json(*a) end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/lmc/authority.rb', line 41 def to_s "#{@name} (#{@type}/#{@visibility})" end |