diff --git a/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudBillingClient.java b/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudBillingClient.java index b862a5ea..50603b35 100644 --- a/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudBillingClient.java +++ b/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudBillingClient.java @@ -47,6 +47,13 @@ *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

{@code
+ * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+ *   BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]");
+ *   BillingAccount response = cloudBillingClient.getBillingAccount(name);
+ * }
+ * }
+ * *

Note: close() needs to be called on the CloudBillingClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -150,6 +157,15 @@ public CloudBillingStub getStub() { * Gets information about a billing account. The current authenticated user must be a [viewer of * the billing account](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   BillingAccount response = cloudBillingClient.getBillingAccount(name);
+   * }
+   * }
+ * * @param name Required. The resource name of the billing account to retrieve. For example, * `billingAccounts/012345-567890-ABCDEF`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -167,6 +183,15 @@ public final BillingAccount getBillingAccount(BillingAccountName name) { * Gets information about a billing account. The current authenticated user must be a [viewer of * the billing account](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString();
+   *   BillingAccount response = cloudBillingClient.getBillingAccount(name);
+   * }
+   * }
+ * * @param name Required. The resource name of the billing account to retrieve. For example, * `billingAccounts/012345-567890-ABCDEF`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -181,6 +206,18 @@ public final BillingAccount getBillingAccount(String name) { * Gets information about a billing account. The current authenticated user must be a [viewer of * the billing account](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   GetBillingAccountRequest request =
+   *       GetBillingAccountRequest.newBuilder()
+   *           .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
+   *           .build();
+   *   BillingAccount response = cloudBillingClient.getBillingAccount(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -194,6 +231,19 @@ public final BillingAccount getBillingAccount(GetBillingAccountRequest request) * the billing account](https://cloud.google.com/billing/docs/how-to/billing-access). * *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   GetBillingAccountRequest request =
+   *       GetBillingAccountRequest.newBuilder()
+   *           .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       cloudBillingClient.getBillingAccountCallable().futureCall(request);
+   *   // Do something.
+   *   BillingAccount response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getBillingAccountCallable() { return stub.getBillingAccountCallable(); @@ -204,6 +254,16 @@ public final UnaryCallable getBillingA * Lists the billing accounts that the current authenticated user has permission to * [view](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   for (BillingAccount element : cloudBillingClient.listBillingAccounts().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -217,6 +277,22 @@ public final ListBillingAccountsPagedResponse listBillingAccounts() { * Lists the billing accounts that the current authenticated user has permission to * [view](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   ListBillingAccountsRequest request =
+   *       ListBillingAccountsRequest.newBuilder()
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   for (BillingAccount element : cloudBillingClient.listBillingAccounts(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -231,6 +307,23 @@ public final ListBillingAccountsPagedResponse listBillingAccounts( * [view](https://cloud.google.com/billing/docs/how-to/billing-access). * *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   ListBillingAccountsRequest request =
+   *       ListBillingAccountsRequest.newBuilder()
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   ApiFuture future =
+   *       cloudBillingClient.listBillingAccountsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (BillingAccount element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listBillingAccountsPagedCallable() { @@ -243,6 +336,24 @@ public final ListBillingAccountsPagedResponse listBillingAccounts( * [view](https://cloud.google.com/billing/docs/how-to/billing-access). * *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   while (true) {
+   *     ListBillingAccountsResponse response =
+   *         cloudBillingClient.listBillingAccountsCallable().call(request);
+   *     for (BillingAccount element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listBillingAccountsCallable() { @@ -257,6 +368,16 @@ public final ListBillingAccountsPagedResponse listBillingAccounts( * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing * account. * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   BillingAccount account = BillingAccount.newBuilder().build();
+   *   BillingAccount response = cloudBillingClient.updateBillingAccount(name, account);
+   * }
+   * }
+ * * @param name Required. The name of the billing account resource to be updated. * @param account Required. The billing account resource to replace the resource on the server. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -279,6 +400,16 @@ public final BillingAccount updateBillingAccount( * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing * account. * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString();
+   *   BillingAccount account = BillingAccount.newBuilder().build();
+   *   BillingAccount response = cloudBillingClient.updateBillingAccount(name, account);
+   * }
+   * }
+ * * @param name Required. The name of the billing account resource to be updated. * @param account Required. The billing account resource to replace the resource on the server. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -297,6 +428,20 @@ public final BillingAccount updateBillingAccount(String name, BillingAccount acc * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing * account. * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   UpdateBillingAccountRequest request =
+   *       UpdateBillingAccountRequest.newBuilder()
+   *           .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
+   *           .setAccount(BillingAccount.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   BillingAccount response = cloudBillingClient.updateBillingAccount(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -313,6 +458,21 @@ public final BillingAccount updateBillingAccount(UpdateBillingAccountRequest req * account. * *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   UpdateBillingAccountRequest request =
+   *       UpdateBillingAccountRequest.newBuilder()
+   *           .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
+   *           .setAccount(BillingAccount.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       cloudBillingClient.updateBillingAccountCallable().futureCall(request);
+   *   // Do something.
+   *   BillingAccount response = future.get();
+   * }
+   * }
*/ public final UnaryCallable updateBillingAccountCallable() { @@ -328,6 +488,15 @@ public final BillingAccount updateBillingAccount(UpdateBillingAccountRequest req * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will * return an error if the master account has not been provisioned as a reseller account. * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   BillingAccount billingAccount = BillingAccount.newBuilder().build();
+   *   BillingAccount response = cloudBillingClient.createBillingAccount(billingAccount);
+   * }
+   * }
+ * * @param billingAccount Required. The billing account resource to create. Currently * CreateBillingAccount only supports subaccount creation, so any created billing accounts * must be under a provided master billing account. @@ -348,6 +517,18 @@ public final BillingAccount createBillingAccount(BillingAccount billingAccount) * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will * return an error if the master account has not been provisioned as a reseller account. * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   CreateBillingAccountRequest request =
+   *       CreateBillingAccountRequest.newBuilder()
+   *           .setBillingAccount(BillingAccount.newBuilder().build())
+   *           .build();
+   *   BillingAccount response = cloudBillingClient.createBillingAccount(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -365,6 +546,19 @@ public final BillingAccount createBillingAccount(CreateBillingAccountRequest req * return an error if the master account has not been provisioned as a reseller account. * *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   CreateBillingAccountRequest request =
+   *       CreateBillingAccountRequest.newBuilder()
+   *           .setBillingAccount(BillingAccount.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       cloudBillingClient.createBillingAccountCallable().futureCall(request);
+   *   // Do something.
+   *   BillingAccount response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createBillingAccountCallable() { @@ -377,6 +571,18 @@ public final BillingAccount createBillingAccount(CreateBillingAccountRequest req * the `billing.resourceAssociations.list` IAM permission, which is often given to billing account * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]");
+   *   for (ProjectBillingInfo element :
+   *       cloudBillingClient.listProjectBillingInfo(name).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param name Required. The resource name of the billing account associated with the projects * that you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -395,6 +601,18 @@ public final ListProjectBillingInfoPagedResponse listProjectBillingInfo(BillingA * the `billing.resourceAssociations.list` IAM permission, which is often given to billing account * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   String name = BillingAccountName.of("[BILLING_ACCOUNT]").toString();
+   *   for (ProjectBillingInfo element :
+   *       cloudBillingClient.listProjectBillingInfo(name).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param name Required. The resource name of the billing account associated with the projects * that you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -411,6 +629,23 @@ public final ListProjectBillingInfoPagedResponse listProjectBillingInfo(String n * the `billing.resourceAssociations.list` IAM permission, which is often given to billing account * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   ListProjectBillingInfoRequest request =
+   *       ListProjectBillingInfoRequest.newBuilder()
+   *           .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (ProjectBillingInfo element :
+   *       cloudBillingClient.listProjectBillingInfo(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -426,6 +661,23 @@ public final ListProjectBillingInfoPagedResponse listProjectBillingInfo( * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   ListProjectBillingInfoRequest request =
+   *       ListProjectBillingInfoRequest.newBuilder()
+   *           .setName(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       cloudBillingClient.listProjectBillingInfoPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (ProjectBillingInfo element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listProjectBillingInfoPagedCallable() { @@ -439,6 +691,24 @@ public final ListProjectBillingInfoPagedResponse listProjectBillingInfo( * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   while (true) {
+   *     ListProjectBillingInfoResponse response =
+   *         cloudBillingClient.listProjectBillingInfoCallable().call(request);
+   *     for (ProjectBillingInfo element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listProjectBillingInfoCallable() { @@ -451,6 +721,15 @@ public final ListProjectBillingInfoPagedResponse listProjectBillingInfo( * [permission to view the * project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   String name = "name3373707";
+   *   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 @@ -467,6 +746,16 @@ public final ProjectBillingInfo getProjectBillingInfo(String name) { * [permission to view the * project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ). * + *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   GetProjectBillingInfoRequest request =
+   *       GetProjectBillingInfoRequest.newBuilder().setName("name3373707").build();
+   *   ProjectBillingInfo response = cloudBillingClient.getProjectBillingInfo(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -481,6 +770,17 @@ public final ProjectBillingInfo getProjectBillingInfo(GetProjectBillingInfoReque * project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ). * *

Sample code: + * + *

{@code
+   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
+   *   GetProjectBillingInfoRequest request =
+   *       GetProjectBillingInfoRequest.newBuilder().setName("name3373707").build();
+   *   ApiFuture future =
+   *       cloudBillingClient.getProjectBillingInfoCallable().futureCall(request);
+   *   // Do something.
+   *   ProjectBillingInfo response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getProjectBillingInfoCallable() { @@ -519,6 +819,17 @@ public final ProjectBillingInfo getProjectBillingInfo(GetProjectBillingInfoReque *
  • open* billing account. * * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   String name = "name3373707";
    +   *   ProjectBillingInfo projectBillingInfo = ProjectBillingInfo.newBuilder().build();
    +   *   ProjectBillingInfo response =
    +   *       cloudBillingClient.updateProjectBillingInfo(name, projectBillingInfo);
    +   * }
    +   * }
    + * * @param name Required. The resource name of the project associated with the billing information * that you want to update. For example, `projects/tokyo-rain-123`. * @param projectBillingInfo The new billing information for the project. Read-only fields are @@ -567,6 +878,19 @@ public final ProjectBillingInfo updateProjectBillingInfo( *
  • open* billing account. * * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   UpdateProjectBillingInfoRequest request =
    +   *       UpdateProjectBillingInfoRequest.newBuilder()
    +   *           .setName("name3373707")
    +   *           .setProjectBillingInfo(ProjectBillingInfo.newBuilder().build())
    +   *           .build();
    +   *   ProjectBillingInfo response = cloudBillingClient.updateProjectBillingInfo(request);
    +   * }
    +   * }
    + * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -608,6 +932,20 @@ public final ProjectBillingInfo updateProjectBillingInfo( * * *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   UpdateProjectBillingInfoRequest request =
    +   *       UpdateProjectBillingInfoRequest.newBuilder()
    +   *           .setName("name3373707")
    +   *           .setProjectBillingInfo(ProjectBillingInfo.newBuilder().build())
    +   *           .build();
    +   *   ApiFuture future =
    +   *       cloudBillingClient.updateProjectBillingInfoCallable().futureCall(request);
    +   *   // Do something.
    +   *   ProjectBillingInfo response = future.get();
    +   * }
    +   * }
    */ public final UnaryCallable updateProjectBillingInfoCallable() { @@ -620,6 +958,15 @@ public final ProjectBillingInfo updateProjectBillingInfo( * `billing.accounts.getIamPolicy` permission on the account, which is often given to billing * account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]");
    +   *   Policy response = cloudBillingClient.getIamPolicy(resource);
    +   * }
    +   * }
    + * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -638,6 +985,15 @@ public final Policy getIamPolicy(ResourceName resource) { * `billing.accounts.getIamPolicy` permission on the account, which is often given to billing * account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString();
    +   *   Policy response = cloudBillingClient.getIamPolicy(resource);
    +   * }
    +   * }
    + * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -653,6 +1009,19 @@ public final Policy getIamPolicy(String resource) { * `billing.accounts.getIamPolicy` permission on the account, which is often given to billing * account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   GetIamPolicyRequest request =
    +   *       GetIamPolicyRequest.newBuilder()
    +   *           .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
    +   *           .setOptions(GetPolicyOptions.newBuilder().build())
    +   *           .build();
    +   *   Policy response = cloudBillingClient.getIamPolicy(request);
    +   * }
    +   * }
    + * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -667,6 +1036,19 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { * account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). * *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   GetIamPolicyRequest request =
    +   *       GetIamPolicyRequest.newBuilder()
    +   *           .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
    +   *           .setOptions(GetPolicyOptions.newBuilder().build())
    +   *           .build();
    +   *   ApiFuture future = cloudBillingClient.getIamPolicyCallable().futureCall(request);
    +   *   // Do something.
    +   *   Policy response = future.get();
    +   * }
    +   * }
    */ public final UnaryCallable getIamPolicyCallable() { return stub.getIamPolicyCallable(); @@ -679,6 +1061,16 @@ public final UnaryCallable getIamPolicyCallable() { * to billing account * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]");
    +   *   Policy policy = Policy.newBuilder().build();
    +   *   Policy response = cloudBillingClient.setIamPolicy(resource, policy);
    +   * }
    +   * }
    + * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -702,6 +1094,16 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) { * to billing account * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString();
    +   *   Policy policy = Policy.newBuilder().build();
    +   *   Policy response = cloudBillingClient.setIamPolicy(resource, policy);
    +   * }
    +   * }
    + * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -722,6 +1124,19 @@ public final Policy setIamPolicy(String resource, Policy policy) { * to billing account * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   SetIamPolicyRequest request =
    +   *       SetIamPolicyRequest.newBuilder()
    +   *           .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
    +   *           .setPolicy(Policy.newBuilder().build())
    +   *           .build();
    +   *   Policy response = cloudBillingClient.setIamPolicy(request);
    +   * }
    +   * }
    + * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -737,6 +1152,19 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). * *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   SetIamPolicyRequest request =
    +   *       SetIamPolicyRequest.newBuilder()
    +   *           .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
    +   *           .setPolicy(Policy.newBuilder().build())
    +   *           .build();
    +   *   ApiFuture future = cloudBillingClient.setIamPolicyCallable().futureCall(request);
    +   *   // Do something.
    +   *   Policy response = future.get();
    +   * }
    +   * }
    */ public final UnaryCallable setIamPolicyCallable() { return stub.setIamPolicyCallable(); @@ -748,6 +1176,17 @@ public final UnaryCallable setIamPolicyCallable() { * of permissions as input and returns the subset of the input permissions that the caller is * allowed for that resource. * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   ResourceName resource = BillingAccountName.of("[BILLING_ACCOUNT]");
    +   *   List permissions = new ArrayList<>();
    +   *   TestIamPermissionsResponse response =
    +   *       cloudBillingClient.testIamPermissions(resource, permissions);
    +   * }
    +   * }
    + * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -771,6 +1210,17 @@ public final TestIamPermissionsResponse testIamPermissions( * of permissions as input and returns the subset of the input permissions that the caller is * allowed for that resource. * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   String resource = BillingAccountName.of("[BILLING_ACCOUNT]").toString();
    +   *   List permissions = new ArrayList<>();
    +   *   TestIamPermissionsResponse response =
    +   *       cloudBillingClient.testIamPermissions(resource, permissions);
    +   * }
    +   * }
    + * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -794,6 +1244,19 @@ public final TestIamPermissionsResponse testIamPermissions( * of permissions as input and returns the subset of the input permissions that the caller is * allowed for that resource. * + *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   TestIamPermissionsRequest request =
    +   *       TestIamPermissionsRequest.newBuilder()
    +   *           .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
    +   *           .addAllPermissions(new ArrayList())
    +   *           .build();
    +   *   TestIamPermissionsResponse response = cloudBillingClient.testIamPermissions(request);
    +   * }
    +   * }
    + * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -808,6 +1271,20 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * allowed for that resource. * *

    Sample code: + * + *

    {@code
    +   * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    +   *   TestIamPermissionsRequest request =
    +   *       TestIamPermissionsRequest.newBuilder()
    +   *           .setResource(BillingAccountName.of("[BILLING_ACCOUNT]").toString())
    +   *           .addAllPermissions(new ArrayList())
    +   *           .build();
    +   *   ApiFuture future =
    +   *       cloudBillingClient.testIamPermissionsCallable().futureCall(request);
    +   *   // Do something.
    +   *   TestIamPermissionsResponse response = future.get();
    +   * }
    +   * }
    */ public final UnaryCallable testIamPermissionsCallable() { diff --git a/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudCatalogClient.java b/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudCatalogClient.java index 9a85d566..4293dd04 100644 --- a/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudCatalogClient.java +++ b/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/CloudCatalogClient.java @@ -42,6 +42,14 @@ *

    This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * + *

    {@code
    + * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    + *   for (Service element : cloudCatalogClient.listServices().iterateAll()) {
    + *     // doThingsWith(element);
    + *   }
    + * }
    + * }
    + * *

    Note: close() needs to be called on the CloudCatalogClient object to clean up resources such * as threads. In the example above, try-with-resources is used, which automatically calls close(). * @@ -144,6 +152,16 @@ public CloudCatalogStub getStub() { /** * Lists all public cloud services. * + *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   for (Service element : cloudCatalogClient.listServices().iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    + * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -156,6 +174,21 @@ public final ListServicesPagedResponse listServices() { /** * Lists all public cloud services. * + *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   ListServicesRequest request =
    +   *       ListServicesRequest.newBuilder()
    +   *           .setPageSize(883849137)
    +   *           .setPageToken("pageToken873572522")
    +   *           .build();
    +   *   for (Service element : cloudCatalogClient.listServices(request).iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    + * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -168,6 +201,22 @@ public final ListServicesPagedResponse listServices(ListServicesRequest request) * Lists all public cloud services. * *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   ListServicesRequest request =
    +   *       ListServicesRequest.newBuilder()
    +   *           .setPageSize(883849137)
    +   *           .setPageToken("pageToken873572522")
    +   *           .build();
    +   *   ApiFuture future =
    +   *       cloudCatalogClient.listServicesPagedCallable().futureCall(request);
    +   *   // Do something.
    +   *   for (Service element : future.get().iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    */ public final UnaryCallable listServicesPagedCallable() { @@ -179,6 +228,23 @@ public final ListServicesPagedResponse listServices(ListServicesRequest request) * Lists all public cloud services. * *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   while (true) {
    +   *     ListServicesResponse response = cloudCatalogClient.listServicesCallable().call(request);
    +   *     for (Service element : response.getResponsesList()) {
    +   *       // doThingsWith(element);
    +   *     }
    +   *     String nextPageToken = response.getNextPageToken();
    +   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
    +   *       request = request.toBuilder().setPageToken(nextPageToken).build();
    +   *     } else {
    +   *       break;
    +   *     }
    +   *   }
    +   * }
    +   * }
    */ public final UnaryCallable listServicesCallable() { return stub.listServicesCallable(); @@ -188,6 +254,17 @@ public final UnaryCallable listServic /** * Lists all publicly available SKUs for a given cloud service. * + *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   ServiceName parent = ServiceName.of("[SERVICE]");
    +   *   for (Sku element : cloudCatalogClient.listSkus(parent).iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    + * * @param parent Required. The name of the service. Example: "services/DA34-426B-A397" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -201,6 +278,17 @@ public final ListSkusPagedResponse listSkus(ServiceName parent) { /** * Lists all publicly available SKUs for a given cloud service. * + *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   String parent = ServiceName.of("[SERVICE]").toString();
    +   *   for (Sku element : cloudCatalogClient.listSkus(parent).iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    + * * @param parent Required. The name of the service. Example: "services/DA34-426B-A397" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -213,6 +301,25 @@ public final ListSkusPagedResponse listSkus(String parent) { /** * Lists all publicly available SKUs for a given cloud service. * + *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   ListSkusRequest request =
    +   *       ListSkusRequest.newBuilder()
    +   *           .setParent(ServiceName.of("[SERVICE]").toString())
    +   *           .setStartTime(Timestamp.newBuilder().build())
    +   *           .setEndTime(Timestamp.newBuilder().build())
    +   *           .setCurrencyCode("currencyCode1004773790")
    +   *           .setPageSize(883849137)
    +   *           .setPageToken("pageToken873572522")
    +   *           .build();
    +   *   for (Sku element : cloudCatalogClient.listSkus(request).iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    + * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -225,6 +332,25 @@ public final ListSkusPagedResponse listSkus(ListSkusRequest request) { * Lists all publicly available SKUs for a given cloud service. * *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   ListSkusRequest request =
    +   *       ListSkusRequest.newBuilder()
    +   *           .setParent(ServiceName.of("[SERVICE]").toString())
    +   *           .setStartTime(Timestamp.newBuilder().build())
    +   *           .setEndTime(Timestamp.newBuilder().build())
    +   *           .setCurrencyCode("currencyCode1004773790")
    +   *           .setPageSize(883849137)
    +   *           .setPageToken("pageToken873572522")
    +   *           .build();
    +   *   ApiFuture future = cloudCatalogClient.listSkusPagedCallable().futureCall(request);
    +   *   // Do something.
    +   *   for (Sku element : future.get().iterateAll()) {
    +   *     // doThingsWith(element);
    +   *   }
    +   * }
    +   * }
    */ public final UnaryCallable listSkusPagedCallable() { return stub.listSkusPagedCallable(); @@ -235,6 +361,23 @@ public final UnaryCallable listSkusPaged * Lists all publicly available SKUs for a given cloud service. * *

    Sample code: + * + *

    {@code
    +   * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    +   *   while (true) {
    +   *     ListSkusResponse response = cloudCatalogClient.listSkusCallable().call(request);
    +   *     for (Sku element : response.getResponsesList()) {
    +   *       // doThingsWith(element);
    +   *     }
    +   *     String nextPageToken = response.getNextPageToken();
    +   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
    +   *       request = request.toBuilder().setPageToken(nextPageToken).build();
    +   *     } else {
    +   *       break;
    +   *     }
    +   *   }
    +   * }
    +   * }
    */ public final UnaryCallable listSkusCallable() { return stub.listSkusCallable(); diff --git a/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/package-info.java b/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/package-info.java index 315a2be8..40599c2f 100644 --- a/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/package-info.java +++ b/google-cloud-billing/src/main/java/com/google/cloud/billing/v1/package-info.java @@ -23,12 +23,27 @@ * *

    Sample for CloudBillingClient: * + *

    {@code
    + * try (CloudBillingClient cloudBillingClient = CloudBillingClient.create()) {
    + *   BillingAccountName name = BillingAccountName.of("[BILLING_ACCOUNT]");
    + *   BillingAccount response = cloudBillingClient.getBillingAccount(name);
    + * }
    + * }
    + * *

    ======================= CloudCatalogClient ======================= * *

    Service Description: A catalog of Google Cloud Platform services and SKUs. Provides pricing * information and metadata on Google Cloud Platform services and SKUs. * *

    Sample for CloudCatalogClient: + * + *

    {@code
    + * try (CloudCatalogClient cloudCatalogClient = CloudCatalogClient.create()) {
    + *   for (Service element : cloudCatalogClient.listServices().iterateAll()) {
    + *     // doThingsWith(element);
    + *   }
    + * }
    + * }
    */ @Generated("by gapic-generator-java") package com.google.cloud.billing.v1; diff --git a/synth.metadata b/synth.metadata index ce015670..7b1e41a7 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-billing.git", - "sha": "41f8dedd6f81d97ba6493a117595a4930db8ff71" + "sha": "12cbb3a8a3a51fb2bee085f34741aa7f3cb31229" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {