Projects#
Utility for managing projects via the Cloud Resource Manager API.
-
class
gcloud.resource_manager.project.Project(project_id, client, name=None, labels=None)[source]# Bases:
objectProjects are containers for your work on Google Cloud Platform.
Note
A
Projectcan also be created viaClient.new_project()To manage labels on a
Project:>>> from gcloud import resource_manager >>> client = resource_manager.Client() >>> project = client.new_project('purple-spaceship-123') >>> project.labels = {'color': 'purple'} >>> project.labels['environment'] = 'production' >>> project.update()
See: https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects
Parameters: - project_id (string) – The globally unique ID of the project.
- client (
gcloud.resource_manager.client.Client) – The Client used with this project. - name (string) – The display name of the project.
- labels (dict) – A list of labels associated with the project.
-
create(client=None)[source]# API call: create the project via a
POSTrequest.See https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/create
Parameters: client ( gcloud.resource_manager.client.ClientorNoneType) – the client to use. If not passed, falls back to the client stored on the current project.
-
delete(client=None, reload_data=False)[source]# API call: delete the project via a
DELETErequest.See: https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/delete
This actually changes the status (
lifecycleState) fromACTIVEtoDELETE_REQUESTED. Later (it’s not specified when), the project will move into theDELETE_IN_PROGRESSstate, which means the deleting has actually begun.Parameters: - client (
gcloud.resource_manager.client.ClientorNoneType) – the client to use. If not passed, falls back to the client stored on the current project. - reload_data (bool) – Whether to reload the project with the latest
state. If you want to get the updated status,
you’ll want this set to
Trueas the DELETE method doesn’t send back the updated project. Default:False.
- client (
-
exists(client=None)[source]# API call: test the existence of a project via a
GETrequest.See https://cloud.google.com/pubsub/reference/rest/v1beta2/projects/projects/get
Parameters: client ( gcloud.resource_manager.client.ClientorNoneType) – the client to use. If not passed, falls back to the client stored on the current project.
-
classmethod
from_api_repr(resource, client)[source]# Factory: construct a project given its API representation.
Parameters: - resource (dict) – project resource representation returned from the API
- client (
gcloud.resource_manager.client.Client) – The Client used with this project.
Return type:
-
full_name# Fully-qualified name (ie,
'projects/purple-spaceship-123').
-
path# URL for the project (ie,
'/projects/purple-spaceship-123').
-
reload(client=None)[source]# API call: reload the project via a
GETrequest.This method will reload the newest metadata for the project. If you’ve created a new
Projectinstance viaClient.new_project(), this method will retrieve project metadata.Warning
This will overwrite any local changes you’ve made and not saved via
update().See https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/get
Parameters: client ( gcloud.resource_manager.client.ClientorNoneType) – the client to use. If not passed, falls back to the client stored on the current project.
-
set_properties_from_api_repr(resource)[source]# Update specific properties from its API representation.
-
undelete(client=None, reload_data=False)[source]# API call: undelete the project via a
POSTrequest.See https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/undelete
This actually changes the project status (
lifecycleState) fromDELETE_REQUESTEDtoACTIVE. If the project has already reached a status ofDELETE_IN_PROGRESS, this request will fail and the project cannot be restored.Parameters: - client (
gcloud.resource_manager.client.ClientorNoneType) – the client to use. If not passed, falls back to the client stored on the current project. - reload_data (bool) – Whether to reload the project with the latest
state. If you want to get the updated status,
you’ll want this set to
Trueas the DELETE method doesn’t send back the updated project. Default:False.
- client (
-
update(client=None)[source]# API call: update the project via a
PUTrequest.See https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/update
Parameters: client ( gcloud.resource_manager.client.ClientorNoneType) – the client to use. If not passed, falls back to the client stored on the current project.