2012-10-19 11:38:44 -04:00
|
|
|
require "fog/core/collection"
|
|
|
|
require "fog/brightbox/models/compute/collaboration"
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Brightbox
|
|
|
|
class Collaborations < Fog::Collection
|
|
|
|
model Fog::Compute::Brightbox::Collaboration
|
|
|
|
|
|
|
|
def all
|
2013-08-07 07:54:49 -04:00
|
|
|
data = service.list_collaborations
|
2012-10-19 11:38:44 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
2013-08-07 06:30:58 -04:00
|
|
|
def get(identifier)
|
|
|
|
return nil if identifier.nil? || identifier == ""
|
|
|
|
data = service.get_collaboration(identifier)
|
|
|
|
new(data)
|
|
|
|
rescue Excon::Errors::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
# Invites a user (via an email) to collaborate on the currently scoped
|
|
|
|
# account at the +role+ level.
|
|
|
|
#
|
|
|
|
# @param [String] email The email address to use for the invitation
|
|
|
|
# @param [String] role The role being granted. Only (+admin+ is
|
|
|
|
# currently supported
|
|
|
|
# @return [Fog::Compute::Brightbox::Collaboration]
|
|
|
|
#
|
|
|
|
def invite(email, role)
|
|
|
|
return nil if email.nil? || email == ""
|
|
|
|
return nil if role.nil? || role == ""
|
|
|
|
options = {:email => email, :role => role}
|
|
|
|
data = service.create_collaboration(options)
|
|
|
|
new(data)
|
|
|
|
end
|
|
|
|
|
2012-10-19 11:38:44 -04:00
|
|
|
def destroy
|
|
|
|
requires :identity
|
2013-08-07 07:54:49 -04:00
|
|
|
service.destroy_collaboration(identity)
|
2012-10-19 11:38:44 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|