diff --git a/java-billing/README.md b/java-billing/README.md index 63fee8c3e7be..bb7c6d8ff0b3 100644 --- a/java-billing/README.md +++ b/java-billing/README.md @@ -20,7 +20,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: com.google.cloud libraries-bom - 26.16.0 + 26.17.0 pom import diff --git a/java-billing/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudBillingClient.java b/java-billing/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudBillingClient.java index 612c2c8ec5a9..bf4a3f9a9263 100644 --- a/java-billing/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudBillingClient.java +++ b/java-billing/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudBillingClient.java @@ -888,7 +888,40 @@ public final ListProjectBillingInfoPagedResponse listProjectBillingInfo( * // - It may require specifying regional endpoints when creating the service client as shown in * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { - * String name = "name3373707"; + * ProjectBillingInfoName name = ProjectBillingInfoName.of("[PROJECT]"); + * ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(name); + * } + * } + * + * @param name Required. The resource name of the project for which billing information is + * retrieved. For example, `projects/tokyo-rain-123`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ProjectBillingInfo getProjectBillingInfo(ProjectBillingInfoName name) { + GetProjectBillingInfoRequest request = + GetProjectBillingInfoRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getProjectBillingInfo(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the billing information for a project. The current authenticated user must have the + * `resourcemanager.projects.get` permission for the project, which can be granted by assigning + * the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + * role. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   String name = ProjectBillingInfoName.of("[PROJECT]").toString();
    *   ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(name);
    * }
    * }
@@ -920,7 +953,9 @@ public final ProjectBillingInfo getProjectBillingInfo(String name) { * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { * GetProjectBillingInfoRequest request = - * GetProjectBillingInfoRequest.newBuilder().setName("name3373707").build(); + * GetProjectBillingInfoRequest.newBuilder() + * .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) + * .build(); * ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(request); * } * } @@ -949,7 +984,9 @@ public final ProjectBillingInfo getProjectBillingInfo(GetProjectBillingInfoReque * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { * GetProjectBillingInfoRequest request = - * GetProjectBillingInfoRequest.newBuilder().setName("name3373707").build(); + * GetProjectBillingInfoRequest.newBuilder() + * .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) + * .build(); * ApiFuture future = * cloudBillingClient.getProjectBillingInfoCallable().futureCall(request); * // Do something. diff --git a/java-billing/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/gapic_metadata.json b/java-billing/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/gapic_metadata.json index 01f7725e04b3..dcde96340188 100644 --- a/java-billing/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/gapic_metadata.json +++ b/java-billing/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/gapic_metadata.json @@ -20,7 +20,7 @@ "methods": ["getIamPolicy", "getIamPolicy", "getIamPolicy", "getIamPolicyCallable"] }, "GetProjectBillingInfo": { - "methods": ["getProjectBillingInfo", "getProjectBillingInfo", "getProjectBillingInfoCallable"] + "methods": ["getProjectBillingInfo", "getProjectBillingInfo", "getProjectBillingInfo", "getProjectBillingInfoCallable"] }, "ListBillingAccounts": { "methods": ["listBillingAccounts", "listBillingAccounts", "listBillingAccountsPagedCallable", "listBillingAccountsCallable"] diff --git a/java-billing/google-cloud-billing/src/test/java/com/google/cloud/billing/v1/CloudBillingClientHttpJsonTest.java b/java-billing/google-cloud-billing/src/test/java/com/google/cloud/billing/v1/CloudBillingClientHttpJsonTest.java index 843b397441bf..2c7e71d43676 100644 --- a/java-billing/google-cloud-billing/src/test/java/com/google/cloud/billing/v1/CloudBillingClientHttpJsonTest.java +++ b/java-billing/google-cloud-billing/src/test/java/com/google/cloud/billing/v1/CloudBillingClientHttpJsonTest.java @@ -46,6 +46,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; @Generated("by gapic-generator-java") @@ -475,18 +476,19 @@ public void listProjectBillingInfoExceptionTest2() throws Exception { } } + @Ignore("Ignore until https://github.com/googleapis/sdk-platform-java/issues/1780 is resolved") @Test public void getProjectBillingInfoTest() throws Exception { ProjectBillingInfo expectedResponse = ProjectBillingInfo.newBuilder() - .setName("name3373707") + .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) .setProjectId("projectId-894832108") .setBillingAccountName("billingAccountName929322205") .setBillingEnabled(true) .build(); mockService.addResponse(expectedResponse); - String name = "projects/project-3664"; + ProjectBillingInfoName name = ProjectBillingInfoName.of("[PROJECT]"); ProjectBillingInfo actualResponse = client.getProjectBillingInfo(name); Assert.assertEquals(expectedResponse, actualResponse); @@ -513,6 +515,53 @@ public void getProjectBillingInfoExceptionTest() throws Exception { new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); mockService.addException(exception); + try { + ProjectBillingInfoName name = ProjectBillingInfoName.of("[PROJECT]"); + client.getProjectBillingInfo(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProjectBillingInfoTest2() throws Exception { + ProjectBillingInfo expectedResponse = + ProjectBillingInfo.newBuilder() + .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) + .setProjectId("projectId-894832108") + .setBillingAccountName("billingAccountName929322205") + .setBillingEnabled(true) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3664"; + + ProjectBillingInfo actualResponse = client.getProjectBillingInfo(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getProjectBillingInfoExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + try { String name = "projects/project-3664"; client.getProjectBillingInfo(name); @@ -526,7 +575,7 @@ public void getProjectBillingInfoExceptionTest() throws Exception { public void updateProjectBillingInfoTest() throws Exception { ProjectBillingInfo expectedResponse = ProjectBillingInfo.newBuilder() - .setName("name3373707") + .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) .setProjectId("projectId-894832108") .setBillingAccountName("billingAccountName929322205") .setBillingEnabled(true) diff --git a/java-billing/google-cloud-billing/src/test/java/com/google/cloud/billing/v1/CloudBillingClientTest.java b/java-billing/google-cloud-billing/src/test/java/com/google/cloud/billing/v1/CloudBillingClientTest.java index c85b4a96f485..24526c0f8efb 100644 --- a/java-billing/google-cloud-billing/src/test/java/com/google/cloud/billing/v1/CloudBillingClientTest.java +++ b/java-billing/google-cloud-billing/src/test/java/com/google/cloud/billing/v1/CloudBillingClientTest.java @@ -443,7 +443,49 @@ public void listProjectBillingInfoExceptionTest2() throws Exception { public void getProjectBillingInfoTest() throws Exception { ProjectBillingInfo expectedResponse = ProjectBillingInfo.newBuilder() - .setName("name3373707") + .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) + .setProjectId("projectId-894832108") + .setBillingAccountName("billingAccountName929322205") + .setBillingEnabled(true) + .build(); + mockCloudBilling.addResponse(expectedResponse); + + ProjectBillingInfoName name = ProjectBillingInfoName.of("[PROJECT]"); + + ProjectBillingInfo actualResponse = client.getProjectBillingInfo(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockCloudBilling.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetProjectBillingInfoRequest actualRequest = + ((GetProjectBillingInfoRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getProjectBillingInfoExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockCloudBilling.addException(exception); + + try { + ProjectBillingInfoName name = ProjectBillingInfoName.of("[PROJECT]"); + client.getProjectBillingInfo(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getProjectBillingInfoTest2() throws Exception { + ProjectBillingInfo expectedResponse = + ProjectBillingInfo.newBuilder() + .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) .setProjectId("projectId-894832108") .setBillingAccountName("billingAccountName929322205") .setBillingEnabled(true) @@ -468,7 +510,7 @@ public void getProjectBillingInfoTest() throws Exception { } @Test - public void getProjectBillingInfoExceptionTest() throws Exception { + public void getProjectBillingInfoExceptionTest2() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudBilling.addException(exception); @@ -485,7 +527,7 @@ public void getProjectBillingInfoExceptionTest() throws Exception { public void updateProjectBillingInfoTest() throws Exception { ProjectBillingInfo expectedResponse = ProjectBillingInfo.newBuilder() - .setName("name3373707") + .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) .setProjectId("projectId-894832108") .setBillingAccountName("billingAccountName929322205") .setBillingEnabled(true) diff --git a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/CloudBillingProto.java b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/CloudBillingProto.java index 13232d3b7849..5bef58f8edcd 100644 --- a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/CloudBillingProto.java +++ b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/CloudBillingProto.java @@ -91,88 +91,92 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + ",\n*cloudbilling.googleapis.com/BillingAc" + "count\022\022\n\004open\030\002 \001(\010B\004\342A\001\003\022\024\n\014display_nam" + "e\030\003 \001(\t\022\036\n\026master_billing_account\030\004 \001(\t\"" - + "m\n\022ProjectBillingInfo\022\014\n\004name\030\001 \001(\t\022\022\n\np" - + "roject_id\030\002 \001(\t\022\034\n\024billing_account_name\030" - + "\003 \001(\t\022\027\n\017billing_enabled\030\004 \001(\010\"]\n\030GetBil" - + "lingAccountRequest\022A\n\004name\030\001 \001(\tB3\342A\001\002\372A" - + ",\n*cloudbilling.googleapis.com/BillingAc" - + "count\"S\n\032ListBillingAccountsRequest\022\021\n\tp" - + "age_size\030\001 \001(\005\022\022\n\npage_token\030\002 \001(\t\022\016\n\006fi" - + "lter\030\003 \001(\t\"y\n\033ListBillingAccountsRespons" - + "e\022A\n\020billing_accounts\030\001 \003(\0132\'.google.clo" - + "ud.billing.v1.BillingAccount\022\027\n\017next_pag" - + "e_token\030\002 \001(\t\"e\n\033CreateBillingAccountReq" - + "uest\022F\n\017billing_account\030\001 \001(\0132\'.google.c" - + "loud.billing.v1.BillingAccountB\004\342A\001\002\"\321\001\n" - + "\033UpdateBillingAccountRequest\022A\n\004name\030\001 \001" - + "(\tB3\342A\001\002\372A,\n*cloudbilling.googleapis.com" - + "/BillingAccount\022>\n\007account\030\002 \001(\0132\'.googl" - + "e.cloud.billing.v1.BillingAccountB\004\342A\001\002\022" - + "/\n\013update_mask\030\003 \001(\0132\032.google.protobuf.F" - + "ieldMask\"\211\001\n\035ListProjectBillingInfoReque" + + "\324\001\n\022ProjectBillingInfo\022\022\n\004name\030\001 \001(\tB\004\342A" + + "\001\003\022\030\n\nproject_id\030\002 \001(\tB\004\342A\001\003\022\034\n\024billing_" + + "account_name\030\003 \001(\t\022\035\n\017billing_enabled\030\004 " + + "\001(\010B\004\342A\001\003:S\352AP\n.cloudbilling.googleapis." + + "com/ProjectBillingInfo\022\036projects/{projec" + + "t}/billingInfo\"]\n\030GetBillingAccountReque" + "st\022A\n\004name\030\001 \001(\tB3\342A\001\002\372A,\n*cloudbilling." - + "googleapis.com/BillingAccount\022\021\n\tpage_si" - + "ze\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"\204\001\n\036ListPro" - + "jectBillingInfoResponse\022I\n\024project_billi" - + "ng_info\030\001 \003(\0132+.google.cloud.billing.v1." - + "ProjectBillingInfo\022\027\n\017next_page_token\030\002 " - + "\001(\t\"2\n\034GetProjectBillingInfoRequest\022\022\n\004n" - + "ame\030\001 \001(\tB\004\342A\001\002\"\200\001\n\037UpdateProjectBilling" - + "InfoRequest\022\022\n\004name\030\001 \001(\tB\004\342A\001\002\022I\n\024proje" - + "ct_billing_info\030\002 \001(\0132+.google.cloud.bil" - + "ling.v1.ProjectBillingInfo2\262\017\n\014CloudBill" - + "ing\022\234\001\n\021GetBillingAccount\0221.google.cloud" - + ".billing.v1.GetBillingAccountRequest\032\'.g" - + "oogle.cloud.billing.v1.BillingAccount\"+\332" - + "A\004name\202\323\344\223\002\036\022\034/v1/{name=billingAccounts/" - + "*}\022\240\001\n\023ListBillingAccounts\0223.google.clou" - + "d.billing.v1.ListBillingAccountsRequest\032" - + "4.google.cloud.billing.v1.ListBillingAcc" - + "ountsResponse\"\036\332A\000\202\323\344\223\002\025\022\023/v1/billingAcc" - + "ounts\022\263\001\n\024UpdateBillingAccount\0224.google." - + "cloud.billing.v1.UpdateBillingAccountReq" - + "uest\032\'.google.cloud.billing.v1.BillingAc" - + "count\"<\332A\014name,account\202\323\344\223\002\'2\034/v1/{name=" - + "billingAccounts/*}:\007account\022\265\001\n\024CreateBi" - + "llingAccount\0224.google.cloud.billing.v1.C" - + "reateBillingAccountRequest\032\'.google.clou" - + "d.billing.v1.BillingAccount\">\332A\017billing_" - + "account\202\323\344\223\002&\"\023/v1/billingAccounts:\017bill" - + "ing_account\022\277\001\n\026ListProjectBillingInfo\0226" - + ".google.cloud.billing.v1.ListProjectBill" - + "ingInfoRequest\0327.google.cloud.billing.v1" - + ".ListProjectBillingInfoResponse\"4\332A\004name" - + "\202\323\344\223\002\'\022%/v1/{name=billingAccounts/*}/pro" - + "jects\022\255\001\n\025GetProjectBillingInfo\0225.google" - + ".cloud.billing.v1.GetProjectBillingInfoR" - + "equest\032+.google.cloud.billing.v1.Project" - + "BillingInfo\"0\332A\004name\202\323\344\223\002#\022!/v1/{name=pr" - + "ojects/*}/billingInfo\022\336\001\n\030UpdateProjectB" - + "illingInfo\0228.google.cloud.billing.v1.Upd" - + "ateProjectBillingInfoRequest\032+.google.cl" - + "oud.billing.v1.ProjectBillingInfo\"[\332A\031na" - + "me,project_billing_info\202\323\344\223\0029\032!/v1/{name" - + "=projects/*}/billingInfo:\024project_billin" - + "g_info\022\213\001\n\014GetIamPolicy\022\".google.iam.v1." - + "GetIamPolicyRequest\032\025.google.iam.v1.Poli" - + "cy\"@\332A\010resource\202\323\344\223\002/\022-/v1/{resource=bil" - + "lingAccounts/*}:getIamPolicy\022\225\001\n\014SetIamP" - + "olicy\022\".google.iam.v1.SetIamPolicyReques" - + "t\032\025.google.iam.v1.Policy\"J\332A\017resource,po" - + "licy\202\323\344\223\0022\"-/v1/{resource=billingAccount" - + "s/*}:setIamPolicy:\001*\022\300\001\n\022TestIamPermissi" - + "ons\022(.google.iam.v1.TestIamPermissionsRe" - + "quest\032).google.iam.v1.TestIamPermissions" - + "Response\"U\332A\024resource,permissions\202\323\344\223\0028\"" - + "3/v1/{resource=billingAccounts/*}:testIa" - + "mPermissions:\001*\032\265\001\312A\033cloudbilling.google" - + "apis.com\322A\223\001https://www.googleapis.com/a" - + "uth/cloud-billing,https://www.googleapis" - + ".com/auth/cloud-billing.readonly,https:/" - + "/www.googleapis.com/auth/cloud-platformB" - + "i\n\033com.google.cloud.billing.v1B\021CloudBil" - + "lingProtoP\001Z5cloud.google.com/go/billing" - + "/apiv1/billingpb;billingpbb\006proto3" + + "googleapis.com/BillingAccount\"S\n\032ListBil" + + "lingAccountsRequest\022\021\n\tpage_size\030\001 \001(\005\022\022" + + "\n\npage_token\030\002 \001(\t\022\016\n\006filter\030\003 \001(\t\"y\n\033Li" + + "stBillingAccountsResponse\022A\n\020billing_acc" + + "ounts\030\001 \003(\0132\'.google.cloud.billing.v1.Bi" + + "llingAccount\022\027\n\017next_page_token\030\002 \001(\t\"e\n" + + "\033CreateBillingAccountRequest\022F\n\017billing_" + + "account\030\001 \001(\0132\'.google.cloud.billing.v1." + + "BillingAccountB\004\342A\001\002\"\321\001\n\033UpdateBillingAc" + + "countRequest\022A\n\004name\030\001 \001(\tB3\342A\001\002\372A,\n*clo" + + "udbilling.googleapis.com/BillingAccount\022" + + ">\n\007account\030\002 \001(\0132\'.google.cloud.billing." + + "v1.BillingAccountB\004\342A\001\002\022/\n\013update_mask\030\003" + + " \001(\0132\032.google.protobuf.FieldMask\"\211\001\n\035Lis" + + "tProjectBillingInfoRequest\022A\n\004name\030\001 \001(\t" + + "B3\342A\001\002\372A,\n*cloudbilling.googleapis.com/B" + + "illingAccount\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npage" + + "_token\030\003 \001(\t\"\204\001\n\036ListProjectBillingInfoR" + + "esponse\022I\n\024project_billing_info\030\001 \003(\0132+." + + "google.cloud.billing.v1.ProjectBillingIn" + + "fo\022\027\n\017next_page_token\030\002 \001(\t\"e\n\034GetProjec" + + "tBillingInfoRequest\022E\n\004name\030\001 \001(\tB7\342A\001\002\372" + + "A0\n.cloudbilling.googleapis.com/ProjectB" + + "illingInfo\"\200\001\n\037UpdateProjectBillingInfoR" + + "equest\022\022\n\004name\030\001 \001(\tB\004\342A\001\002\022I\n\024project_bi" + + "lling_info\030\002 \001(\0132+.google.cloud.billing." + + "v1.ProjectBillingInfo2\262\017\n\014CloudBilling\022\234" + + "\001\n\021GetBillingAccount\0221.google.cloud.bill" + + "ing.v1.GetBillingAccountRequest\032\'.google" + + ".cloud.billing.v1.BillingAccount\"+\332A\004nam" + + "e\202\323\344\223\002\036\022\034/v1/{name=billingAccounts/*}\022\240\001" + + "\n\023ListBillingAccounts\0223.google.cloud.bil" + + "ling.v1.ListBillingAccountsRequest\0324.goo" + + "gle.cloud.billing.v1.ListBillingAccounts" + + "Response\"\036\332A\000\202\323\344\223\002\025\022\023/v1/billingAccounts" + + "\022\263\001\n\024UpdateBillingAccount\0224.google.cloud" + + ".billing.v1.UpdateBillingAccountRequest\032" + + "\'.google.cloud.billing.v1.BillingAccount" + + "\"<\332A\014name,account\202\323\344\223\002\'2\034/v1/{name=billi" + + "ngAccounts/*}:\007account\022\265\001\n\024CreateBilling" + + "Account\0224.google.cloud.billing.v1.Create" + + "BillingAccountRequest\032\'.google.cloud.bil" + + "ling.v1.BillingAccount\">\332A\017billing_accou" + + "nt\202\323\344\223\002&\"\023/v1/billingAccounts:\017billing_a" + + "ccount\022\277\001\n\026ListProjectBillingInfo\0226.goog" + + "le.cloud.billing.v1.ListProjectBillingIn" + + "foRequest\0327.google.cloud.billing.v1.List" + + "ProjectBillingInfoResponse\"4\332A\004name\202\323\344\223\002" + + "\'\022%/v1/{name=billingAccounts/*}/projects" + + "\022\255\001\n\025GetProjectBillingInfo\0225.google.clou" + + "d.billing.v1.GetProjectBillingInfoReques" + + "t\032+.google.cloud.billing.v1.ProjectBilli" + + "ngInfo\"0\332A\004name\202\323\344\223\002#\022!/v1/{name=project" + + "s/*}/billingInfo\022\336\001\n\030UpdateProjectBillin" + + "gInfo\0228.google.cloud.billing.v1.UpdatePr" + + "ojectBillingInfoRequest\032+.google.cloud.b" + + "illing.v1.ProjectBillingInfo\"[\332A\031name,pr" + + "oject_billing_info\202\323\344\223\0029\032!/v1/{name=proj" + + "ects/*}/billingInfo:\024project_billing_inf" + + "o\022\213\001\n\014GetIamPolicy\022\".google.iam.v1.GetIa" + + "mPolicyRequest\032\025.google.iam.v1.Policy\"@\332" + + "A\010resource\202\323\344\223\002/\022-/v1/{resource=billingA" + + "ccounts/*}:getIamPolicy\022\225\001\n\014SetIamPolicy" + + "\022\".google.iam.v1.SetIamPolicyRequest\032\025.g" + + "oogle.iam.v1.Policy\"J\332A\017resource,policy\202" + + "\323\344\223\0022\"-/v1/{resource=billingAccounts/*}:" + + "setIamPolicy:\001*\022\300\001\n\022TestIamPermissions\022(" + + ".google.iam.v1.TestIamPermissionsRequest" + + "\032).google.iam.v1.TestIamPermissionsRespo" + + "nse\"U\332A\024resource,permissions\202\323\344\223\0028\"3/v1/" + + "{resource=billingAccounts/*}:testIamPerm" + + "issions:\001*\032\265\001\312A\033cloudbilling.googleapis." + + "com\322A\223\001https://www.googleapis.com/auth/c" + + "loud-billing,https://www.googleapis.com/" + + "auth/cloud-billing.readonly,https://www." + + "googleapis.com/auth/cloud-platformBi\n\033co" + + "m.google.cloud.billing.v1B\021CloudBillingP" + + "rotoP\001Z5cloud.google.com/go/billing/apiv" + + "1/billingpb;billingpbb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -281,6 +285,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { registry.add(com.google.api.AnnotationsProto.http); registry.add(com.google.api.ClientProto.methodSignature); registry.add(com.google.api.ClientProto.oauthScopes); + registry.add(com.google.api.ResourceProto.resource); registry.add(com.google.api.ResourceProto.resourceReference); com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( descriptor, registry); diff --git a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/GetProjectBillingInfoRequest.java b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/GetProjectBillingInfoRequest.java index 1c3fe0c78a8b..15c4d8fab4fc 100644 --- a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/GetProjectBillingInfoRequest.java +++ b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/GetProjectBillingInfoRequest.java @@ -74,7 +74,9 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The name. */ @@ -98,7 +100,9 @@ public java.lang.String getName() { * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The bytes for name. */ @@ -467,7 +471,9 @@ public Builder mergeFrom( * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The name. */ @@ -490,7 +496,9 @@ public java.lang.String getName() { * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The bytes for name. */ @@ -513,7 +521,9 @@ public com.google.protobuf.ByteString getNameBytes() { * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @param value The name to set. * @return This builder for chaining. @@ -535,7 +545,9 @@ public Builder setName(java.lang.String value) { * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return This builder for chaining. */ @@ -553,7 +565,9 @@ public Builder clearName() { * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @param value The bytes for name to set. * @return This builder for chaining. diff --git a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/GetProjectBillingInfoRequestOrBuilder.java b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/GetProjectBillingInfoRequestOrBuilder.java index ee24eee8f2d0..d303aa1819fa 100644 --- a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/GetProjectBillingInfoRequestOrBuilder.java +++ b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/GetProjectBillingInfoRequestOrBuilder.java @@ -31,7 +31,9 @@ public interface GetProjectBillingInfoRequestOrBuilder * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The name. */ @@ -44,7 +46,9 @@ public interface GetProjectBillingInfoRequestOrBuilder * retrieved. For example, `projects/tokyo-rain-123`. * * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * * * @return The bytes for name. */ diff --git a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfo.java b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfo.java index 870b26c554da..2bf0d12d8823 100644 --- a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfo.java +++ b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfo.java @@ -74,13 +74,13 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * *
-   * The resource name for the `ProjectBillingInfo`; has the form
+   * Output only. The resource name for the `ProjectBillingInfo`; has the form
    * `projects/{project_id}/billingInfo`. For example, the resource name for the
    * billing information for project `tokyo-rain-123` would be
    * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
    * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The name. */ @@ -100,13 +100,13 @@ public java.lang.String getName() { * * *
-   * The resource name for the `ProjectBillingInfo`; has the form
+   * Output only. The resource name for the `ProjectBillingInfo`; has the form
    * `projects/{project_id}/billingInfo`. For example, the resource name for the
    * billing information for project `tokyo-rain-123` would be
    * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
    * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The bytes for name. */ @@ -131,12 +131,13 @@ public com.google.protobuf.ByteString getNameBytes() { * * *
-   * The ID of the project that this `ProjectBillingInfo` represents, such as
-   * `tokyo-rain-123`. This is a convenience field so that you don't need to
-   * parse the `name` field to obtain a project ID. This field is read-only.
+   * Output only. The ID of the project that this `ProjectBillingInfo`
+   * represents, such as `tokyo-rain-123`. This is a convenience field so that
+   * you don't need to parse the `name` field to obtain a project ID. This field
+   * is read-only.
    * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The projectId. */ @@ -156,12 +157,13 @@ public java.lang.String getProjectId() { * * *
-   * The ID of the project that this `ProjectBillingInfo` represents, such as
-   * `tokyo-rain-123`. This is a convenience field so that you don't need to
-   * parse the `name` field to obtain a project ID. This field is read-only.
+   * Output only. The ID of the project that this `ProjectBillingInfo`
+   * represents, such as `tokyo-rain-123`. This is a convenience field so that
+   * you don't need to parse the `name` field to obtain a project ID. This field
+   * is read-only.
    * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The bytes for projectId. */ @@ -237,13 +239,13 @@ public com.google.protobuf.ByteString getBillingAccountNameBytes() { * * *
-   * True if the project is associated with an open billing account, to which
-   * usage on the project is charged. False if the project is associated with a
-   * closed billing account, or no billing account at all, and therefore cannot
-   * use paid services. This field is read-only.
+   * Output only. True if the project is associated with an open billing
+   * account, to which usage on the project is charged. False if the project is
+   * associated with a closed billing account, or no billing account at all, and
+   * therefore cannot use paid services. This field is read-only.
    * 
* - * bool billing_enabled = 4; + * bool billing_enabled = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The billingEnabled. */ @@ -670,13 +672,13 @@ public Builder mergeFrom( * * *
-     * The resource name for the `ProjectBillingInfo`; has the form
+     * Output only. The resource name for the `ProjectBillingInfo`; has the form
      * `projects/{project_id}/billingInfo`. For example, the resource name for the
      * billing information for project `tokyo-rain-123` would be
      * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
      * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The name. */ @@ -695,13 +697,13 @@ public java.lang.String getName() { * * *
-     * The resource name for the `ProjectBillingInfo`; has the form
+     * Output only. The resource name for the `ProjectBillingInfo`; has the form
      * `projects/{project_id}/billingInfo`. For example, the resource name for the
      * billing information for project `tokyo-rain-123` would be
      * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
      * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The bytes for name. */ @@ -720,13 +722,13 @@ public com.google.protobuf.ByteString getNameBytes() { * * *
-     * The resource name for the `ProjectBillingInfo`; has the form
+     * Output only. The resource name for the `ProjectBillingInfo`; has the form
      * `projects/{project_id}/billingInfo`. For example, the resource name for the
      * billing information for project `tokyo-rain-123` would be
      * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
      * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @param value The name to set. * @return This builder for chaining. @@ -744,13 +746,13 @@ public Builder setName(java.lang.String value) { * * *
-     * The resource name for the `ProjectBillingInfo`; has the form
+     * Output only. The resource name for the `ProjectBillingInfo`; has the form
      * `projects/{project_id}/billingInfo`. For example, the resource name for the
      * billing information for project `tokyo-rain-123` would be
      * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
      * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return This builder for chaining. */ @@ -764,13 +766,13 @@ public Builder clearName() { * * *
-     * The resource name for the `ProjectBillingInfo`; has the form
+     * Output only. The resource name for the `ProjectBillingInfo`; has the form
      * `projects/{project_id}/billingInfo`. For example, the resource name for the
      * billing information for project `tokyo-rain-123` would be
      * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
      * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @param value The bytes for name to set. * @return This builder for chaining. @@ -791,12 +793,13 @@ public Builder setNameBytes(com.google.protobuf.ByteString value) { * * *
-     * The ID of the project that this `ProjectBillingInfo` represents, such as
-     * `tokyo-rain-123`. This is a convenience field so that you don't need to
-     * parse the `name` field to obtain a project ID. This field is read-only.
+     * Output only. The ID of the project that this `ProjectBillingInfo`
+     * represents, such as `tokyo-rain-123`. This is a convenience field so that
+     * you don't need to parse the `name` field to obtain a project ID. This field
+     * is read-only.
      * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The projectId. */ @@ -815,12 +818,13 @@ public java.lang.String getProjectId() { * * *
-     * The ID of the project that this `ProjectBillingInfo` represents, such as
-     * `tokyo-rain-123`. This is a convenience field so that you don't need to
-     * parse the `name` field to obtain a project ID. This field is read-only.
+     * Output only. The ID of the project that this `ProjectBillingInfo`
+     * represents, such as `tokyo-rain-123`. This is a convenience field so that
+     * you don't need to parse the `name` field to obtain a project ID. This field
+     * is read-only.
      * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The bytes for projectId. */ @@ -839,12 +843,13 @@ public com.google.protobuf.ByteString getProjectIdBytes() { * * *
-     * The ID of the project that this `ProjectBillingInfo` represents, such as
-     * `tokyo-rain-123`. This is a convenience field so that you don't need to
-     * parse the `name` field to obtain a project ID. This field is read-only.
+     * Output only. The ID of the project that this `ProjectBillingInfo`
+     * represents, such as `tokyo-rain-123`. This is a convenience field so that
+     * you don't need to parse the `name` field to obtain a project ID. This field
+     * is read-only.
      * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @param value The projectId to set. * @return This builder for chaining. @@ -862,12 +867,13 @@ public Builder setProjectId(java.lang.String value) { * * *
-     * The ID of the project that this `ProjectBillingInfo` represents, such as
-     * `tokyo-rain-123`. This is a convenience field so that you don't need to
-     * parse the `name` field to obtain a project ID. This field is read-only.
+     * Output only. The ID of the project that this `ProjectBillingInfo`
+     * represents, such as `tokyo-rain-123`. This is a convenience field so that
+     * you don't need to parse the `name` field to obtain a project ID. This field
+     * is read-only.
      * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return This builder for chaining. */ @@ -881,12 +887,13 @@ public Builder clearProjectId() { * * *
-     * The ID of the project that this `ProjectBillingInfo` represents, such as
-     * `tokyo-rain-123`. This is a convenience field so that you don't need to
-     * parse the `name` field to obtain a project ID. This field is read-only.
+     * Output only. The ID of the project that this `ProjectBillingInfo`
+     * represents, such as `tokyo-rain-123`. This is a convenience field so that
+     * you don't need to parse the `name` field to obtain a project ID. This field
+     * is read-only.
      * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @param value The bytes for projectId to set. * @return This builder for chaining. @@ -1018,13 +1025,13 @@ public Builder setBillingAccountNameBytes(com.google.protobuf.ByteString value) * * *
-     * True if the project is associated with an open billing account, to which
-     * usage on the project is charged. False if the project is associated with a
-     * closed billing account, or no billing account at all, and therefore cannot
-     * use paid services. This field is read-only.
+     * Output only. True if the project is associated with an open billing
+     * account, to which usage on the project is charged. False if the project is
+     * associated with a closed billing account, or no billing account at all, and
+     * therefore cannot use paid services. This field is read-only.
      * 
* - * bool billing_enabled = 4; + * bool billing_enabled = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The billingEnabled. */ @@ -1036,13 +1043,13 @@ public boolean getBillingEnabled() { * * *
-     * True if the project is associated with an open billing account, to which
-     * usage on the project is charged. False if the project is associated with a
-     * closed billing account, or no billing account at all, and therefore cannot
-     * use paid services. This field is read-only.
+     * Output only. True if the project is associated with an open billing
+     * account, to which usage on the project is charged. False if the project is
+     * associated with a closed billing account, or no billing account at all, and
+     * therefore cannot use paid services. This field is read-only.
      * 
* - * bool billing_enabled = 4; + * bool billing_enabled = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @param value The billingEnabled to set. * @return This builder for chaining. @@ -1058,13 +1065,13 @@ public Builder setBillingEnabled(boolean value) { * * *
-     * True if the project is associated with an open billing account, to which
-     * usage on the project is charged. False if the project is associated with a
-     * closed billing account, or no billing account at all, and therefore cannot
-     * use paid services. This field is read-only.
+     * Output only. True if the project is associated with an open billing
+     * account, to which usage on the project is charged. False if the project is
+     * associated with a closed billing account, or no billing account at all, and
+     * therefore cannot use paid services. This field is read-only.
      * 
* - * bool billing_enabled = 4; + * bool billing_enabled = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return This builder for chaining. */ diff --git a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfoName.java b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfoName.java new file mode 100644 index 000000000000..03e898f25676 --- /dev/null +++ b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfoName.java @@ -0,0 +1,168 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.billing.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class ProjectBillingInfoName implements ResourceName { + private static final PathTemplate PROJECT = + PathTemplate.createWithoutUrlEncoding("projects/{project}/billingInfo"); + private volatile Map fieldValuesMap; + private final String project; + + @Deprecated + protected ProjectBillingInfoName() { + project = null; + } + + private ProjectBillingInfoName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + } + + public String getProject() { + return project; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static ProjectBillingInfoName of(String project) { + return newBuilder().setProject(project).build(); + } + + public static String format(String project) { + return newBuilder().setProject(project).build().toString(); + } + + public static ProjectBillingInfoName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT.validatedMatch( + formattedString, "ProjectBillingInfoName.parse: formattedString not in valid format"); + return of(matchMap.get("project")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (ProjectBillingInfoName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT.instantiate("project", project); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ProjectBillingInfoName that = ((ProjectBillingInfoName) o); + return Objects.equals(this.project, that.project); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + return h; + } + + /** Builder for projects/{project}/billingInfo. */ + public static class Builder { + private String project; + + protected Builder() {} + + public String getProject() { + return project; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + private Builder(ProjectBillingInfoName projectBillingInfoName) { + this.project = projectBillingInfoName.project; + } + + public ProjectBillingInfoName build() { + return new ProjectBillingInfoName(this); + } + } +} diff --git a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfoOrBuilder.java b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfoOrBuilder.java index cd72d1b5b1f0..faeae8435944 100644 --- a/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfoOrBuilder.java +++ b/java-billing/proto-google-cloud-billing-v1/src/main/java/com/google/cloud/billing/v1/ProjectBillingInfoOrBuilder.java @@ -27,13 +27,13 @@ public interface ProjectBillingInfoOrBuilder * * *
-   * The resource name for the `ProjectBillingInfo`; has the form
+   * Output only. The resource name for the `ProjectBillingInfo`; has the form
    * `projects/{project_id}/billingInfo`. For example, the resource name for the
    * billing information for project `tokyo-rain-123` would be
    * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
    * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The name. */ @@ -42,13 +42,13 @@ public interface ProjectBillingInfoOrBuilder * * *
-   * The resource name for the `ProjectBillingInfo`; has the form
+   * Output only. The resource name for the `ProjectBillingInfo`; has the form
    * `projects/{project_id}/billingInfo`. For example, the resource name for the
    * billing information for project `tokyo-rain-123` would be
    * `projects/tokyo-rain-123/billingInfo`. This field is read-only.
    * 
* - * string name = 1; + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The bytes for name. */ @@ -58,12 +58,13 @@ public interface ProjectBillingInfoOrBuilder * * *
-   * The ID of the project that this `ProjectBillingInfo` represents, such as
-   * `tokyo-rain-123`. This is a convenience field so that you don't need to
-   * parse the `name` field to obtain a project ID. This field is read-only.
+   * Output only. The ID of the project that this `ProjectBillingInfo`
+   * represents, such as `tokyo-rain-123`. This is a convenience field so that
+   * you don't need to parse the `name` field to obtain a project ID. This field
+   * is read-only.
    * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The projectId. */ @@ -72,12 +73,13 @@ public interface ProjectBillingInfoOrBuilder * * *
-   * The ID of the project that this `ProjectBillingInfo` represents, such as
-   * `tokyo-rain-123`. This is a convenience field so that you don't need to
-   * parse the `name` field to obtain a project ID. This field is read-only.
+   * Output only. The ID of the project that this `ProjectBillingInfo`
+   * represents, such as `tokyo-rain-123`. This is a convenience field so that
+   * you don't need to parse the `name` field to obtain a project ID. This field
+   * is read-only.
    * 
* - * string project_id = 2; + * string project_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The bytes for projectId. */ @@ -114,13 +116,13 @@ public interface ProjectBillingInfoOrBuilder * * *
-   * True if the project is associated with an open billing account, to which
-   * usage on the project is charged. False if the project is associated with a
-   * closed billing account, or no billing account at all, and therefore cannot
-   * use paid services. This field is read-only.
+   * Output only. True if the project is associated with an open billing
+   * account, to which usage on the project is charged. False if the project is
+   * associated with a closed billing account, or no billing account at all, and
+   * therefore cannot use paid services. This field is read-only.
    * 
* - * bool billing_enabled = 4; + * bool billing_enabled = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; * * @return The billingEnabled. */ diff --git a/java-billing/proto-google-cloud-billing-v1/src/main/proto/google/cloud/billing/v1/cloud_billing.proto b/java-billing/proto-google-cloud-billing-v1/src/main/proto/google/cloud/billing/v1/cloud_billing.proto index 213967d9eee9..ae64248d637d 100644 --- a/java-billing/proto-google-cloud-billing-v1/src/main/proto/google/cloud/billing/v1/cloud_billing.proto +++ b/java-billing/proto-google-cloud-billing-v1/src/main/proto/google/cloud/billing/v1/cloud_billing.proto @@ -239,26 +239,32 @@ message BillingAccount { // project has at most one associated billing account at a time (but a billing // account can be assigned to multiple projects). message ProjectBillingInfo { - // The resource name for the `ProjectBillingInfo`; has the form + option (google.api.resource) = { + type: "cloudbilling.googleapis.com/ProjectBillingInfo" + pattern: "projects/{project}/billingInfo" + }; + + // Output only. The resource name for the `ProjectBillingInfo`; has the form // `projects/{project_id}/billingInfo`. For example, the resource name for the // billing information for project `tokyo-rain-123` would be // `projects/tokyo-rain-123/billingInfo`. This field is read-only. - string name = 1; + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // The ID of the project that this `ProjectBillingInfo` represents, such as - // `tokyo-rain-123`. This is a convenience field so that you don't need to - // parse the `name` field to obtain a project ID. This field is read-only. - string project_id = 2; + // Output only. The ID of the project that this `ProjectBillingInfo` + // represents, such as `tokyo-rain-123`. This is a convenience field so that + // you don't need to parse the `name` field to obtain a project ID. This field + // is read-only. + string project_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; // The resource name of the billing account associated with the project, if // any. For example, `billingAccounts/012345-567890-ABCDEF`. string billing_account_name = 3; - // True if the project is associated with an open billing account, to which - // usage on the project is charged. False if the project is associated with a - // closed billing account, or no billing account at all, and therefore cannot - // use paid services. This field is read-only. - bool billing_enabled = 4; + // Output only. True if the project is associated with an open billing + // account, to which usage on the project is charged. False if the project is + // associated with a closed billing account, or no billing account at all, and + // therefore cannot use paid services. This field is read-only. + bool billing_enabled = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; } // Request message for `GetBillingAccount`. @@ -370,7 +376,12 @@ message ListProjectBillingInfoResponse { message GetProjectBillingInfoRequest { // Required. The resource name of the project for which billing information is // retrieved. For example, `projects/tokyo-rain-123`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/ProjectBillingInfo" + } + ]; } // Request message for `UpdateProjectBillingInfo`. diff --git a/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/AsyncGetProjectBillingInfo.java b/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/AsyncGetProjectBillingInfo.java index 4a35142430ce..0d3495976d5b 100644 --- a/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/AsyncGetProjectBillingInfo.java +++ b/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/AsyncGetProjectBillingInfo.java @@ -21,6 +21,7 @@ import com.google.cloud.billing.v1.CloudBillingClient; import com.google.cloud.billing.v1.GetProjectBillingInfoRequest; import com.google.cloud.billing.v1.ProjectBillingInfo; +import com.google.cloud.billing.v1.ProjectBillingInfoName; public class AsyncGetProjectBillingInfo { @@ -36,7 +37,9 @@ public static void asyncGetProjectBillingInfo() throws Exception { // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { GetProjectBillingInfoRequest request = - GetProjectBillingInfoRequest.newBuilder().setName("name3373707").build(); + GetProjectBillingInfoRequest.newBuilder() + .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) + .build(); ApiFuture future = cloudBillingClient.getProjectBillingInfoCallable().futureCall(request); // Do something. diff --git a/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfo.java b/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfo.java index 4dcbb47bbe3d..f471f90f8804 100644 --- a/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfo.java +++ b/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfo.java @@ -20,6 +20,7 @@ import com.google.cloud.billing.v1.CloudBillingClient; import com.google.cloud.billing.v1.GetProjectBillingInfoRequest; import com.google.cloud.billing.v1.ProjectBillingInfo; +import com.google.cloud.billing.v1.ProjectBillingInfoName; public class SyncGetProjectBillingInfo { @@ -35,7 +36,9 @@ public static void syncGetProjectBillingInfo() throws Exception { // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { GetProjectBillingInfoRequest request = - GetProjectBillingInfoRequest.newBuilder().setName("name3373707").build(); + GetProjectBillingInfoRequest.newBuilder() + .setName(ProjectBillingInfoName.of("[PROJECT]").toString()) + .build(); ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(request); } } diff --git a/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfoProjectbillinginfoname.java b/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfoProjectbillinginfoname.java new file mode 100644 index 000000000000..ee5e2795492b --- /dev/null +++ b/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfoProjectbillinginfoname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.billing.v1.samples; + +// [START cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_Projectbillinginfoname_sync] +import com.google.cloud.billing.v1.CloudBillingClient; +import com.google.cloud.billing.v1.ProjectBillingInfo; +import com.google.cloud.billing.v1.ProjectBillingInfoName; + +public class SyncGetProjectBillingInfoProjectbillinginfoname { + + public static void main(String[] args) throws Exception { + syncGetProjectBillingInfoProjectbillinginfoname(); + } + + public static void syncGetProjectBillingInfoProjectbillinginfoname() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { + ProjectBillingInfoName name = ProjectBillingInfoName.of("[PROJECT]"); + ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(name); + } + } +} +// [END cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_Projectbillinginfoname_sync] diff --git a/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfoString.java b/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfoString.java index fcf5bd7cc0cd..5d6ed7262e2c 100644 --- a/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfoString.java +++ b/java-billing/samples/snippets/generated/com/google/cloud/billing/v1/cloudbilling/getprojectbillinginfo/SyncGetProjectBillingInfoString.java @@ -19,6 +19,7 @@ // [START cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_String_sync] import com.google.cloud.billing.v1.CloudBillingClient; import com.google.cloud.billing.v1.ProjectBillingInfo; +import com.google.cloud.billing.v1.ProjectBillingInfoName; public class SyncGetProjectBillingInfoString { @@ -33,7 +34,7 @@ public static void syncGetProjectBillingInfoString() throws Exception { // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) { - String name = "name3373707"; + String name = ProjectBillingInfoName.of("[PROJECT]").toString(); ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(name); } }