public interface ResourceManager extends Service<ResourceManagerOptions>
Modifier and Type | Interface and Description |
---|---|
static class |
ResourceManager.ProjectField
The fields of a project.
|
static class |
ResourceManager.ProjectGetOption
Class for specifying project get options.
|
static class |
ResourceManager.ProjectListOption
Class for specifying project list options.
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CONTENT_TYPE |
Modifier and Type | Method and Description |
---|---|
Project |
create(ProjectInfo project)
Creates a new project.
|
void |
delete(String projectId)
Marks the project identified by the specified project ID for deletion.
|
Project |
get(String projectId,
ResourceManager.ProjectGetOption... options)
Retrieves the project identified by the specified project ID.
|
Policy |
getPolicy(String projectId)
Returns the IAM access control policy for the specified project.
|
Page<Project> |
list(ResourceManager.ProjectListOption... options)
Lists the projects visible to the current user.
|
Project |
replace(ProjectInfo newProject)
Replaces the attributes of the project.
|
Policy |
replacePolicy(String projectId,
Policy newPolicy)
Sets the IAM access control policy for the specified project.
|
List<Boolean> |
testPermissions(String projectId,
List<String> permissions)
Returns the permissions that a caller has on the specified project.
|
void |
undelete(String projectId)
Restores the project identified by the specified project ID.
|
getOptions
static final String DEFAULT_CONTENT_TYPE
Project create(ProjectInfo project)
Initially, the project resource is owned by its creator exclusively. The creator can later grant permission to others to read or update the project. Several APIs are activated automatically for the project, including Google Cloud Storage.
ResourceManagerException
- upon failurevoid delete(String projectId)
This method will only affect the project if the following criteria are met:
ProjectInfo.State.ACTIVE
.
ProjectInfo.State.ACTIVE
to
ProjectInfo.State.DELETE_REQUESTED
. The deletion starts at an unspecified time, at
which point the lifecycle state changes to ProjectInfo.State.DELETE_IN_PROGRESS
. Until
the deletion completes, you can check the lifecycle state checked by retrieving the project
with get(java.lang.String, com.google.cloud.resourcemanager.ResourceManager.ProjectGetOption...)
, and the project remains visible to list(com.google.cloud.resourcemanager.ResourceManager.ProjectListOption...)
. However, you cannot update the project. After the deletion completes,
the project is not retrievable by the get(java.lang.String, com.google.cloud.resourcemanager.ResourceManager.ProjectGetOption...)
and list(com.google.cloud.resourcemanager.ResourceManager.ProjectListOption...)
methods. The caller must have modify permissions for this project.ResourceManagerException
- upon failureProject get(String projectId, ResourceManager.ProjectGetOption... options)
Returns null
if the project is not found or if the user doesn't have read
permissions for the project.
ResourceManagerException
- upon failurePage<Project> list(ResourceManager.ProjectListOption... options)
This method returns projects in an unspecified order. New projects do not necessarily appear
at the end of the list. Use ResourceManager.ProjectListOption
to filter this list, set page size, and
set page tokens.
Page<Project>
, a page of projectsResourceManagerException
- upon failureProject replace(ProjectInfo newProject)
The caller must have modify permissions for this project.
ResourceManagerException
- upon failurevoid undelete(String projectId)
You can only use this method for a project that has a lifecycle state of ProjectInfo.State.DELETE_REQUESTED
. After deletion starts, as indicated by a lifecycle state
of ProjectInfo.State.DELETE_IN_PROGRESS
, the project cannot be restored. The caller
must have modify permissions for this project.
ResourceManagerException
- upon failurePolicy getPolicy(String projectId)
null
if the
resource does not exist or if you do not have adequate permission to view the project or get
the policy.ResourceManagerException
- upon failurePolicy replacePolicy(String projectId, Policy newPolicy)
It is recommended that you use the read-modify-write pattern. This pattern entails reading
the project's current policy, updating it locally, and then sending the modified policy for
writing. Cloud IAM solves the problem of conflicting processes simultaneously attempting to
modify a policy by using the etag
property. This property is used to
verify whether the policy has changed since the last request. When you make a request to Cloud
IAM with an etag value, Cloud IAM compares the etag value in the request with the existing etag
value associated with the policy. It writes the policy only if the etag values match. If the
etags don't match, a ResourceManagerException
is thrown, denoting that the server
aborted update. If an etag is not provided, the policy is overwritten blindly.
An example of using the read-write-modify pattern is as follows:
Policy currentPolicy = resourceManager.getPolicy("my-project-id");
Policy modifiedPolicy = current.toBuilder()
.removeIdentity(Role.viewer(), Identity.user("user@gmail.com"))
.build();
Policy newPolicy = resourceManager.replacePolicy("my-project-id", modified);
ResourceManagerException
- upon failureList<Boolean> testPermissions(String projectId, List<String> permissions)
ResourceManagerException
- upon failureCopyright © 2019 Google LLC. All rights reserved.