Search in sources :

Example 6 with Project

use of com.blackducksoftware.bdio2.model.Project in project terra-resource-buffer by DataBiosphere.

the class DeleteProjectFlightIntegrationTest method assertProjectExists.

private Project assertProjectExists(ResourceId resourceId) throws Exception {
    Resource resource = bufferDao.retrieveResource(resourceId).get();
    Project project = rmCow.projects().get(resource.cloudResourceUid().getGoogleProjectUid().getProjectId()).execute();
    assertEquals("ACTIVE", project.getState());
    return project;
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) Resource(bio.terra.buffer.common.Resource)

Example 7 with Project

use of com.blackducksoftware.bdio2.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 8 with Project

use of com.blackducksoftware.bdio2.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 9 with Project

use of com.blackducksoftware.bdio2.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 10 with Project

use of com.blackducksoftware.bdio2.model.Project in project blackduck-common by blackducksoftware.

the class Bdio2Factory method createBdioMetadata.

private BdioMetadata createBdioMetadata(String codeLocationName, ProjectInfo projectInfo, ZonedDateTime creationDateTime, ProductList productList) {
    BdioMetadata metadata = new BdioMetadata().id(LegacyUtilities.toNameUri(codeLocationName)).name(codeLocationName).project(projectInfo.getNameVersion().getName()).projectVersion(projectInfo.getNameVersion().getVersion()).creationDateTime(creationDateTime).publisher(productList);
    projectInfo.getProjectGroup().ifPresent(metadata::projectGroup);
    projectInfo.getCorrelationId().ifPresent(metadata::correlationId);
    projectInfo.getGitInfo().getSourceRevision().ifPresent(metadata::sourceRevision);
    projectInfo.getGitInfo().getSourceBranch().ifPresent(metadata::sourceBranch);
    projectInfo.getGitInfo().getSourceRepository().map(URL::toString).ifPresent(metadata::sourceRepository);
    return metadata;
}
Also used : BdioMetadata(com.blackducksoftware.bdio2.BdioMetadata)

Aggregations

Project (com.google.api.services.cloudresourcemanager.v3.model.Project)38 Test (org.junit.jupiter.api.Test)32 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 StepStatus (bio.terra.stairway.StepStatus)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 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 Project (com.blackducksoftware.bdio2.model.Project)6 UUID (java.util.UUID)6 Resource (bio.terra.buffer.common.Resource)5 bio.terra.buffer.generated.model (bio.terra.buffer.generated.model)5