class Datacentred::Model::Project
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).
@attr [String] id @attr [String] name @attr [Hash] quota_set @attr_reader [Time] created_at @attr_reader [Time] updated_at
Public Class Methods
Add a new user to this project, giving them access to it via OpenStack.
@param [String] project_id The unique identifier for this project. @param [String] user_id The unique identifier for this user. @raise [Errors::NotFound] Raised if the project or user couldn't be found. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [Boolean] Confirms the user was added (or is already present).
# 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
List all available projects.
@raise [Errors::Unauthorized] Raised if credentials aren't valid.
@return [[Project]] A collection of all projects on this account.
# File lib/datacentred/model/project.rb, line 30 def all Request::Projects.list.map{|project| new project } end
Create a new project.
@param [Hash] params Project
attributes @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [Project] New project.
# File lib/datacentred/model/project.rb, line 22 def create(params) new Request::Projects.create params end
Permanently remove the specified project.
@param [String] id The unique identifier for this project. @raise [Errors::NotFound] Raised if the project couldn't be found. @raise [Errors::UnprocessableEntity] Raised if validations fail for the specified project. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [Boolean] Confirms the user was destroyed.
# File lib/datacentred/model/project.rb, line 63 def destroy(id) Request::Projects.destroy id true end
Find a project by unique ID.
@param [String] id The unique identifier for this project. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @raise [Errors::NotFound] Raised if the project couldn't be found. @return [Project] The project, if it exists.
# File lib/datacentred/model/project.rb, line 40 def find(id) new Request::Projects.show id end
Remove user from this project, revoking their access to it on OpenStack.
@param [String] project_id The unique identifier for this project. @param [String] user_id The unique identifier for this user. @raise [Errors::NotFound] Raised if project or user couldn't be found. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [Boolean] Confirms that user was removed (or is already absent).
# 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 a project by unique ID.
@param [String] id The unique identifier for this project. @param [Hash] params Project
attributes. @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes. @raise [Errors::NotFound] Raised if the project could not be found. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [Project] The updated project.
# File lib/datacentred/model/project.rb, line 52 def update(id, params) new Request::Projects.update id, params end
List all users assigned to this project.
@param [String] id The unique identifier for this project. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [[User]] A collection of the project's users.
# File lib/datacentred/model/project.rb, line 73 def users(id) Request::Projects.list_users(id).map{|user| new user } end