Class: Brightbox::Collaboration

Inherits:
Api
  • Object
show all
Defined in:
lib/brightbox-cli/collaboration.rb

Overview

These are collaborations from the perspective of the authenticated account admins. This allows creating new invites, listing, viewing, cancelling or resending emails

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api

#attributes, cache_all!, cached_get, conn, #created_on, #exists?, find, find_all_or_warn, find_by_handle, find_or_call, #fog_attributes, #fog_model, #initialize, klass_name, #method_missing, #respond_to_missing?

Constructor Details

This class inherits a constructor from Brightbox::Api

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Brightbox::Api

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



32
33
34
# File 'lib/brightbox-cli/collaboration.rb', line 32

def id
  @id
end

Class Method Details

.allObject



16
17
18
# File 'lib/brightbox-cli/collaboration.rb', line 16

def self.all
  conn.collaborations
end

.default_field_orderObject



24
25
26
# File 'lib/brightbox-cli/collaboration.rb', line 24

def self.default_field_order
  %i[id status role email name]
end

.get(id) ⇒ Object



20
21
22
# File 'lib/brightbox-cli/collaboration.rb', line 20

def self.get(id)
  conn.collaborations.get(id)
end

.invite(email, role) ⇒ Object



9
10
11
12
13
14
# File 'lib/brightbox-cli/collaboration.rb', line 9

def self.invite(email, role)
  options = { :email => email, :role => role }
  data = conn.create_collaboration(options)
  model = Fog::Brightbox::Compute::Collaboration.new(data)
  new(model)
end

.require_account?Boolean

Returns:

  • (Boolean)


7
# File 'lib/brightbox-cli/collaboration.rb', line 7

def self.require_account?; true; end

Instance Method Details

#invitee_nameObject



40
41
42
43
44
45
46
# File 'lib/brightbox-cli/collaboration.rb', line 40

def invitee_name
  if attributes[:user].nil?
    "-"
  else
    attributes[:user]["name"]
  end
end

#resendObject



48
49
50
51
# File 'lib/brightbox-cli/collaboration.rb', line 48

def resend
  data = service.resend_collaboration(id)
  fog_model.merge_attributes(data)
end

#to_rowObject



34
35
36
37
38
# File 'lib/brightbox-cli/collaboration.rb', line 34

def to_row
  attributes.merge(
    name: invitee_name
  ).to_h
end

#to_sObject



28
29
30
# File 'lib/brightbox-cli/collaboration.rb', line 28

def to_s
  @id
end