/** * Restores the project identified by the specified project ID. * * <p>You can only use this method for a project that has a lifecycle state of {@link * ProjectInfo.State#DELETE_REQUESTED}. After deletion starts, as indicated by a lifecycle state * of {@link ProjectInfo.State#DELETE_IN_PROGRESS}, the project cannot be restored. The caller * must have modify permissions for this project. * * @throws ResourceManagerException upon failure (including when the project can't be restored) * @see <a href= * "https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/undelete">Cloud * Resource Manager undelete</a> */ public void undelete() { resourceManager.undelete(getProjectId()); }
@Test public void testUndelete() { initializeExpectedProject(1); expect(resourceManager.getOptions()).andReturn(mockOptions); resourceManager.undelete(PROJECT_INFO.getProjectId()); replay(resourceManager); initializeProject(); project.undelete(); }
@Test public void testUndelete() { RESOURCE_MANAGER.create(COMPLETE_PROJECT); RESOURCE_MANAGER.delete(COMPLETE_PROJECT.getProjectId()); assertEquals( ProjectInfo.State.DELETE_REQUESTED, RESOURCE_MANAGER.get(COMPLETE_PROJECT.getProjectId()).getState()); RESOURCE_MANAGER.undelete(COMPLETE_PROJECT.getProjectId()); ProjectInfo revivedProject = RESOURCE_MANAGER.get(COMPLETE_PROJECT.getProjectId()); compareReadWriteFields(COMPLETE_PROJECT, revivedProject); assertEquals(ProjectInfo.State.ACTIVE, revivedProject.getState()); try { RESOURCE_MANAGER.undelete("invalid-project-id"); fail("Should fail because the project doesn't exist."); } catch (ResourceManagerException e) { assertEquals(403, e.getCode()); assertTrue(e.getMessage().contains("the project was not found")); } }
/** * Restores the project identified by the specified project ID. * * <p>You can only use this method for a project that has a lifecycle state of * {@link ProjectInfo.State#DELETE_REQUESTED}. After deletion starts, as indicated by a lifecycle * state of {@link ProjectInfo.State#DELETE_IN_PROGRESS}, the project cannot be restored. The * caller must have modify permissions for this project. * * @throws ResourceManagerException upon failure (including when the project can't be restored) * @see <a href= * "https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/undelete">Cloud * Resource Manager undelete</a> */ public void undelete() { resourceManager.undelete(projectId()); }