Class: Gcloud::ResourceManager::Project::List
- Inherits:
-
Array
- Object
- Array
- Gcloud::ResourceManager::Project::List
- Defined in:
- lib/gcloud/resource_manager/project/list.rb
Overview
Project::List is a special case Array with additional values.
Instance Attribute Summary collapse
-
#token ⇒ Object
If not empty, indicates that there are more projects that match the request and this value should be passed to continue.
Class Method Summary collapse
Instance Method Summary collapse
-
#all ⇒ Object
Retrieves all projects by repeatedly loading pages until #next? returns false.
-
#initialize(arr = []) ⇒ List
constructor
Create a new Project::List with an array of Project instances.
-
#next ⇒ Object
Retrieve the next page of projects.
-
#next? ⇒ Boolean
Whether there a next page of projects.
Constructor Details
#initialize(arr = []) ⇒ List
Create a new Project::List with an array of Project instances.
29 30 31 |
# File 'lib/gcloud/resource_manager/project/list.rb', line 29 def initialize arr = [] super arr end |
Instance Attribute Details
#token ⇒ Object
If not empty, indicates that there are more projects that match the request and this value should be passed to continue.
25 26 27 |
# File 'lib/gcloud/resource_manager/project/list.rb', line 25 def token @token end |
Class Method Details
.from_response(resp, manager) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/gcloud/resource_manager/project/list.rb', line 69 def self.from_response resp, manager projects = new(Array(resp.data["projects"]).map do |gapi_object| Project.from_gapi gapi_object, manager.connection end) projects.instance_eval do @token = resp.data["nextPageToken"] @manager = manager end projects end |
Instance Method Details
#all ⇒ Object
Retrieves all projects by repeatedly loading pages until #next? returns false. Returns the list instance for method chaining.
58 59 60 61 62 63 64 65 |
# File 'lib/gcloud/resource_manager/project/list.rb', line 58 def all while next? next_projects = self.next push(*next_projects) self.token = next_projects.token end self end |
#next ⇒ Object
Retrieve the next page of projects.
41 42 43 44 45 |
# File 'lib/gcloud/resource_manager/project/list.rb', line 41 def next return nil unless next? ensure_manager! @manager.projects token: token end |
#next? ⇒ Boolean
Whether there a next page of projects.
35 36 37 |
# File 'lib/gcloud/resource_manager/project/list.rb', line 35 def next? !token.nil? end |