class Datacentred::Request::Projects
RESTful API requests for the projects endpoints.
Public Class Methods
Add a new user to this project, giving them access to it via OpenStack.
PUT /api/projects/ead738d9f894bed9/users/82fa8de8f09102cc
@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 [nil] Confirms the user was added (or is already present).
# File lib/datacentred/request/projects.rb, line 87 def add_user(project_id, user_id) put("projects/#{project_id}/users/#{user_id}") end
Create a new project.
POST /api/projects
@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 [Hash] New project.
# File lib/datacentred/request/projects.rb, line 14 def create(params) post('projects', 'project' => params)['project'] end
Permanently remove the specified project.
DELETE /api/projects/ead738d9f894bed9
@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 [nil] Confirms the user was destroyed.
# File lib/datacentred/request/projects.rb, line 63 def destroy(id) delete("projects/#{id}") end
List all available projects.
GET /api/projects
@raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [[Hash]] A collection of all projects on this account.
# File lib/datacentred/request/projects.rb, line 24 def list get('projects')['projects'] end
List all users assigned to this project.
GET /api/projects/ead738d9f894bed9/users
@param [String] id The unique identifier for this project. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [[Hash]] A collection of the project's users.
# File lib/datacentred/request/projects.rb, line 74 def list_users(id) get("projects/#{id}/users")['users'] end
Remove user from this project, revoking their access to it on OpenStack.
DELETE /api/projects/ead738d9f894bed9/users/82fa8de8f09102cc
@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 [nil] Confirms that user was removed (or is already absent).
# File lib/datacentred/request/projects.rb, line 100 def remove_user(project_id, user_id) delete("projects/#{project_id}/users/#{user_id}") end
Find a project by unique ID.
GET /api/projects/ead738d9f894bed9
@param [String] id The unique identifier for this project. @raise [Errors::NotFound] Raised if the project couldn't be found. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [Hash] The project, if it exists.
# File lib/datacentred/request/projects.rb, line 36 def show(id) get("projects/#{id}")['project'] end
Update a project by unique ID.
PUT /api/projects/ead738d9f894bed9
@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 [Hash] The updated project.
# File lib/datacentred/request/projects.rb, line 50 def update(id, params) put("projects/#{id}", 'project' => params)['project'] end