Search in sources :

Example 21 with Project

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());
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project)

Example 22 with Project

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();
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) IOException(java.io.IOException) StepResult(bio.terra.stairway.StepResult)

Example 23 with Project

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());
}
Also used : Project(com.blackducksoftware.bdio2.model.Project) Bdio2Document(com.synopsys.integration.blackduck.bdio2.model.Bdio2Document) ProductList(com.blackducksoftware.common.value.ProductList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 24 with Project

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());
}
Also used : Project(com.blackducksoftware.bdio2.model.Project) Bdio2Document(com.synopsys.integration.blackduck.bdio2.model.Bdio2Document) ProductList(com.blackducksoftware.common.value.ProductList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 25 with Project

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());
}
Also used : Project(com.blackducksoftware.bdio2.model.Project) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) List(java.util.List) ProjectDependency(com.synopsys.integration.bdio.model.dependency.ProjectDependency) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) ProjectDependency(com.synopsys.integration.bdio.model.dependency.ProjectDependency) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

Project (com.google.api.services.cloudresourcemanager.v3.model.Project)37 Test (org.junit.jupiter.api.Test)29 BaseIntegrationTest (bio.terra.buffer.common.BaseIntegrationTest)15 Pool (bio.terra.buffer.common.Pool)15 ResourceId (bio.terra.buffer.common.ResourceId)15 IntegrationUtils.preparePool (bio.terra.buffer.integration.IntegrationUtils.preparePool)15 FlightManager (bio.terra.buffer.service.resource.FlightManager)15 IOException (java.io.IOException)14 Binding (com.google.api.services.cloudresourcemanager.v3.model.Binding)10 StepStatus (bio.terra.stairway.StepStatus)9 ArrayList (java.util.ArrayList)9 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)8 List (java.util.List)8 DisabledIfEnvironmentVariable (org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)8 FlightDebugInfo (bio.terra.stairway.FlightDebugInfo)7 FlightState (bio.terra.stairway.FlightState)7 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)7 Project (com.blackducksoftware.bdio2.model.Project)7 GetIamPolicyRequest (com.google.api.services.cloudresourcemanager.v3.model.GetIamPolicyRequest)7 FlightMap (bio.terra.stairway.FlightMap)6