use of com.google.api.services.cloudresourcemanager.v3.model.Project in project terra-resource-buffer by DataBiosphere.
the class DeleteProjectFlightIntegrationTest method assertProjectDeleting.
private void assertProjectDeleting(String projectId) throws Exception {
// Project is ready for deletion
Project project = rmCow.projects().get(projectId).execute();
assertEquals("DELETE_REQUESTED", project.getState());
}
use of com.google.api.services.cloudresourcemanager.v3.model.Project in project terra-resource-buffer by DataBiosphere.
the class DeleteProjectStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) throws InterruptedException, RetryException {
String projectId = flightContext.getInputParameters().get(CLOUD_RESOURCE_UID, CloudResourceUid.class).getGoogleProjectUid().getProjectId();
try {
Optional<Project> project = retrieveProject(rmCow, projectId);
if (project.isEmpty() || isProjectDeleting(project.get())) {
// Skip if project does not exist, or is being deleted. We know that the project is
// created by Resource Buffer Service hence Resource Buffer Service should have owner
// permission. So we assume 403 in this case
// means that the project does not exist.
logger.info("Project id: {} is deleted or being deleted", projectId);
return StepResult.getStepResultSuccess();
}
OperationCow<?> operation = rmCow.operations().operationCow(rmCow.projects().delete(projectId).execute());
pollUntilSuccess(operation, Duration.ofSeconds(5), Duration.ofMinutes(5));
} catch (IOException e) {
logger.info("Error when deleting GCP project", e);
return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, e);
}
return StepResult.getStepResultSuccess();
}
use of com.google.api.services.cloudresourcemanager.v3.model.Project in project blackduck-common by blackducksoftware.
the class Bdio2Factory method createLegacyBdio2Document.
/**
* @deprecated (Use createBdio2Document instead when the ProjectDependencyGraph has an accurate ProjectDependency)
*/
@Deprecated
public Bdio2Document createLegacyBdio2Document(BdioMetadata bdioMetadata, DependencyGraph dependencyGraph, ProjectInfo projectInfo, ExternalId projectExternalId) {
Project project = createProject(projectInfo.getNameVersion(), projectExternalId, true);
Pair<List<Project>, List<Component>> subprojectsAndComponents = createAndLinkComponents(dependencyGraph, project);
return new Bdio2Document(bdioMetadata, project, subprojectsAndComponents.getLeft(), subprojectsAndComponents.getRight());
}
use of com.google.api.services.cloudresourcemanager.v3.model.Project in project blackduck-common by blackducksoftware.
the class Bdio2Factory method createBdio2Document.
public Bdio2Document createBdio2Document(BdioMetadata bdioMetadata, ProjectDependencyGraph dependencyGraph) {
Project project = createProject(dependencyGraph.getProjectDependency().getExternalId(), true);
Pair<List<Project>, List<Component>> subprojectsAndComponents = createAndLinkComponents(dependencyGraph, project);
return new Bdio2Document(bdioMetadata, project, subprojectsAndComponents.getLeft(), subprojectsAndComponents.getRight());
}
use of com.google.api.services.cloudresourcemanager.v3.model.Project in project blackduck-common by blackducksoftware.
the class Bdio2FactoryTest method testCreateAndLinkComponents.
@Test
void testCreateAndLinkComponents() {
ExternalIdFactory externalIdFactory = new ExternalIdFactory();
String rootProjectGroup = "testRootProjectGroup";
String rootProjectName = "testRootProjectName";
String rootProjectVersion = "testRootProjectVersion";
String subProjectGroup = "testSubProjectGroup";
String subProjectName = "testSubProjectName";
String subProjectVersion = "testSubProjectVersion";
String compGroup = "testCompGroup";
String compName = "testCompName";
String compVersion = "testCompVersion";
ExternalId rootProjectExternalId = externalIdFactory.createMavenExternalId(rootProjectGroup, rootProjectName, rootProjectVersion);
ExternalId subProjectExternalId = externalIdFactory.createMavenExternalId(subProjectGroup, subProjectName, subProjectVersion);
ExternalId componentExternalId = externalIdFactory.createMavenExternalId(compGroup, compName, compVersion);
Bdio2Factory bdio2Factory = new Bdio2Factory();
Project rootProject = bdio2Factory.createProject(rootProjectExternalId, true);
DependencyGraph dependencyGraph = Mockito.mock(DependencyGraph.class);
Set<Dependency> dependencies = new HashSet<>();
ProjectDependency subProjectDependency = new ProjectDependency(subProjectName, subProjectVersion, subProjectExternalId);
Dependency componentDependency = new Dependency(componentExternalId);
dependencies.add(subProjectDependency);
dependencies.add(componentDependency);
Mockito.when(dependencyGraph.getDirectDependencies()).thenReturn(dependencies);
Pair<List<Project>, List<Component>> results = bdio2Factory.createAndLinkComponents(dependencyGraph, rootProject);
assertEquals(1, results.getLeft().size());
assertEquals("http:maven/" + subProjectGroup + "/" + subProjectName + "/" + subProjectVersion, results.getLeft().get(0).id());
assertEquals(1, results.getRight().size());
assertEquals("http:maven/" + compGroup + "/" + compName + "/" + compVersion, results.getRight().get(0).id());
}
Aggregations