Skip to main content

projects

Creates, updates, deletes, gets or lists a projects resource.

Overview

Nameprojects
TypeResource
Idgoogle.cloudresourcemanager.projects

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringOutput only. The unique resource name of the project. It is an int64 generated number prefixed by "projects/". Example: projects/415104041262
configuredCapabilitiesarrayOutput only. If this project is a Management Project, list of capabilities configured on the parent folder. Note, presence of any capability implies that this is a Management Project. Example: folders/123/capabilities/app-management. OUTPUT ONLY.
createTimestring (google-datetime)Output only. Creation time.
deleteTimestring (google-datetime)Output only. The time at which this resource was requested for deletion.
displayNamestringOptional. A user-assigned display name of the project. When present it must be between 4 to 30 characters. Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. Example: My Project
etagstringOutput only. A checksum computed by the server based on the current value of the Project resource. This may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
labelsobjectOptional. The labels associated with this project. Label keys must be between 1 and 63 characters long and must conform to the following regular expression: [a-z]([-a-z0-9][a-z0-9])?. Label values must be between 0 and 63 characters long and must conform to the regular expression ([a-z]([-a-z0-9][a-z0-9])?)?. No more than 64 labels can be associated with a given resource. Clients should store labels in a representation such as JSON that does not depend on specific characters being disallowed. Example: "myBusinessDimension" : "businessValue"
parentstringOptional. A reference to a parent Resource. eg., organizations/123 or folders/876.
projectIdstringImmutable. The unique, user-assigned id of the project. It must be 6 to 30 lowercase ASCII letters, digits, or hyphens. It must start with a letter. Trailing hyphens are prohibited. Example: tokyo-rain-123
statestringOutput only. The project lifecycle state.
tagsobjectOptional. Input only. Immutable. Tag keys/values directly bound to this project. Each item in the map must be expressed as " : ". For example: "123/environment" : "production", "123/costCenter" : "marketing" Note: Currently this field is in Preview.
updateTimestring (google-datetime)Output only. The most recent time this resource was modified.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsIdRetrieves the project identified by the specified name (for example, projects/415104041262). The caller must have resourcemanager.projects.get permission for this project.
listselectparent, pageToken, pageSize, showDeletedLists projects that are direct children of the specified folder or organization resource. list() provides a strongly consistent view of the projects underneath the specified parent resource. list() returns projects sorted based upon the (ascending) lexical ordering of their display_name. The caller must have resourcemanager.projects.list permission on the identified parent.
createinsertRequest that a new project be created. The result is an Operation which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking Operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
patchupdateprojectsIdupdateMaskUpdates the display_name and labels of the project identified by the specified name (for example, projects/415104041262). Deleting all labels requires an update mask for labels field. The caller must have resourcemanager.projects.update permission for this project.
deletedeleteprojectsIdMarks the project identified by the specified name (for example, projects/415104041262) for deletion. This method will only affect the project if it has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the project with GetProject, and the project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the project is not retrievable by the GetProject, ListProjects, and SearchProjects methods. The caller must have resourcemanager.projects.delete permissions for this project.
searchexecquery, pageToken, pageSizeSearch for projects that the caller has the resourcemanager.projects.get permission on, and also satisfy the specified query. This method returns projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the GetProject method.
moveexecprojectsIdMove a project to another place in your resource hierarchy, under a new resource parent. Returns an operation which can be used to track the process of the project move workflow. Upon success, the Operation.response field will be populated with the moved project. The caller must have resourcemanager.projects.move permission on the project, on the project's current and proposed new parent. If project has no current parent, or it currently does not have an associated organization resource, you will also need the resourcemanager.projects.setIamPolicy permission in the project.
undeleteexecprojectsIdRestores the project identified by the specified name (for example, projects/415104041262). You can only use this method for a project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the project cannot be restored. The caller must have resourcemanager.projects.undelete permission for this project.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
projectsIdstring
pageSizeinteger (int32)
pageTokenstring
parentstring
querystring
showDeletedboolean
updateMaskstring (google-fieldmask)

SELECT examples

Retrieves the project identified by the specified name (for example, projects/415104041262). The caller must have resourcemanager.projects.get permission for this project.

SELECT
name,
configuredCapabilities,
createTime,
deleteTime,
displayName,
etag,
labels,
parent,
projectId,
state,
tags,
updateTime
FROM google.cloudresourcemanager.projects
WHERE projectsId = '{{ projectsId }}' -- required;

INSERT examples

Request that a new project be created. The result is an Operation which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking Operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.

INSERT INTO google.cloudresourcemanager.projects (
data__parent,
data__projectId,
data__displayName,
data__labels,
data__tags
)
SELECT
'{{ parent }}',
'{{ projectId }}',
'{{ displayName }}',
'{{ labels }}',
'{{ tags }}'
RETURNING
name,
done,
error,
metadata,
response
;

UPDATE examples

Updates the display_name and labels of the project identified by the specified name (for example, projects/415104041262). Deleting all labels requires an update mask for labels field. The caller must have resourcemanager.projects.update permission for this project.

UPDATE google.cloudresourcemanager.projects
SET
data__parent = '{{ parent }}',
data__projectId = '{{ projectId }}',
data__displayName = '{{ displayName }}',
data__labels = '{{ labels }}',
data__tags = '{{ tags }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
done,
error,
metadata,
response;

DELETE examples

Marks the project identified by the specified name (for example, projects/415104041262) for deletion. This method will only affect the project if it has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the project with GetProject, and the project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the project is not retrievable by the GetProject, ListProjects, and SearchProjects methods. The caller must have resourcemanager.projects.delete permissions for this project.

DELETE FROM google.cloudresourcemanager.projects
WHERE projectsId = '{{ projectsId }}' --required;

Lifecycle Methods

Search for projects that the caller has the resourcemanager.projects.get permission on, and also satisfy the specified query. This method returns projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the GetProject method.

EXEC google.cloudresourcemanager.projects.search 
@query='{{ query }}',
@pageToken='{{ pageToken }}',
@pageSize='{{ pageSize }}';