use of com.blackducksoftware.bdio2.model.Project in project terra-cloud-resource-lib by DataBiosphere.
the class CloudResourceManagerCowTest method createGetDeleteProject.
@Test
public void createGetDeleteProject() throws Exception {
CloudResourceManagerCow managerCow = defaultManager();
String projectId = ProjectUtils.randomProjectId();
assertThrows(GoogleJsonResponseException.class, () -> managerCow.projects().get(projectId).execute());
Operation operation = managerCow.projects().create(defaultProject(projectId)).execute();
OperationTestUtils.pollAndAssertSuccess(managerCow.operations().operationCow(operation), Duration.ofSeconds(5), Duration.ofSeconds(30));
Project project = managerCow.projects().get(projectId).execute();
assertEquals(projectId, project.getProjectId());
assertEquals("ACTIVE", project.getState());
Operation deleteOperation = managerCow.projects().delete(projectId).execute();
OperationTestUtils.pollAndAssertSuccess(managerCow.operations().operationCow(deleteOperation), Duration.ofSeconds(5), Duration.ofSeconds(30));
// After "deletion," the project still exists for up to 30 days where it can be recovered.
project = managerCow.projects().get(projectId).execute();
assertEquals("DELETE_REQUESTED", project.getState());
}
use of com.blackducksoftware.bdio2.model.Project in project terra-cloud-resource-lib by DataBiosphere.
the class CloudComputeCowTest method createPreparedProject.
/**
* Create Project then set billing account, enable compute compute service
*/
private static Project createPreparedProject() throws Exception {
Project project = ProjectUtils.executeCreateProject();
CloudBillingUtils.setDefaultProjectBilling(project.getProjectId());
ServiceUsageUtils.enableServices(project.getProjectId(), ImmutableList.of(COMPUTE_SERVICE_ID));
return project;
}
use of com.blackducksoftware.bdio2.model.Project in project terra-cloud-resource-lib by DataBiosphere.
the class DnsCowTest method createAndGetChange.
@Test
public void createAndGetChange() throws Exception {
Project project = ProjectUtils.executeCreateProject();
String projectId = project.getProjectId();
CloudBillingUtils.setDefaultProjectBilling(projectId);
ServiceUsageUtils.enableServices(projectId, SERVICE_IDS);
DnsCow dnsCow = defaultDns();
ManagedZone managedZone = new ManagedZone().setName("zone-name").setDnsName("googleapis.com.").setVisibility("private").setDescription("description");
dnsCow.managedZones().create(project.getProjectId(), managedZone).execute();
ResourceRecordSet resourceRecordSet = new ResourceRecordSet().setType("A").setName("restricted.googleapis.com.").setRrdatas(ImmutableList.of("199.36.153.4")).setTtl(300);
Change createdChange = dnsCow.changes().create(project.getProjectId(), managedZone.getName(), new Change().setAdditions(ImmutableList.of(resourceRecordSet))).execute();
List<ResourceRecordSet> actualRecordSet = dnsCow.changes().get(projectId, managedZone.getName(), createdChange.getId()).execute().getAdditions();
assertEquals(1, actualRecordSet.size());
assertEquals("A", actualRecordSet.get(0).getType());
assertEquals("restricted.googleapis.com.", actualRecordSet.get(0).getName());
assertEquals("199.36.153.4", actualRecordSet.get(0).getRrdatas().get(0));
assertEquals(300, actualRecordSet.get(0).getTtl());
assertThat(dnsCow.resourceRecordSets().list(projectId, managedZone.getName()).execute().getRrsets(), Matchers.hasItem(actualRecordSet.get(0)));
}
use of com.blackducksoftware.bdio2.model.Project in project terra-cloud-resource-lib by DataBiosphere.
the class ProjectUtils method executeCreateProject.
/**
* Creates a new Google Project in GCP for testing.
*/
public static Project executeCreateProject() throws Exception {
Project project = new Project().setProjectId(randomProjectId()).setParent(PARENT_RESOURCE);
Operation operation = getManagerCow().projects().create(project).execute();
OperationCow<Operation> operationCow = managerCow.operations().operationCow(operation);
OperationTestUtils.pollAndAssertSuccess(operationCow, Duration.ofSeconds(5), Duration.ofSeconds(60));
return managerCow.projects().get(project.getProjectId()).execute();
}
use of com.blackducksoftware.bdio2.model.Project in project terra-resource-buffer by DataBiosphere.
the class CreateProjectStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) throws RetryException {
String projectId = flightContext.getWorkingMap().get(GOOGLE_PROJECT_ID, String.class);
try {
Project project = new Project().setProjectId(projectId).setLabels(createLabelMap(flightContext, gcpProjectConfig)).setParent("folders/" + gcpProjectConfig.getParentFolderId());
OperationCow<?> operation = rmCow.operations().operationCow(rmCow.projects().create(project).execute());
pollUntilSuccess(operation, Duration.ofSeconds(5), Duration.ofMinutes(5));
Project createdProject = rmCow.projects().get(projectId).execute();
flightContext.getWorkingMap().put(GOOGLE_PROJECT_NUMBER, getNumber(createdProject));
} catch (IOException | InterruptedException e) {
logger.info("Error when creating GCP project", e);
return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, e);
}
return StepResult.getStepResultSuccess();
}
Aggregations