Class: Google::Cloud::ResourceManager::Manager
- Inherits:
-
Object
- Object
- Google::Cloud::ResourceManager::Manager
- Defined in:
- lib/google/cloud/resource_manager/manager.rb
Overview
Manager
Provides methods for creating, retrieving, and updating projects.
Instance Method Summary collapse
-
#create_project(project_id, name: nil, labels: nil) ⇒ Google::Cloud::ResourceManager::Project
Creates a project resource.
-
#delete(project_id) ⇒ Object
Marks the project for deletion.
-
#project(project_id) ⇒ Google::Cloud::ResourceManager::Project?
Retrieves the project identified by the specified
project_id
. -
#projects(filter: nil, token: nil, max: nil) ⇒ Array<Google::Cloud::ResourceManager::Project>
Retrieves the projects that are visible to the user and satisfy the specified filter.
-
#undelete(project_id) ⇒ Object
Restores the project.
Instance Method Details
#create_project(project_id, name: nil, labels: nil) ⇒ Google::Cloud::ResourceManager::Project
Creates a project resource.
Initially, the project resource is owned by its creator exclusively. The creator can later grant permission to others to read or update the project.
Several APIs are activated automatically for the project, including Google Cloud Storage.
192 193 194 195 |
# File 'lib/google/cloud/resource_manager/manager.rb', line 192 def create_project project_id, name: nil, labels: nil gapi = service.create_project project_id, name, labels Project.from_gapi gapi, service end |
#delete(project_id) ⇒ Object
Marks the project for deletion. This method will only affect the project if the following criteria are met:
- The project does not have a billing account associated with it.
- The project has a lifecycle state of
ACTIVE
. - This method changes the project's lifecycle state from
ACTIVE
toDELETE_REQUESTED
. The deletion starts at an unspecified time, at which point the lifecycle state changes toDELETE_IN_PROGRESS
.
Until the deletion completes, you can check the lifecycle state by retrieving the project with Manager#project. The project remains visible to Manager#project and Manager#projects, but cannot be updated.
After the deletion completes, the project is not retrievable by the Manager#project and Manager#projects methods.
The caller must have modify permissions for this project.
226 227 228 229 |
# File 'lib/google/cloud/resource_manager/manager.rb', line 226 def delete project_id service.delete_project project_id true end |
#project(project_id) ⇒ Google::Cloud::ResourceManager::Project?
Retrieves the project identified by the specified project_id
.
138 139 140 141 142 143 |
# File 'lib/google/cloud/resource_manager/manager.rb', line 138 def project project_id gapi = service.get_project project_id Project.from_gapi gapi, service rescue NotFoundError nil end |
#projects(filter: nil, token: nil, max: nil) ⇒ Array<Google::Cloud::ResourceManager::Project>
Retrieves the projects that are visible to the user and satisfy the specified filter. This method returns projects in an unspecified order. New projects do not necessarily appear at the end of the list.
117 118 119 120 |
# File 'lib/google/cloud/resource_manager/manager.rb', line 117 def projects filter: nil, token: nil, max: nil gapi = service.list_project filter: filter, token: token, max: max Project::List.from_gapi gapi, self, filter, max end |
#undelete(project_id) ⇒ Object
Restores the project. You can only use this method for a project that
has a lifecycle state of DELETE_REQUESTED
. After deletion starts, as
indicated by a lifecycle state of DELETE_IN_PROGRESS
, the project
cannot be restored.
The caller must have modify permissions for this project.
248 249 250 251 |
# File 'lib/google/cloud/resource_manager/manager.rb', line 248 def undelete project_id service.undelete_project project_id true end |