Class: Fog::Identity::OpenStack::V3::Project

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

Instance Attribute Summary

Attributes inherited from OpenStack::Model

#project

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenStack::Model

#initialize, #save

Constructor Details

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

Class Method Details

.use_cache(cache) ⇒ Object



99
100
101
# File 'lib/fog/openstack/models/identity_v3/project.rb', line 99

def self.use_cache(cache)
  @@cache = cache
end

Instance Method Details

#check_group_role(group_id, role_id) ⇒ Object



83
84
85
86
87
88
89
90
91
# File 'lib/fog/openstack/models/identity_v3/project.rb', line 83

def check_group_role(group_id, role_id)
  requires :id
  begin
    service.check_project_group_role(self.id, group_id, role_id)
  rescue Fog::Identity::OpenStack::NotFound
    return false
  end
  return true
end

#check_user_role(user_id, role_id) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/fog/openstack/models/identity_v3/project.rb', line 56

def check_user_role(user_id, role_id)
  requires :id
  begin
    service.check_project_user_role(self.id, user_id, role_id)
  rescue Fog::Identity::OpenStack::NotFound
    return false
  end
  return true
end

#createObject



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

def create
  @@cache.clear if @@cache
  merge_attributes(
      service.create_project(attributes).body['project'])
  self
end

#destroyObject



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

def destroy
  @@cache.clear if @@cache
  requires :id
  service.delete_project(self.id)
  true
end

#grant_role_to_group(role_id, group_id) ⇒ Object



77
78
79
80
81
# File 'lib/fog/openstack/models/identity_v3/project.rb', line 77

def grant_role_to_group(role_id, group_id)
  @@cache.clear if @@cache
  requires :id
  service.grant_project_group_role(self.id, group_id, role_id)
end

#grant_role_to_user(role_id, user_id) ⇒ Object



50
51
52
53
54
# File 'lib/fog/openstack/models/identity_v3/project.rb', line 50

def grant_role_to_user(role_id, user_id)
  @@cache.clear if @@cache
  requires :id
  service.grant_project_user_role(self.id, user_id, role_id)
end

#group_roles(group_id) ⇒ Object



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

def group_roles(group_id)
  requires :id
  service.list_project_group_roles(self.id, group_id).body['roles']
end

#revoke_role_from_group(role_id, group_id) ⇒ Object



93
94
95
96
97
# File 'lib/fog/openstack/models/identity_v3/project.rb', line 93

def revoke_role_from_group(role_id, group_id)
  @@cache.clear if @@cache
  requires :id
  service.revoke_project_group_role(self.id, group_id, role_id)
end

#revoke_role_from_user(role_id, user_id) ⇒ Object



66
67
68
69
70
# File 'lib/fog/openstack/models/identity_v3/project.rb', line 66

def revoke_role_from_user(role_id, user_id)
  @@cache.clear if @@cache
  requires :id
  service.revoke_project_user_role(self.id, user_id, role_id)
end

#to_sObject



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

def to_s
  self.name
end

#update(attr = nil) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/fog/openstack/models/identity_v3/project.rb', line 30

def update(attr = nil)
  @@cache.clear if @@cache
  requires :id
  merge_attributes(
      service.update_project(self.id, attr || attributes).body['project'])
  self
end

#user_roles(user_id) ⇒ Object



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

def user_roles(user_id)
  requires :id
  service.list_project_user_roles(self.id, user_id).body['roles']
end