Class: RestUser

Inherits:
OpenShift::Model
  • Object
show all
Defined in:
app/models/rest_user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cloud_user, url, nolinks = false) ⇒ RestUser

Returns a new instance of RestUser.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/rest_user.rb', line 4

def initialize(cloud_user, url, nolinks=false)
  self. = cloud_user.
  self.consumed_gears = cloud_user.consumed_gears
  self.max_gears = cloud_user.max_gears
  self.capabilities = cloud_user.capabilities
  self.plan_id = cloud_user.plan_id
  self. = cloud_user.

  unless nolinks
    @links = {
      "LIST_KEYS" => Link.new("Get SSH keys", "GET", URI::join(url, "user/keys")),
      "ADD_KEY" => Link.new("Add new SSH key", "POST", URI::join(url, "user/keys"), [
        Param.new("name", "string", "Name of the key"),
        Param.new("type", "string", "Type of Key", Key::VALID_SSH_KEY_TYPES),
        Param.new("content", "string", "The key portion of an ssh key (excluding ssh type and comment)"),
      ])
    }
    @links["DELETE_USER"] = Link.new("Delete user. Only applicable for subaccount users.", "DELETE", URI::join(url, "user"), nil, [
      OptionalParam.new("force", "boolean", "Force delete user. i.e. delete any domains and applications under this user", [true, false], false)
    ]) if cloud_user.
  end

  consumed_map = {}
  if cloud_user.applications
    cloud_user.applications.each { |a|
      a.gears.each { |g|
        size = g.node_profile || Application.DEFAULT_NODE_PROFILE
        consumed_map[size] = 0 if not consumed_map.has_key? size
        consumed_map[size] = consumed_map[size] +1
      }
    }
  end
  self.consumed_gear_sizes = consumed_map
end

Instance Attribute Details

#capabilitiesObject

Returns the value of attribute capabilities.



2
3
4
# File 'app/models/rest_user.rb', line 2

def capabilities
  @capabilities
end

#consumed_gear_sizesObject

Returns the value of attribute consumed_gear_sizes.



2
3
4
# File 'app/models/rest_user.rb', line 2

def consumed_gear_sizes
  @consumed_gear_sizes
end

#consumed_gearsObject

Returns the value of attribute consumed_gears.



2
3
4
# File 'app/models/rest_user.rb', line 2

def consumed_gears
  @consumed_gears
end

Returns the value of attribute links.



2
3
4
# File 'app/models/rest_user.rb', line 2

def links
  @links
end

#loginObject

Returns the value of attribute login.



2
3
4
# File 'app/models/rest_user.rb', line 2

def 
  @login
end

#max_gearsObject

Returns the value of attribute max_gears.



2
3
4
# File 'app/models/rest_user.rb', line 2

def max_gears
  @max_gears
end

#plan_idObject

Returns the value of attribute plan_id.



2
3
4
# File 'app/models/rest_user.rb', line 2

def plan_id
  @plan_id
end

#usage_account_idObject

Returns the value of attribute usage_account_id.



2
3
4
# File 'app/models/rest_user.rb', line 2

def 
  @usage_account_id
end

Instance Method Details

#to_xml(options = {}) ⇒ Object



39
40
41
42
# File 'app/models/rest_user.rb', line 39

def to_xml(options={})
  options[:tag_name] = "user"
  super(options)
end