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

Inherits:
OpenStack::Model show all
Defined in:
lib/fog/identity/openstack/v3/models/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/identity/openstack/v3/models/user.rb', line 43

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

#createObject



72
73
74
75
76
77
# File 'lib/fog/identity/openstack/v3/models/user.rb', line 72

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

#destroyObject



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

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

#grant_role(role_id) ⇒ Object



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

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

#groupsObject



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

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

#projectsObject



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

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

#revoke_role(role_id) ⇒ Object



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

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

#rolesObject



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

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

#to_sObject



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

def to_s
  name
end

#update(attr = nil) ⇒ Object



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

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