Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

docs: generate sample code in the Java microgenerator #381

Merged
merged 1 commit into from Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -44,6 +44,14 @@
* <p>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:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
* Budget budget = Budget.newBuilder().build();
* Budget response = budgetServiceClient.createBudget(parent, budget);
* }
* }</pre>
*
* <p>Note: close() needs to be called on the BudgetServiceClient object to clean up resources such
* as threads. In the example above, try-with-resources is used, which automatically calls close().
*
Expand Down Expand Up @@ -148,6 +156,16 @@ public BudgetServiceStub getStub() {
* Creates a new budget. See [Quotas and limits](https://cloud.google.com/billing/quotas) for more
* information on the limits of the number of budgets you can create.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
* Budget budget = Budget.newBuilder().build();
* Budget response = budgetServiceClient.createBudget(parent, budget);
* }
* }</pre>
*
* @param parent Required. The name of the billing account to create the budget in. Values are of
* the form `billingAccounts/{billingAccountId}`.
* @param budget Required. Budget to create.
Expand All @@ -167,6 +185,16 @@ public final Budget createBudget(BillingAccountName parent, Budget budget) {
* Creates a new budget. See [Quotas and limits](https://cloud.google.com/billing/quotas) for more
* information on the limits of the number of budgets you can create.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* String parent = BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString();
* Budget budget = Budget.newBuilder().build();
* Budget response = budgetServiceClient.createBudget(parent, budget);
* }
* }</pre>
*
* @param parent Required. The name of the billing account to create the budget in. Values are of
* the form `billingAccounts/{billingAccountId}`.
* @param budget Required. Budget to create.
Expand All @@ -183,6 +211,19 @@ public final Budget createBudget(String parent, Budget budget) {
* Creates a new budget. See [Quotas and limits](https://cloud.google.com/billing/quotas) for more
* information on the limits of the number of budgets you can create.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* CreateBudgetRequest request =
* CreateBudgetRequest.newBuilder()
* .setParent(BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString())
* .setBudget(Budget.newBuilder().build())
* .build();
* Budget response = budgetServiceClient.createBudget(request);
* }
* }</pre>
*
* @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
*/
Expand All @@ -196,6 +237,19 @@ public final Budget createBudget(CreateBudgetRequest request) {
* information on the limits of the number of budgets you can create.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* CreateBudgetRequest request =
* CreateBudgetRequest.newBuilder()
* .setParent(BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString())
* .setBudget(Budget.newBuilder().build())
* .build();
* ApiFuture<Budget> future = budgetServiceClient.createBudgetCallable().futureCall(request);
* // Do something.
* Budget response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<CreateBudgetRequest, Budget> createBudgetCallable() {
return stub.createBudgetCallable();
Expand All @@ -208,6 +262,16 @@ public final UnaryCallable<CreateBudgetRequest, Budget> createBudgetCallable() {
* <p>WARNING: There are some fields exposed on the Google Cloud Console that aren't available on
* this API. Budget fields that are not exposed in this API will not be changed by this method.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* Budget budget = Budget.newBuilder().build();
* FieldMask updateMask = FieldMask.newBuilder().build();
* Budget response = budgetServiceClient.updateBudget(budget, updateMask);
* }
* }</pre>
*
* @param budget Required. The updated budget object. The budget to update is specified by the
* budget name in the budget.
* @param updateMask Optional. Indicates which fields in the provided budget to update. Read-only
Expand All @@ -230,6 +294,19 @@ public final Budget updateBudget(Budget budget, FieldMask updateMask) {
* <p>WARNING: There are some fields exposed on the Google Cloud Console that aren't available on
* this API. Budget fields that are not exposed in this API will not be changed by this method.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* UpdateBudgetRequest request =
* UpdateBudgetRequest.newBuilder()
* .setBudget(Budget.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* Budget response = budgetServiceClient.updateBudget(request);
* }
* }</pre>
*
* @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
*/
Expand All @@ -245,6 +322,19 @@ public final Budget updateBudget(UpdateBudgetRequest request) {
* this API. Budget fields that are not exposed in this API will not be changed by this method.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* UpdateBudgetRequest request =
* UpdateBudgetRequest.newBuilder()
* .setBudget(Budget.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture<Budget> future = budgetServiceClient.updateBudgetCallable().futureCall(request);
* // Do something.
* Budget response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<UpdateBudgetRequest, Budget> updateBudgetCallable() {
return stub.updateBudgetCallable();
Expand All @@ -258,6 +348,15 @@ public final UnaryCallable<UpdateBudgetRequest, Budget> updateBudgetCallable() {
* this API. When reading from the API, you will not see these fields in the return value, though
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* BudgetName name = BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]");
* Budget response = budgetServiceClient.getBudget(name);
* }
* }</pre>
*
* @param name Required. Name of budget to get. Values are of the form
* `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand All @@ -276,6 +375,15 @@ public final Budget getBudget(BudgetName name) {
* this API. When reading from the API, you will not see these fields in the return value, though
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* String name = BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString();
* Budget response = budgetServiceClient.getBudget(name);
* }
* }</pre>
*
* @param name Required. Name of budget to get. Values are of the form
* `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand All @@ -293,6 +401,18 @@ public final Budget getBudget(String name) {
* this API. When reading from the API, you will not see these fields in the return value, though
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* GetBudgetRequest request =
* GetBudgetRequest.newBuilder()
* .setName(BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString())
* .build();
* Budget response = budgetServiceClient.getBudget(request);
* }
* }</pre>
*
* @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
*/
Expand All @@ -309,6 +429,18 @@ public final Budget getBudget(GetBudgetRequest request) {
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* GetBudgetRequest request =
* GetBudgetRequest.newBuilder()
* .setName(BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString())
* .build();
* ApiFuture<Budget> future = budgetServiceClient.getBudgetCallable().futureCall(request);
* // Do something.
* Budget response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<GetBudgetRequest, Budget> getBudgetCallable() {
return stub.getBudgetCallable();
Expand All @@ -322,6 +454,17 @@ public final UnaryCallable<GetBudgetRequest, Budget> getBudgetCallable() {
* this API. When reading from the API, you will not see these fields in the return value, though
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
* for (Budget element : budgetServiceClient.listBudgets(parent).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param parent Required. Name of billing account to list budgets under. Values are of the form
* `billingAccounts/{billingAccountId}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand All @@ -342,6 +485,17 @@ public final ListBudgetsPagedResponse listBudgets(BillingAccountName parent) {
* this API. When reading from the API, you will not see these fields in the return value, though
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* String parent = BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString();
* for (Budget element : budgetServiceClient.listBudgets(parent).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @param parent Required. Name of billing account to list budgets under. Values are of the form
* `billingAccounts/{billingAccountId}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand All @@ -359,6 +513,22 @@ public final ListBudgetsPagedResponse listBudgets(String parent) {
* this API. When reading from the API, you will not see these fields in the return value, though
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* ListBudgetsRequest request =
* ListBudgetsRequest.newBuilder()
* .setParent(BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* for (Budget element : budgetServiceClient.listBudgets(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*
* @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
*/
Expand All @@ -375,6 +545,22 @@ public final ListBudgetsPagedResponse listBudgets(ListBudgetsRequest request) {
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* ListBudgetsRequest request =
* ListBudgetsRequest.newBuilder()
* .setParent(BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture<Budget> future = budgetServiceClient.listBudgetsPagedCallable().futureCall(request);
* // Do something.
* for (Budget element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*/
public final UnaryCallable<ListBudgetsRequest, ListBudgetsPagedResponse>
listBudgetsPagedCallable() {
Expand All @@ -390,6 +576,23 @@ public final ListBudgetsPagedResponse listBudgets(ListBudgetsRequest request) {
* they may have been set in the Cloud Console.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* while (true) {
* ListBudgetsResponse response = budgetServiceClient.listBudgetsCallable().call(request);
* for (Budget element : response.getResponsesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }</pre>
*/
public final UnaryCallable<ListBudgetsRequest, ListBudgetsResponse> listBudgetsCallable() {
return stub.listBudgetsCallable();
Expand All @@ -399,6 +602,15 @@ public final UnaryCallable<ListBudgetsRequest, ListBudgetsResponse> listBudgetsC
/**
* Deletes a budget. Returns successfully if already deleted.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* BudgetName name = BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]");
* budgetServiceClient.deleteBudget(name);
* }
* }</pre>
*
* @param name Required. Name of the budget to delete. Values are of the form
* `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand All @@ -413,6 +625,15 @@ public final void deleteBudget(BudgetName name) {
/**
* Deletes a budget. Returns successfully if already deleted.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* String name = BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString();
* budgetServiceClient.deleteBudget(name);
* }
* }</pre>
*
* @param name Required. Name of the budget to delete. Values are of the form
* `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
Expand All @@ -426,6 +647,18 @@ public final void deleteBudget(String name) {
/**
* Deletes a budget. Returns successfully if already deleted.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* DeleteBudgetRequest request =
* DeleteBudgetRequest.newBuilder()
* .setName(BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString())
* .build();
* budgetServiceClient.deleteBudget(request);
* }
* }</pre>
*
* @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
*/
Expand All @@ -438,6 +671,18 @@ public final void deleteBudget(DeleteBudgetRequest request) {
* Deletes a budget. Returns successfully if already deleted.
*
* <p>Sample code:
*
* <pre>{@code
* try (BudgetServiceClient budgetServiceClient = BudgetServiceClient.create()) {
* DeleteBudgetRequest request =
* DeleteBudgetRequest.newBuilder()
* .setName(BudgetName.of("[BILLING_ACCOUNT]", "[BUDGET]").toString())
* .build();
* ApiFuture<Empty> future = budgetServiceClient.deleteBudgetCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }</pre>
*/
public final UnaryCallable<DeleteBudgetRequest, Empty> deleteBudgetCallable() {
return stub.deleteBudgetCallable();
Expand Down