See: Description
Interface | Description |
---|---|
ResourceManager | Deprecated
v3 GAPIC client of ResourceManager is now available
|
ResourceManagerFactory | Deprecated
v3 GAPIC client of ResourceManager is now available
|
Class | Description |
---|---|
ConstraintInfo | Deprecated
v3 GAPIC client of ResourceManager is now available
|
OrgPolicyInfo | Deprecated
v3 GAPIC client of ResourceManager is now available
|
Project | Deprecated
v3 GAPIC client of ResourceManager is now available
|
Project.Builder |
Builder for
Project . |
ProjectInfo | Deprecated
v3 GAPIC client of ResourceManager is now available
|
ProjectInfo.Builder |
Builder for
ProjectInfo . |
ProjectInfo.ResourceId | |
ProjectInfo.State |
The project lifecycle states.
|
ResourceManager.ListOption |
Class for specifying project list options.
|
ResourceManager.ProjectGetOption |
Class for specifying project get options.
|
ResourceManager.ProjectListOption |
Class for specifying project list options.
|
ResourceManagerOptions | Deprecated
v3 GAPIC client of ResourceManager is now available
|
ResourceManagerOptions.Builder | |
ResourceManagerOptions.DefaultResourceManagerFactory | |
ResourceManagerOptions.DefaultResourceManagerRpcFactory |
Enum | Description |
---|---|
ResourceManager.ProjectField |
The fields of a project.
|
Exception | Description |
---|---|
ResourceManagerException | Deprecated
v3 GAPIC client of ResourceManager is now available
|
Here's a simple usage example for using google-cloud from App/Compute Engine. This example creates a project if it does not exist. For the complete source code see GetOrCreateProject.java.
ResourceManager resourceManager = ResourceManagerOptions.getDefaultInstance().getService();
String projectId = "my-globally-unique-project-id"; // Change to a unique project ID.
Project project = resourceManager.get(projectId);
if (project == null) {
project = resourceManager.create(ProjectInfo.builder(projectId).build());
}
System.out.println("Got project " + project.getProjectId() + " from the server.");
This second example shows how to update a project if it exists and list all projects the user has permission to view. For the complete source code see UpdateAndListProjects.java.
ResourceManager resourceManager = ResourceManagerOptions.getDefaultInstance().getService();
Project project = resourceManager.get("some-project-id"); // Use an existing project's ID
if (project != null) {
Project newProject = project.toBuilder()
.addLabel("launch-status", "in-development")
.build()
.replace();
System.out.println("Updated the labels of project " + newProject.getProjectId()
+ " to be " + newProject.getLabels());
}
Iterator<Project> projectIterator = resourceManager.list().iterateAll();
System.out.println("Projects I can view:");
while (projectIterator.hasNext()) {
System.out.println(projectIterator.next().getProjectId());
}
Remember that you must authenticate using the Google Cloud SDK. See more about providing credentials here.
Copyright © 2022 Google LLC. All rights reserved.