2012-10-19 11:38:44 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Brightbox
|
|
|
|
class Collaboration < Fog::Model
|
|
|
|
identity :id
|
|
|
|
attribute :status
|
|
|
|
attribute :email
|
|
|
|
attribute :role
|
|
|
|
attribute :role_label
|
|
|
|
attribute :account
|
|
|
|
attribute :user
|
|
|
|
attribute :inviter
|
|
|
|
|
|
|
|
def account_id
|
|
|
|
account['id'] || account[:id]
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
|
|
|
|
|
|
|
options = {
|
|
|
|
:role => role,
|
|
|
|
:email => email
|
|
|
|
}.delete_if { |k, v| v.nil? || v == "" }
|
|
|
|
|
2013-08-07 07:54:49 -04:00
|
|
|
data = service.create_collaboration(options)
|
2012-10-19 11:38:44 -04:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2013-08-07 06:30:58 -04:00
|
|
|
def resend
|
|
|
|
requires :identity
|
|
|
|
data = service.resend_collaboration(identity)
|
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2012-10-19 11:38:44 -04:00
|
|
|
def destroy
|
|
|
|
requires :identity
|
2013-08-07 06:30:58 -04:00
|
|
|
data = service.destroy_collaboration(identity)
|
|
|
|
merge_attributes(data)
|
2012-10-19 11:38:44 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|