Class: Fog::Identity::OpenStack::V3::User

Inherits:
OpenStack::Model show all
Defined in:
lib/fog/openstack/models/identity_v3/user.rb

Instance Attribute Summary

Attributes inherited from OpenStack::Model

#project

Instance Method Summary collapse

Methods inherited from OpenStack::Model

#initialize, #save

Constructor Details

This class inherits a constructor from Fog::OpenStack::Model

Instance Method Details

#check_role(role_id) ⇒ Object


43
44
45
46
47
48
49
50
51
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 43

def check_role(role_id)
  requires :id, :domain_id
  begin
    service.check_domain_user_role(self.domain_id, self.id, role_id)
  rescue Fog::Identity::OpenStack::NotFound
    return false
  end
  return true
end

#createObject


71
72
73
74
75
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 71

def create
  merge_attributes(
      service.create_user(attributes).body['user'])
  self
end

#destroyObject


58
59
60
61
62
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 58

def destroy
  requires :id
  service.delete_user(self.id)
  true
end

#grant_role(role_id) ⇒ Object


38
39
40
41
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 38

def grant_role(role_id)
  requires :id, :domain_id
  service.grant_domain_user_role(self.domain_id, self.id, role_id)
end

#groupsObject


23
24
25
26
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 23

def groups
  requires :id
  service.list_user_groups(self.id).body['groups']
end

#projectsObject


28
29
30
31
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 28

def projects
  requires :id
  service.list_user_projects(self.id).body['projects']
end

#revoke_role(role_id) ⇒ Object


53
54
55
56
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 53

def revoke_role(role_id)
  requires :id, :domain_id
  service.revoke_domain_user_role(self.domain_id, self.id, role_id)
end

#rolesObject


33
34
35
36
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 33

def roles
  requires :id, :domain_id
  service.list_domain_user_roles(self.domain_id, self.id).body['roles']
end

#to_sObject


19
20
21
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 19

def to_s
  self.name
end

#update(attr = nil) ⇒ Object


64
65
66
67
68
69
# File 'lib/fog/openstack/models/identity_v3/user.rb', line 64

def update(attr = nil)
  requires :id
  merge_attributes(
      service.update_user(self.id, attr || attributes).body['user'])
  self
end