Class: Fog::OpenStack::Identity::V3::Group

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/openstack/identity/v3/models/group.rb

Instance Attribute Summary

Attributes inherited from Model

#project

Instance Method Summary collapse

Methods inherited from Model

#initialize, #save

Constructor Details

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

Instance Method Details

#add_user(user_id) ⇒ Object



41
42
43
44
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 41

def add_user(user_id)
  requires :id
  service.add_user_to_group(id, user_id)
end

#check_role(role_id) ⇒ Object



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

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

#contains_user?(user_id) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 51

def contains_user?(user_id)
  requires :id
  begin
    service.group_user_check(id, user_id)
  rescue Fog::OpenStack::Identity::NotFound
    return false
  end
  true
end

#createObject



33
34
35
36
37
38
39
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 33

def create
  requires :name
  merge_attributes(
    service.create_group(attributes).body['group']
  )
  self
end

#destroyObject



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

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

#grant_role(role_id) ⇒ Object



66
67
68
69
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 66

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

#remove_user(user_id) ⇒ Object



46
47
48
49
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 46

def remove_user(user_id)
  requires :id
  service.remove_user_from_group(id, user_id)
end

#revoke_role(role_id) ⇒ Object



81
82
83
84
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 81

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

#rolesObject



61
62
63
64
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 61

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

#to_sObject



15
16
17
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 15

def to_s
  name
end

#update(attr = nil) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 25

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

#users(attr = {}) ⇒ Object



86
87
88
89
# File 'lib/fog/openstack/identity/v3/models/group.rb', line 86

def users(attr = {})
  requires :id
  service.list_group_users(id, attr).body['users']
end