Search in sources :

Example 6 with ProjectBillingInfo

use of com.google.cloud.billing.v1.ProjectBillingInfo 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

ProjectBillingInfo (com.google.cloud.billing.v1.ProjectBillingInfo)4 ListProjectBillingInfoPagedResponse (com.google.cloud.billing.v1.CloudBillingClient.ListProjectBillingInfoPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 Project (com.google.api.services.cloudresourcemanager.v3.model.Project)1 ByteString (com.google.protobuf.ByteString)1 Test (org.junit.jupiter.api.Test)1