Class ProjectsClient (1.23.0)

public class ProjectsClient implements BackgroundResource

Service Description: Manages Google Cloud Projects.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ProjectName name = ProjectName.of("[PROJECT]");
   Project response = projectsClient.getProject(name);
 }
 

Note: close() needs to be called on the ProjectsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ProjectsSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ProjectsSettings projectsSettings =
     ProjectsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ProjectsClient projectsClient = ProjectsClient.create(projectsSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ProjectsSettings projectsSettings =
     ProjectsSettings.newBuilder().setEndpoint(myEndpoint).build();
 ProjectsClient projectsClient = ProjectsClient.create(projectsSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ProjectsSettings projectsSettings = ProjectsSettings.newHttpJsonBuilder().build();
 ProjectsClient projectsClient = ProjectsClient.create(projectsSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ProjectsClient

Implements

BackgroundResource

Static Methods

create()

public static final ProjectsClient create()

Constructs an instance of ProjectsClient with default settings.

Returns
TypeDescription
ProjectsClient
Exceptions
TypeDescription
IOException

create(ProjectsSettings settings)

public static final ProjectsClient create(ProjectsSettings settings)

Constructs an instance of ProjectsClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsProjectsSettings
Returns
TypeDescription
ProjectsClient
Exceptions
TypeDescription
IOException

create(ProjectsStub stub)

public static final ProjectsClient create(ProjectsStub stub)

Constructs an instance of ProjectsClient, using the given stub for making calls. This is for advanced usage - prefer using create(ProjectsSettings).

Parameter
NameDescription
stubProjectsStub
Returns
TypeDescription
ProjectsClient

Constructors

ProjectsClient(ProjectsSettings settings)

protected ProjectsClient(ProjectsSettings settings)

Constructs an instance of ProjectsClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
NameDescription
settingsProjectsSettings

ProjectsClient(ProjectsStub stub)

protected ProjectsClient(ProjectsStub stub)
Parameter
NameDescription
stubProjectsStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

createProjectAsync(CreateProjectRequest request)

public final OperationFuture<Project,CreateProjectMetadata> createProjectAsync(CreateProjectRequest request)

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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   CreateProjectRequest request =
       CreateProjectRequest.newBuilder().setProject(Project.newBuilder().build()).build();
   Project response = projectsClient.createProjectAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateProjectRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Project,CreateProjectMetadata>

createProjectAsync(Project project)

public final OperationFuture<Project,CreateProjectMetadata> createProjectAsync(Project project)

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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   Project project = Project.newBuilder().build();
   Project response = projectsClient.createProjectAsync(project).get();
 }
 
Parameter
NameDescription
projectProject

Required. The Project to create.

Project ID is required. If the requested ID is unavailable, the request fails.

If the parent field is set, the resourcemanager.projects.create permission is checked on the parent resource. If no parent is set and the authorization credentials belong to an Organization, the parent will be set to that Organization.

Returns
TypeDescription
OperationFuture<Project,CreateProjectMetadata>

createProjectCallable()

public final UnaryCallable<CreateProjectRequest,Operation> createProjectCallable()

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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   CreateProjectRequest request =
       CreateProjectRequest.newBuilder().setProject(Project.newBuilder().build()).build();
   ApiFuture<Operation> future = projectsClient.createProjectCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateProjectRequest,Operation>

createProjectOperationCallable()

public final OperationCallable<CreateProjectRequest,Project,CreateProjectMetadata> createProjectOperationCallable()

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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   CreateProjectRequest request =
       CreateProjectRequest.newBuilder().setProject(Project.newBuilder().build()).build();
   OperationFuture<Project, CreateProjectMetadata> future =
       projectsClient.createProjectOperationCallable().futureCall(request);
   // Do something.
   Project response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<CreateProjectRequest,Project,CreateProjectMetadata>

deleteProjectAsync(DeleteProjectRequest request)

public final OperationFuture<Project,DeleteProjectMetadata> deleteProjectAsync(DeleteProjectRequest request)

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] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project.

After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and SearchProjects methods.

This method behaves idempotently, such that deleting a DELETE_REQUESTED project will not cause an error, but also won't do anything.

The caller must have resourcemanager.projects.delete permissions for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   DeleteProjectRequest request =
       DeleteProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build();
   Project response = projectsClient.deleteProjectAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteProjectRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Project,DeleteProjectMetadata>

deleteProjectAsync(ProjectName name)

public final OperationFuture<Project,DeleteProjectMetadata> deleteProjectAsync(ProjectName name)

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] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project.

After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and SearchProjects methods.

This method behaves idempotently, such that deleting a DELETE_REQUESTED project will not cause an error, but also won't do anything.

The caller must have resourcemanager.projects.delete permissions for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ProjectName name = ProjectName.of("[PROJECT]");
   Project response = projectsClient.deleteProjectAsync(name).get();
 }
 
Parameter
NameDescription
nameProjectName

Required. The name of the Project (for example, projects/415104041262).

Returns
TypeDescription
OperationFuture<Project,DeleteProjectMetadata>

deleteProjectAsync(String name)

public final OperationFuture<Project,DeleteProjectMetadata> deleteProjectAsync(String name)

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] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project.

After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and SearchProjects methods.

This method behaves idempotently, such that deleting a DELETE_REQUESTED project will not cause an error, but also won't do anything.

The caller must have resourcemanager.projects.delete permissions for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String name = ProjectName.of("[PROJECT]").toString();
   Project response = projectsClient.deleteProjectAsync(name).get();
 }
 
Parameter
NameDescription
nameString

Required. The name of the Project (for example, projects/415104041262).

Returns
TypeDescription
OperationFuture<Project,DeleteProjectMetadata>

deleteProjectCallable()

public final UnaryCallable<DeleteProjectRequest,Operation> deleteProjectCallable()

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] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project.

After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and SearchProjects methods.

This method behaves idempotently, such that deleting a DELETE_REQUESTED project will not cause an error, but also won't do anything.

The caller must have resourcemanager.projects.delete permissions for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   DeleteProjectRequest request =
       DeleteProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build();
   ApiFuture<Operation> future = projectsClient.deleteProjectCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteProjectRequest,Operation>

deleteProjectOperationCallable()

public final OperationCallable<DeleteProjectRequest,Project,DeleteProjectMetadata> deleteProjectOperationCallable()

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] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project.

After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and SearchProjects methods.

This method behaves idempotently, such that deleting a DELETE_REQUESTED project will not cause an error, but also won't do anything.

The caller must have resourcemanager.projects.delete permissions for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   DeleteProjectRequest request =
       DeleteProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build();
   OperationFuture<Project, DeleteProjectMetadata> future =
       projectsClient.deleteProjectOperationCallable().futureCall(request);
   // Do something.
   Project response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<DeleteProjectRequest,Project,DeleteProjectMetadata>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getIamPolicy(ResourceName resource)

public final Policy getIamPolicy(ResourceName resource)

Returns the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123. Permission is denied if the policy or the resource do not exist.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ResourceName resource = ProjectName.of("[PROJECT]");
   Policy response = projectsClient.getIamPolicy(resource);
 }
 
Parameter
NameDescription
resourcecom.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicy(GetIamPolicyRequest request)

public final Policy getIamPolicy(GetIamPolicyRequest request)

Returns the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123. Permission is denied if the policy or the resource do not exist.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource(ProjectName.of("[PROJECT]").toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   Policy response = projectsClient.getIamPolicy(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.GetIamPolicyRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicy(String resource)

public final Policy getIamPolicy(String resource)

Returns the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123. Permission is denied if the policy or the resource do not exist.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String resource = FolderName.of("[FOLDER]").toString();
   Policy response = projectsClient.getIamPolicy(resource);
 }
 
Parameter
NameDescription
resourceString

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicyCallable()

public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()

Returns the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123. Permission is denied if the policy or the resource do not exist.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource(ProjectName.of("[PROJECT]").toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   ApiFuture<Policy> future = projectsClient.getIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getProject(GetProjectRequest request)

public final Project getProject(GetProjectRequest request)

Retrieves the project identified by the specified name (for example, projects/415104041262).

The caller must have resourcemanager.projects.get permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   GetProjectRequest request =
       GetProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build();
   Project response = projectsClient.getProject(request);
 }
 
Parameter
NameDescription
requestGetProjectRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Project

getProject(ProjectName name)

public final Project getProject(ProjectName name)

Retrieves the project identified by the specified name (for example, projects/415104041262).

The caller must have resourcemanager.projects.get permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ProjectName name = ProjectName.of("[PROJECT]");
   Project response = projectsClient.getProject(name);
 }
 
Parameter
NameDescription
nameProjectName

Required. The name of the project (for example, projects/415104041262).

Returns
TypeDescription
Project

getProject(String name)

public final Project getProject(String name)

Retrieves the project identified by the specified name (for example, projects/415104041262).

The caller must have resourcemanager.projects.get permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String name = ProjectName.of("[PROJECT]").toString();
   Project response = projectsClient.getProject(name);
 }
 
Parameter
NameDescription
nameString

Required. The name of the project (for example, projects/415104041262).

Returns
TypeDescription
Project

getProjectCallable()

public final UnaryCallable<GetProjectRequest,Project> getProjectCallable()

Retrieves the project identified by the specified name (for example, projects/415104041262).

The caller must have resourcemanager.projects.get permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   GetProjectRequest request =
       GetProjectRequest.newBuilder().setName(ProjectName.of("[PROJECT]").toString()).build();
   ApiFuture<Project> future = projectsClient.getProjectCallable().futureCall(request);
   // Do something.
   Project response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetProjectRequest,Project>

getSettings()

public final ProjectsSettings getSettings()
Returns
TypeDescription
ProjectsSettings

getStub()

public ProjectsStub getStub()
Returns
TypeDescription
ProjectsStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listProjects(ResourceName parent)

public final ProjectsClient.ListProjectsPagedResponse listProjects(ResourceName parent)

Lists 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ResourceName parent = FolderName.of("[FOLDER]");
   for (Project element : projectsClient.listProjects(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentcom.google.api.resourcenames.ResourceName

Required. The name of the parent resource whose projects are being listed. Only children of this parent resource are listed; descendants are not listed.

If the parent is a folder, use the value folders/{folder_id}. If the parent is an organization, use the value organizations/{org_id}.

Returns
TypeDescription
ProjectsClient.ListProjectsPagedResponse

listProjects(ListProjectsRequest request)

public final ProjectsClient.ListProjectsPagedResponse listProjects(ListProjectsRequest request)

Lists 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ListProjectsRequest request =
       ListProjectsRequest.newBuilder()
           .setParent(FolderName.of("[FOLDER]").toString())
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .setShowDeleted(true)
           .build();
   for (Project element : projectsClient.listProjects(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListProjectsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
ProjectsClient.ListProjectsPagedResponse

listProjects(String parent)

public final ProjectsClient.ListProjectsPagedResponse listProjects(String parent)

Lists 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String parent = FolderName.of("[FOLDER]").toString();
   for (Project element : projectsClient.listProjects(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The name of the parent resource whose projects are being listed. Only children of this parent resource are listed; descendants are not listed.

If the parent is a folder, use the value folders/{folder_id}. If the parent is an organization, use the value organizations/{org_id}.

Returns
TypeDescription
ProjectsClient.ListProjectsPagedResponse

listProjectsCallable()

public final UnaryCallable<ListProjectsRequest,ListProjectsResponse> listProjectsCallable()

Lists 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ListProjectsRequest request =
       ListProjectsRequest.newBuilder()
           .setParent(FolderName.of("[FOLDER]").toString())
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .setShowDeleted(true)
           .build();
   while (true) {
     ListProjectsResponse response = projectsClient.listProjectsCallable().call(request);
     for (Project element : response.getProjectsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListProjectsRequest,ListProjectsResponse>

listProjectsPagedCallable()

public final UnaryCallable<ListProjectsRequest,ProjectsClient.ListProjectsPagedResponse> listProjectsPagedCallable()

Lists 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ListProjectsRequest request =
       ListProjectsRequest.newBuilder()
           .setParent(FolderName.of("[FOLDER]").toString())
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .setShowDeleted(true)
           .build();
   ApiFuture<Project> future = projectsClient.listProjectsPagedCallable().futureCall(request);
   // Do something.
   for (Project element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListProjectsRequest,ListProjectsPagedResponse>

moveProjectAsync(MoveProjectRequest request)

public final OperationFuture<Project,MoveProjectMetadata> moveProjectAsync(MoveProjectRequest request)

Move 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   MoveProjectRequest request =
       MoveProjectRequest.newBuilder()
           .setName(ProjectName.of("[PROJECT]").toString())
           .setDestinationParent(ProjectName.of("[PROJECT]").toString())
           .build();
   Project response = projectsClient.moveProjectAsync(request).get();
 }
 
Parameter
NameDescription
requestMoveProjectRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Project,MoveProjectMetadata>

moveProjectAsync(ProjectName name, ResourceName destinationParent)

public final OperationFuture<Project,MoveProjectMetadata> moveProjectAsync(ProjectName name, ResourceName destinationParent)

Move 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ProjectName name = ProjectName.of("[PROJECT]");
   ResourceName destinationParent = ProjectName.of("[PROJECT]");
   Project response = projectsClient.moveProjectAsync(name, destinationParent).get();
 }
 
Parameters
NameDescription
nameProjectName

Required. The name of the project to move.

destinationParentcom.google.api.resourcenames.ResourceName

Required. The new parent to move the Project under.

Returns
TypeDescription
OperationFuture<Project,MoveProjectMetadata>

moveProjectAsync(ProjectName name, String destinationParent)

public final OperationFuture<Project,MoveProjectMetadata> moveProjectAsync(ProjectName name, String destinationParent)

Move 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ProjectName name = ProjectName.of("[PROJECT]");
   String destinationParent = FolderName.of("[FOLDER]").toString();
   Project response = projectsClient.moveProjectAsync(name, destinationParent).get();
 }
 
Parameters
NameDescription
nameProjectName

Required. The name of the project to move.

destinationParentString

Required. The new parent to move the Project under.

Returns
TypeDescription
OperationFuture<Project,MoveProjectMetadata>

moveProjectAsync(String name, ResourceName destinationParent)

public final OperationFuture<Project,MoveProjectMetadata> moveProjectAsync(String name, ResourceName destinationParent)

Move 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String name = ProjectName.of("[PROJECT]").toString();
   ResourceName destinationParent = ProjectName.of("[PROJECT]");
   Project response = projectsClient.moveProjectAsync(name, destinationParent).get();
 }
 
Parameters
NameDescription
nameString

Required. The name of the project to move.

destinationParentcom.google.api.resourcenames.ResourceName

Required. The new parent to move the Project under.

Returns
TypeDescription
OperationFuture<Project,MoveProjectMetadata>

moveProjectAsync(String name, String destinationParent)

public final OperationFuture<Project,MoveProjectMetadata> moveProjectAsync(String name, String destinationParent)

Move 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String name = ProjectName.of("[PROJECT]").toString();
   String destinationParent = FolderName.of("[FOLDER]").toString();
   Project response = projectsClient.moveProjectAsync(name, destinationParent).get();
 }
 
Parameters
NameDescription
nameString

Required. The name of the project to move.

destinationParentString

Required. The new parent to move the Project under.

Returns
TypeDescription
OperationFuture<Project,MoveProjectMetadata>

moveProjectCallable()

public final UnaryCallable<MoveProjectRequest,Operation> moveProjectCallable()

Move 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   MoveProjectRequest request =
       MoveProjectRequest.newBuilder()
           .setName(ProjectName.of("[PROJECT]").toString())
           .setDestinationParent(ProjectName.of("[PROJECT]").toString())
           .build();
   ApiFuture<Operation> future = projectsClient.moveProjectCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<MoveProjectRequest,Operation>

moveProjectOperationCallable()

public final OperationCallable<MoveProjectRequest,Project,MoveProjectMetadata> moveProjectOperationCallable()

Move 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   MoveProjectRequest request =
       MoveProjectRequest.newBuilder()
           .setName(ProjectName.of("[PROJECT]").toString())
           .setDestinationParent(ProjectName.of("[PROJECT]").toString())
           .build();
   OperationFuture<Project, MoveProjectMetadata> future =
       projectsClient.moveProjectOperationCallable().futureCall(request);
   // Do something.
   Project response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<MoveProjectRequest,Project,MoveProjectMetadata>

searchProjects(SearchProjectsRequest request)

public final ProjectsClient.SearchProjectsPagedResponse searchProjects(SearchProjectsRequest request)

Search for projects that the caller has both 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   SearchProjectsRequest request =
       SearchProjectsRequest.newBuilder()
           .setQuery("query107944136")
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .build();
   for (Project element : projectsClient.searchProjects(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestSearchProjectsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
ProjectsClient.SearchProjectsPagedResponse

searchProjects(String query)

public final ProjectsClient.SearchProjectsPagedResponse searchProjects(String query)

Search for projects that the caller has both 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String query = "query107944136";
   for (Project element : projectsClient.searchProjects(query).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
queryString

Optional. A query string for searching for projects that the caller has resourcemanager.projects.get permission to. If multiple fields are included in the query, then it will return results that match any of the fields. Some eligible fields are:

- **displayName, name**: Filters by displayName. - **parent**: Project's parent (for example: folders/123, organizations/*). Prefer parent field over parent.type and parent.id. - **parent.type**: Parent's type: folder or organization. - **parent.id**: Parent's id number (for example: 123). - **id, projectId**: Filters by projectId. - **state, lifecycleState**: Filters by state. - **labels**: Filters by label name or value. - **labels.<key> (where <key> is the name of a label)**: Filters by label name.

Search expressions are case insensitive.

Some examples queries:

- **name:how***: The project's name starts with "how". - **name:Howl**: The project's name is Howl or howl. - **name:HOWL**: Equivalent to above. - **NAME:howl**: Equivalent to above. - **labels.color:***: The project has the label color. - **labels.color:red**: The project's label color has the value red. - **labels.color:red labels.size:big**: The project's label color has the value red or its label size has the value big.

If no query is specified, the call will return projects for which the user has the resourcemanager.projects.get permission.

Returns
TypeDescription
ProjectsClient.SearchProjectsPagedResponse

searchProjectsCallable()

public final UnaryCallable<SearchProjectsRequest,SearchProjectsResponse> searchProjectsCallable()

Search for projects that the caller has both 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   SearchProjectsRequest request =
       SearchProjectsRequest.newBuilder()
           .setQuery("query107944136")
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .build();
   while (true) {
     SearchProjectsResponse response = projectsClient.searchProjectsCallable().call(request);
     for (Project element : response.getProjectsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<SearchProjectsRequest,SearchProjectsResponse>

searchProjectsPagedCallable()

public final UnaryCallable<SearchProjectsRequest,ProjectsClient.SearchProjectsPagedResponse> searchProjectsPagedCallable()

Search for projects that the caller has both 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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   SearchProjectsRequest request =
       SearchProjectsRequest.newBuilder()
           .setQuery("query107944136")
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .build();
   ApiFuture<Project> future = projectsClient.searchProjectsPagedCallable().futureCall(request);
   // Do something.
   for (Project element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<SearchProjectsRequest,SearchProjectsPagedResponse>

setIamPolicy(ResourceName resource, Policy policy)

public final Policy setIamPolicy(ResourceName resource, Policy policy)

Sets the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123.

CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings.

Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles.

The following constraints apply when using setIamPolicy():

+ Project does not support allUsers and allAuthenticatedUsers as members in a Binding of a Policy.

+ The owner role can be granted to a user, serviceAccount, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization.

+ Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation.

+ A user cannot be granted the owner role using setIamPolicy(). The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation.

+ Invitations to grant the owner role cannot be sent using setIamPolicy(); they must be sent only using the Cloud Platform Console.

+ If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling setIamPolicy() to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ResourceName resource = ProjectName.of("[PROJECT]");
   Policy policy = Policy.newBuilder().build();
   Policy response = projectsClient.setIamPolicy(resource, policy);
 }
 
Parameters
NameDescription
resourcecom.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policycom.google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicy(SetIamPolicyRequest request)

public final Policy setIamPolicy(SetIamPolicyRequest request)

Sets the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123.

CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings.

Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles.

The following constraints apply when using setIamPolicy():

+ Project does not support allUsers and allAuthenticatedUsers as members in a Binding of a Policy.

+ The owner role can be granted to a user, serviceAccount, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization.

+ Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation.

+ A user cannot be granted the owner role using setIamPolicy(). The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation.

+ Invitations to grant the owner role cannot be sent using setIamPolicy(); they must be sent only using the Cloud Platform Console.

+ If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling setIamPolicy() to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource(ProjectName.of("[PROJECT]").toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Policy response = projectsClient.setIamPolicy(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.SetIamPolicyRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicy(String resource, Policy policy)

public final Policy setIamPolicy(String resource, Policy policy)

Sets the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123.

CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings.

Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles.

The following constraints apply when using setIamPolicy():

+ Project does not support allUsers and allAuthenticatedUsers as members in a Binding of a Policy.

+ The owner role can be granted to a user, serviceAccount, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization.

+ Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation.

+ A user cannot be granted the owner role using setIamPolicy(). The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation.

+ Invitations to grant the owner role cannot be sent using setIamPolicy(); they must be sent only using the Cloud Platform Console.

+ If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling setIamPolicy() to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String resource = FolderName.of("[FOLDER]").toString();
   Policy policy = Policy.newBuilder().build();
   Policy response = projectsClient.setIamPolicy(resource, policy);
 }
 
Parameters
NameDescription
resourceString

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policycom.google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicyCallable()

public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()

Sets the IAM access control policy for the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123.

CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings.

Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles.

The following constraints apply when using setIamPolicy():

+ Project does not support allUsers and allAuthenticatedUsers as members in a Binding of a Policy.

+ The owner role can be granted to a user, serviceAccount, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization.

+ Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation.

+ A user cannot be granted the owner role using setIamPolicy(). The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation.

+ Invitations to grant the owner role cannot be sent using setIamPolicy(); they must be sent only using the Cloud Platform Console.

+ If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling setIamPolicy() to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource(ProjectName.of("[PROJECT]").toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Policy> future = projectsClient.setIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

testIamPermissions(ResourceName resource, List<String> permissions)

public final TestIamPermissionsResponse testIamPermissions(ResourceName resource, List<String> permissions)

Returns permissions that a caller has on the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123..

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ResourceName resource = ProjectName.of("[PROJECT]");
   List<String> permissions = new ArrayList<>();
   TestIamPermissionsResponse response =
       projectsClient.testIamPermissions(resource, permissions);
 }
 
Parameters
NameDescription
resourcecom.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissionsList<String>

The set of permissions to check for the resource. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see IAM Overview.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissions(TestIamPermissionsRequest request)

public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)

Returns permissions that a caller has on the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123..

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource(ProjectName.of("[PROJECT]").toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   TestIamPermissionsResponse response = projectsClient.testIamPermissions(request);
 }
 
Parameter
NameDescription
requestcom.google.iam.v1.TestIamPermissionsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissions(String resource, List<String> permissions)

public final TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)

Returns permissions that a caller has on the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123..

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String resource = FolderName.of("[FOLDER]").toString();
   List<String> permissions = new ArrayList<>();
   TestIamPermissionsResponse response =
       projectsClient.testIamPermissions(resource, permissions);
 }
 
Parameters
NameDescription
resourceString

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissionsList<String>

The set of permissions to check for the resource. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see IAM Overview.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissionsCallable()

public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()

Returns permissions that a caller has on the specified project, in the format projects/{ProjectIdOrNumber} e.g. projects/123..

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource(ProjectName.of("[PROJECT]").toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   ApiFuture<TestIamPermissionsResponse> future =
       projectsClient.testIamPermissionsCallable().futureCall(request);
   // Do something.
   TestIamPermissionsResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>

undeleteProjectAsync(ProjectName name)

public final OperationFuture<Project,UndeleteProjectMetadata> undeleteProjectAsync(ProjectName name)

Restores 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] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored.

The caller must have resourcemanager.projects.undelete permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   ProjectName name = ProjectName.of("[PROJECT]");
   Project response = projectsClient.undeleteProjectAsync(name).get();
 }
 
Parameter
NameDescription
nameProjectName

Required. The name of the project (for example, projects/415104041262).

Required.

Returns
TypeDescription
OperationFuture<Project,UndeleteProjectMetadata>

undeleteProjectAsync(UndeleteProjectRequest request)

public final OperationFuture<Project,UndeleteProjectMetadata> undeleteProjectAsync(UndeleteProjectRequest request)

Restores 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] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored.

The caller must have resourcemanager.projects.undelete permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   UndeleteProjectRequest request =
       UndeleteProjectRequest.newBuilder()
           .setName(ProjectName.of("[PROJECT]").toString())
           .build();
   Project response = projectsClient.undeleteProjectAsync(request).get();
 }
 
Parameter
NameDescription
requestUndeleteProjectRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Project,UndeleteProjectMetadata>

undeleteProjectAsync(String name)

public final OperationFuture<Project,UndeleteProjectMetadata> undeleteProjectAsync(String name)

Restores 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] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored.

The caller must have resourcemanager.projects.undelete permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   String name = ProjectName.of("[PROJECT]").toString();
   Project response = projectsClient.undeleteProjectAsync(name).get();
 }
 
Parameter
NameDescription
nameString

Required. The name of the project (for example, projects/415104041262).

Required.

Returns
TypeDescription
OperationFuture<Project,UndeleteProjectMetadata>

undeleteProjectCallable()

public final UnaryCallable<UndeleteProjectRequest,Operation> undeleteProjectCallable()

Restores 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] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored.

The caller must have resourcemanager.projects.undelete permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   UndeleteProjectRequest request =
       UndeleteProjectRequest.newBuilder()
           .setName(ProjectName.of("[PROJECT]").toString())
           .build();
   ApiFuture<Operation> future = projectsClient.undeleteProjectCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UndeleteProjectRequest,Operation>

undeleteProjectOperationCallable()

public final OperationCallable<UndeleteProjectRequest,Project,UndeleteProjectMetadata> undeleteProjectOperationCallable()

Restores 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] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored.

The caller must have resourcemanager.projects.undelete permission for this project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   UndeleteProjectRequest request =
       UndeleteProjectRequest.newBuilder()
           .setName(ProjectName.of("[PROJECT]").toString())
           .build();
   OperationFuture<Project, UndeleteProjectMetadata> future =
       projectsClient.undeleteProjectOperationCallable().futureCall(request);
   // Do something.
   Project response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<UndeleteProjectRequest,Project,UndeleteProjectMetadata>

updateProjectAsync(Project project, FieldMask updateMask)

public final OperationFuture<Project,UpdateProjectMetadata> updateProjectAsync(Project project, FieldMask updateMask)

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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   Project project = Project.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Project response = projectsClient.updateProjectAsync(project, updateMask).get();
 }
 
Parameters
NameDescription
projectProject

Required. The new definition of the project.

updateMaskFieldMask

Optional. An update mask to selectively update fields.

Returns
TypeDescription
OperationFuture<Project,UpdateProjectMetadata>

updateProjectAsync(UpdateProjectRequest request)

public final OperationFuture<Project,UpdateProjectMetadata> updateProjectAsync(UpdateProjectRequest request)

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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   UpdateProjectRequest request =
       UpdateProjectRequest.newBuilder()
           .setProject(Project.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Project response = projectsClient.updateProjectAsync(request).get();
 }
 
Parameter
NameDescription
requestUpdateProjectRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Project,UpdateProjectMetadata>

updateProjectCallable()

public final UnaryCallable<UpdateProjectRequest,Operation> updateProjectCallable()

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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   UpdateProjectRequest request =
       UpdateProjectRequest.newBuilder()
           .setProject(Project.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Operation> future = projectsClient.updateProjectCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateProjectRequest,Operation>

updateProjectOperationCallable()

public final OperationCallable<UpdateProjectRequest,Project,UpdateProjectMetadata> updateProjectOperationCallable()

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.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ProjectsClient projectsClient = ProjectsClient.create()) {
   UpdateProjectRequest request =
       UpdateProjectRequest.newBuilder()
           .setProject(Project.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   OperationFuture<Project, UpdateProjectMetadata> future =
       projectsClient.updateProjectOperationCallable().futureCall(request);
   // Do something.
   Project response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<UpdateProjectRequest,Project,UpdateProjectMetadata>