Class: Datacentred::Model::Project
- Defined in:
- lib/datacentred/model/project.rb
Overview
A project on your DataCentred account.
Projects (also called “Cloud Projects” or “Tenants”) are a way of grouping together users and resources.
All projects created in your DataCented account are backed by a corresponding project in OpenStack's identity service (Keystone).
Instance Attribute Summary collapse
-
#created_at ⇒ Time
readonly
The current value of created_at.
-
#id ⇒ String
The current value of id.
-
#name ⇒ String
The current value of name.
-
#quota_set ⇒ Hash
The current value of quota_set.
-
#updated_at ⇒ Time
readonly
The current value of updated_at.
Class Method Summary collapse
-
.add_user(project_id:, user_id:) ⇒ Boolean
Add a new user to this project, giving them access to it via OpenStack.
-
.all ⇒ [Project]
List all available projects.
-
.create(params) ⇒ Project
Create a new project.
-
.destroy(id) ⇒ Boolean
Permanently remove the specified project.
-
.find(id) ⇒ Project
Find a project by unique ID.
-
.remove_user(project_id:, user_id:) ⇒ Boolean
Remove user from this project, revoking their access to it on OpenStack.
-
.update(id, params) ⇒ Project
Update a project by unique ID.
-
.users(id) ⇒ [User]
List all users assigned to this project.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Datacentred::Model::Base
Instance Attribute Details
#created_at ⇒ Time (readonly)
Returns the current value of created_at
14 15 16 |
# File 'lib/datacentred/model/project.rb', line 14 def created_at @created_at end |
#id ⇒ String
Returns the current value of id
14 15 16 |
# File 'lib/datacentred/model/project.rb', line 14 def id @id end |
#name ⇒ String
Returns the current value of name
14 15 16 |
# File 'lib/datacentred/model/project.rb', line 14 def name @name end |
#quota_set ⇒ Hash
Returns the current value of quota_set
14 15 16 |
# File 'lib/datacentred/model/project.rb', line 14 def quota_set @quota_set end |
#updated_at ⇒ Time (readonly)
Returns the current value of updated_at
14 15 16 |
# File 'lib/datacentred/model/project.rb', line 14 def updated_at @updated_at end |
Class Method Details
.add_user(project_id:, user_id:) ⇒ Boolean
Add a new user to this project, giving them access to it via OpenStack.
84 85 86 87 |
# File 'lib/datacentred/model/project.rb', line 84 def add_user(project_id:, user_id:) Request::Projects.add_user project_id, user_id true end |
.all ⇒ [Project]
List all available projects.
@raise [Errors::Unauthorized] Raised if credentials aren't valid.
30 31 32 |
# File 'lib/datacentred/model/project.rb', line 30 def all Request::Projects.list.map{|project| new project } end |
.create(params) ⇒ Project
Create a new project.
22 23 24 |
# File 'lib/datacentred/model/project.rb', line 22 def create(params) new Request::Projects.create params end |
.destroy(id) ⇒ Boolean
Permanently remove the specified project.
63 64 65 66 |
# File 'lib/datacentred/model/project.rb', line 63 def destroy(id) Request::Projects.destroy id true end |
.find(id) ⇒ Project
Find a project by unique ID.
40 41 42 |
# File 'lib/datacentred/model/project.rb', line 40 def find(id) new Request::Projects.show id end |
.remove_user(project_id:, user_id:) ⇒ Boolean
Remove user from this project, revoking their access to it on OpenStack.
96 97 98 99 |
# File 'lib/datacentred/model/project.rb', line 96 def remove_user(project_id:, user_id:) Request::Projects.remove_user project_id, user_id true end |
.update(id, params) ⇒ Project
Update a project by unique ID.
52 53 54 |
# File 'lib/datacentred/model/project.rb', line 52 def update(id, params) new Request::Projects.update id, params end |
.users(id) ⇒ [User]
List all users assigned to this project.
73 74 75 |
# File 'lib/datacentred/model/project.rb', line 73 def users(id) Request::Projects.list_users(id).map{|user| new user } end |