Class: Fog::Compute::ProfitBricks::Share

Inherits:
Models::ProfitBricks::Base show all
Includes:
Helpers::ProfitBricks::DataHelper
Defined in:
lib/fog/profitbricks/models/compute/share.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::ProfitBricks::DataHelper

#flatten

Methods inherited from Models::ProfitBricks::Base

#failed?, #ready?, #request_status, #wait_for

Constructor Details

#initialize(attributes = {}) ⇒ Share

Returns a new instance of Share.



22
23
24
# File 'lib/fog/profitbricks/models/compute/share.rb', line 22

def initialize(attributes = {})
  super
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



20
21
22
# File 'lib/fog/profitbricks/models/compute/share.rb', line 20

def options
  @options
end

Instance Method Details

#deleteObject



53
54
55
56
57
# File 'lib/fog/profitbricks/models/compute/share.rb', line 53

def delete
  requires :group_id, :resource_id
  service.delete_share(group_id, resource_id)
  true
end

#saveObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/profitbricks/models/compute/share.rb', line 26

def save
  requires :group_id, :resource_id

  options = {}

  options[:editPrivilege]  = edit_privilege if edit_privilege
  options[:sharePrivilege] = share_privilege if share_privilege

  data = service.add_share(group_id, resource_id, options).body
  data['group_id']    = group_id
  data['resource_id'] = resource_id
  merge_attributes(flatten(data))
  true
end

#updateObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/profitbricks/models/compute/share.rb', line 41

def update
  requires :group_id, :resource_id

  options = {}
  options[:editPrivilege]  = edit_privilege if [true, false].include?(edit_privilege)
  options[:sharePrivilege] = share_privilege if [true, false].include?(share_privilege)

  data = service.update_share(group_id, resource_id, options)
  merge_attributes(flatten(data.body))
  true
end