1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #2044 from brightbox/collaboration_updates

[Brightbox] Collaboration model updates
This commit is contained in:
Paul Thornthwaite 2013-08-07 07:58:12 -07:00
commit 5e72c08bf5
4 changed files with 62 additions and 7 deletions

View file

@ -25,14 +25,22 @@ module Fog
:email => email
}.delete_if { |k, v| v.nil? || v == "" }
data = connection.create_collaboration(options)
data = service.create_collaboration(options)
merge_attributes(data)
true
end
def resend
requires :identity
data = service.resend_collaboration(identity)
merge_attributes(data)
true
end
def destroy
requires :identity
connection.destroy_collaboration(identity)
data = service.destroy_collaboration(identity)
merge_attributes(data)
true
end

View file

@ -8,13 +8,37 @@ module Fog
model Fog::Compute::Brightbox::Collaboration
def all
data = connection.list_collaborations
data = service.list_collaborations
load(data)
end
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
def destroy
requires :identity
connection.destroy_collaboration(identity)
service.destroy_collaboration(identity)
true
end
end

View file

@ -17,9 +17,24 @@ module Fog
account['id'] || account[:id]
end
def accept
requires :identity
data = service.accept_user_collaboration(identity)
merge_attributes(data)
true
end
def reject
requires :identity
data = service.reject_user_collaboration(identity)
merge_attributes(data)
true
end
def destroy
requires :identity
connection.destroy_user_collaboration(identity)
data = service.destroy_user_collaboration(identity)
merge_attributes(data)
true
end

View file

@ -8,13 +8,21 @@ module Fog
model Fog::Compute::Brightbox::UserCollaboration
def all
data = connection.list_user_collaborations
data = service.list_user_collaborations
load(data)
end
def get(identifier)
return nil if identifier.nil? || identifier == ""
data = service.get_user_collaboration(identifier)
new(data)
rescue Excon::Errors::NotFound
nil
end
def destroy
requires :identity
connection.destroy_user_collaboration(identity)
service.destroy_user_collaboration(identity)
true
end
end