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

Inherits:
OpenStack::Model show all
Defined in:
lib/fog/openstack/models/identity_v3/group.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

#add_user(user_id) ⇒ Object



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

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

#check_role(role_id) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/fog/openstack/models/identity_v3/group.rb', line 69

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

#contains_user?(user_id) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
57
# File 'lib/fog/openstack/models/identity_v3/group.rb', line 49

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

#createObject



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

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

#destroyObject



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

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

#grant_role(role_id) ⇒ Object



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

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

#remove_user(user_id) ⇒ Object



44
45
46
47
# File 'lib/fog/openstack/models/identity_v3/group.rb', line 44

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

#revoke_role(role_id) ⇒ Object



79
80
81
82
# File 'lib/fog/openstack/models/identity_v3/group.rb', line 79

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

#rolesObject



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

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

#to_sObject



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

def to_s
  self.name
end

#update(attr = nil) ⇒ Object



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

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

#users(attr = {}) ⇒ Object



84
85
86
87
# File 'lib/fog/openstack/models/identity_v3/group.rb', line 84

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