Class: Fog::Identity::OpenStack::V3::Projects
- Inherits:
-
OpenStack::Collection
- Object
- Collection
- OpenStack::Collection
- Fog::Identity::OpenStack::V3::Projects
- Defined in:
- lib/fog/openstack/models/identity_v3/projects.rb
Instance Attribute Summary
Attributes inherited from OpenStack::Collection
Instance Method Summary collapse
- #all(options = {}) ⇒ Object
- #auth_projects(options = {}) ⇒ Object
-
#find_by_id(id, options = []) ⇒ Object
options can include :subtree_as_ids, :subtree_as_list, :parents_as_ids, :parents_as_list.
Methods inherited from OpenStack::Collection
#destroy, #get, #load_response, #summary
Instance Method Details
#all(options = {}) ⇒ Object
11 12 13 |
# File 'lib/fog/openstack/models/identity_v3/projects.rb', line 11 def all( = {}) load_response(service.list_projects(), 'projects') end |
#auth_projects(options = {}) ⇒ Object
15 16 17 |
# File 'lib/fog/openstack/models/identity_v3/projects.rb', line 15 def auth_projects( = {}) load(service.auth_projects().body['projects']) end |
#find_by_id(id, options = []) ⇒ Object
options can include :subtree_as_ids, :subtree_as_list, :parents_as_ids, :parents_as_list
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fog/openstack/models/identity_v3/projects.rb', line 19 def find_by_id(id, =[]) # options can include :subtree_as_ids, :subtree_as_list, :parents_as_ids, :parents_as_list if .is_a? Symbol # Deal with a single option being passed on its own = [] end cached_project = self.find { |project| project.id == id } if .empty? return cached_project if cached_project project_hash = service.get_project(id, ).body['project'] top_project = project_from_hash(project_hash, service) if .include? :subtree_as_list top_project.subtree.map! {|proj_hash| project_from_hash(proj_hash['project'], service)} end if .include? :parents_as_list top_project.parents.map! {|proj_hash| project_from_hash(proj_hash['project'], service)} end return top_project end |