Search in sources :

Example 26 with Project

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

the class ServiceUsageCowTest method listAndEnableServices.

@Test
public void listAndEnableServices() throws Exception {
    ServiceUsageCow serviceUsage = defaultServiceUsage();
    Project project = ProjectUtils.executeCreateProject();
    String projectName = projectIdToName(project.getProjectId());
    String storageServiceName = serviceName(project, STORAGE_SERVICE_ID);
    ListServicesResponse response1 = serviceUsage.services().list(projectName).setFilter(ENABLED_FILTER).execute();
    assertNull(response1.getServices());
    Operation operation = serviceUsage.services().batchEnable(projectName, new BatchEnableServicesRequest().setServiceIds(ImmutableList.of(STORAGE_SERVICE_ID))).execute();
    OperationTestUtils.pollAndAssertSuccess(serviceUsage.operations().operationCow(operation), Duration.ofSeconds(5), Duration.ofSeconds(60));
    ListServicesResponse response2 = serviceUsage.services().list(projectName).setFilter(ENABLED_FILTER).execute();
    List<String> services2 = response2.getServices().stream().map(Service::getName).collect(Collectors.toList());
    assertThat(services2, Matchers.hasItem(storageServiceName));
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) ListServicesResponse(com.google.api.services.serviceusage.v1beta1.model.ListServicesResponse) Operation(com.google.api.services.serviceusage.v1beta1.model.Operation) BatchEnableServicesRequest(com.google.api.services.serviceusage.v1beta1.model.BatchEnableServicesRequest) Test(org.junit.jupiter.api.Test)

Example 27 with Project

use of com.blackducksoftware.bdio2.model.Project in project uPMT by coco35700.

the class NewProjectDialogController method createProject.

public void createProject() {
    Project p = new Project(nomProjet.getText(), this.choixSchema.getValue());
    p.getSchema().setName(nomProjet.getText());
    main.setProjectInCreation(p);
    // main.getProjects().add(p);
    // main.setCurrentProject(p);
    // p.save();
    window.close();
    launchingScreenWindow.close();
// in case the center was set to null because of automatic interview Creation
/*if (main.getRootLayout().getCenter() == null) {
			main.launchMainView();
		}*/
// main.launchMainView();
// main.refreshDataTreeView();
// main.needToSave();
}
Also used : Project(model.Project)

Example 28 with Project

use of com.blackducksoftware.bdio2.model.Project in project uPMT by coco35700.

the class NewProjectDialogController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    // TODO Auto-generated method stub
    choixSchema.getItems().add(main.getDefaultSchema());
    for (Project p : main.getProjects()) {
        choixSchema.getItems().add(p.getSchema());
    }
    // change the text to make it pretty
    choixSchema.setConverter(new StringConverter<Schema>() {

        @Override
        public String toString(Schema object) {
            // TODO Auto-generated method stub
            return object.getName();
        }

        @Override
        public Schema fromString(String string) {
            // TODO Auto-generated method stub
            return new Schema(string);
        }
    });
    choixSchema.setValue(main.getDefaultSchema());
}
Also used : Project(model.Project) Schema(model.Schema)

Example 29 with Project

use of com.blackducksoftware.bdio2.model.Project in project terra-workspace-manager by DataBiosphere.

the class DeleteGcpContextFlightTest method deleteContextDo.

@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void deleteContextDo() throws Exception {
    FlightMap createParameters = new FlightMap();
    AuthenticatedUserRequest userRequest = userAccessUtils.defaultUserAuthRequest();
    createParameters.put(WorkspaceFlightMapKeys.WORKSPACE_ID, workspaceUuid.toString());
    createParameters.put(JobMapKeys.AUTH_USER_INFO.getKeyName(), userRequest);
    // Create the google context.
    FlightState flightState = StairwayTestUtils.blockUntilFlightCompletes(jobService.getStairway(), CreateGcpContextFlightV2.class, createParameters, CREATION_FLIGHT_TIMEOUT, null);
    assertEquals(FlightStatus.SUCCESS, flightState.getFlightStatus());
    String projectId = workspaceService.getAuthorizedGcpProject(workspaceUuid, userRequest).orElse(null);
    assertNotNull(projectId);
    // validate that required project does not throw and gives the same answer
    String projectId2 = workspaceService.getAuthorizedRequiredGcpProject(workspaceUuid, userRequest);
    assertEquals(projectId, projectId2);
    Project project = crl.getCloudResourceManagerCow().projects().get(projectId).execute();
    assertEquals("ACTIVE", project.getState());
    // Delete the google context.
    FlightMap deleteParameters = new FlightMap();
    deleteParameters.put(WorkspaceFlightMapKeys.WORKSPACE_ID, workspaceUuid.toString());
    // Force each step to be retried once to ensure proper behavior.
    Map<String, StepStatus> doFailures = new HashMap<>();
    doFailures.put(DeleteControlledSamResourcesStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
    doFailures.put(DeleteControlledDbResourcesStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
    doFailures.put(DeleteGcpProjectStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
    doFailures.put(DeleteGcpContextStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
    FlightDebugInfo debugInfo = FlightDebugInfo.newBuilder().doStepFailures(doFailures).build();
    flightState = StairwayTestUtils.blockUntilFlightCompletes(jobService.getStairway(), DeleteGcpContextFlight.class, deleteParameters, DELETION_FLIGHT_TIMEOUT, debugInfo);
    assertEquals(FlightStatus.SUCCESS, flightState.getFlightStatus());
    assertTrue(testUtils.getAuthorizedGcpCloudContext(workspaceUuid, userRequest).isEmpty());
    // make sure required really requires
    assertThrows(CloudContextRequiredException.class, () -> workspaceService.getAuthorizedRequiredGcpProject(workspaceUuid, userRequest));
    project = crl.getCloudResourceManagerCow().projects().get(projectId).execute();
    assertEquals("DELETE_REQUESTED", project.getState());
}
Also used : FlightDebugInfo(bio.terra.stairway.FlightDebugInfo) HashMap(java.util.HashMap) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) StepStatus(bio.terra.stairway.StepStatus) FlightState(bio.terra.stairway.FlightState) Project(com.google.api.services.cloudresourcemanager.v3.model.Project) FlightMap(bio.terra.stairway.FlightMap) BaseConnectedTest(bio.terra.workspace.common.BaseConnectedTest) Test(org.junit.jupiter.api.Test) DisabledIfEnvironmentVariable(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)

Example 30 with Project

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

the class CloudBillingClientCowTest method getSetProjectBillingInfo.

@Test
public void getSetProjectBillingInfo() throws Exception {
    Project project = ProjectUtils.executeCreateProject();
    try (CloudBillingClientCow billingCow = defaultBillingCow()) {
        ProjectBillingInfo initialBilling = billingCow.getProjectBillingInfo("projects/" + project.getProjectId());
        assertEquals(project.getProjectId(), initialBilling.getProjectId());
        assertEquals("", initialBilling.getBillingAccountName());
        ProjectBillingInfo setBilling = ProjectBillingInfo.newBuilder().setBillingAccountName(BILLING_ACCOUNT_NAME).build();
        ProjectBillingInfo updatedBilling = billingCow.updateProjectBillingInfo("projects/" + project.getProjectId(), setBilling);
        assertEquals(project.getProjectId(), updatedBilling.getProjectId());
        assertEquals(BILLING_ACCOUNT_NAME, updatedBilling.getBillingAccountName());
    }
    ProjectUtils.getManagerCow().projects().delete(project.getProjectId());
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) ProjectBillingInfo(com.google.cloud.billing.v1.ProjectBillingInfo) Test(org.junit.jupiter.api.Test)

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