use of com.google.api.services.cloudresourcemanager.v3.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());
}
use of com.google.api.services.cloudresourcemanager.v3.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.google.api.services.cloudresourcemanager.v3.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.google.api.services.cloudresourcemanager.v3.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.google.api.services.cloudresourcemanager.v3.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();
}
Aggregations