From c7d532323d4fa10815494a393d7dc545345f4f94 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 9 Feb 2021 10:50:08 -0800 Subject: [PATCH] docs: generate sample code in the Java microgenerator (#296) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/89565b2d-2643-4c84-a434-564a46601538/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 356341083 Source-Link: https://github.com/googleapis/googleapis/commit/8d8c008e56f1af31d57f75561e0f1848ffb29eeb --- .../dashboard/v1/DashboardsServiceClient.java | 160 ++++++++++++++++++ .../monitoring/dashboard/v1/package-info.java | 11 ++ synth.metadata | 6 +- 3 files changed, 174 insertions(+), 3 deletions(-) diff --git a/google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/DashboardsServiceClient.java b/google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/DashboardsServiceClient.java index 30e600ed..8a58a9b6 100644 --- a/google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/DashboardsServiceClient.java +++ b/google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/DashboardsServiceClient.java @@ -50,6 +50,17 @@ *

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 (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+ *   CreateDashboardRequest request =
+ *       CreateDashboardRequest.newBuilder()
+ *           .setParent("parent-995424086")
+ *           .setDashboard(Dashboard.newBuilder().build())
+ *           .build();
+ *   Dashboard response = dashboardsServiceClient.createDashboard(request);
+ * }
+ * }
+ * *

Note: close() needs to be called on the DashboardsServiceClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -159,6 +170,19 @@ public DashboardsServiceStub getStub() { *

This method requires the `monitoring.dashboards.create` permission on the specified project. * For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * + *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   CreateDashboardRequest request =
+   *       CreateDashboardRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setDashboard(Dashboard.newBuilder().build())
+   *           .build();
+   *   Dashboard response = dashboardsServiceClient.createDashboard(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 */ @@ -174,6 +198,20 @@ public final Dashboard createDashboard(CreateDashboardRequest request) { * For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   CreateDashboardRequest request =
+   *       CreateDashboardRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setDashboard(Dashboard.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       dashboardsServiceClient.createDashboardCallable().futureCall(request);
+   *   // Do something.
+   *   Dashboard response = future.get();
+   * }
+   * }
*/ public final UnaryCallable createDashboardCallable() { return stub.createDashboardCallable(); @@ -186,6 +224,22 @@ public final UnaryCallable createDashboardCal *

This method requires the `monitoring.dashboards.list` permission on the specified project. * For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * + *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   ListDashboardsRequest request =
+   *       ListDashboardsRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Dashboard element : dashboardsServiceClient.listDashboards(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 */ @@ -201,6 +255,23 @@ public final ListDashboardsPagedResponse listDashboards(ListDashboardsRequest re * For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   ListDashboardsRequest request =
+   *       ListDashboardsRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       dashboardsServiceClient.listDashboardsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Dashboard element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listDashboardsPagedCallable() { @@ -215,6 +286,24 @@ public final ListDashboardsPagedResponse listDashboards(ListDashboardsRequest re * For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   while (true) {
+   *     ListDashboardsResponse response =
+   *         dashboardsServiceClient.listDashboardsCallable().call(request);
+   *     for (Dashboard element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
*/ public final UnaryCallable listDashboardsCallable() { @@ -228,6 +317,18 @@ public final ListDashboardsPagedResponse listDashboards(ListDashboardsRequest re *

This method requires the `monitoring.dashboards.get` permission on the specified dashboard. * For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * + *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   GetDashboardRequest request =
+   *       GetDashboardRequest.newBuilder()
+   *           .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
+   *           .build();
+   *   Dashboard response = dashboardsServiceClient.getDashboard(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 */ @@ -243,6 +344,19 @@ public final Dashboard getDashboard(GetDashboardRequest request) { * For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   GetDashboardRequest request =
+   *       GetDashboardRequest.newBuilder()
+   *           .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       dashboardsServiceClient.getDashboardCallable().futureCall(request);
+   *   // Do something.
+   *   Dashboard response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getDashboardCallable() { return stub.getDashboardCallable(); @@ -255,6 +369,18 @@ public final UnaryCallable getDashboardCallable( *

This method requires the `monitoring.dashboards.delete` permission on the specified * dashboard. For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * + *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   DeleteDashboardRequest request =
+   *       DeleteDashboardRequest.newBuilder()
+   *           .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
+   *           .build();
+   *   dashboardsServiceClient.deleteDashboard(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 */ @@ -270,6 +396,19 @@ public final void deleteDashboard(DeleteDashboardRequest request) { * dashboard. For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   DeleteDashboardRequest request =
+   *       DeleteDashboardRequest.newBuilder()
+   *           .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       dashboardsServiceClient.deleteDashboardCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
*/ public final UnaryCallable deleteDashboardCallable() { return stub.deleteDashboardCallable(); @@ -282,6 +421,16 @@ public final UnaryCallable deleteDashboardCallabl *

This method requires the `monitoring.dashboards.update` permission on the specified * dashboard. For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * + *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   UpdateDashboardRequest request =
+   *       UpdateDashboardRequest.newBuilder().setDashboard(Dashboard.newBuilder().build()).build();
+   *   Dashboard response = dashboardsServiceClient.updateDashboard(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 */ @@ -297,6 +446,17 @@ public final Dashboard updateDashboard(UpdateDashboardRequest request) { * dashboard. For more information, see [Google Cloud IAM](https://cloud.google.com/iam). * *

Sample code: + * + *

{@code
+   * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+   *   UpdateDashboardRequest request =
+   *       UpdateDashboardRequest.newBuilder().setDashboard(Dashboard.newBuilder().build()).build();
+   *   ApiFuture future =
+   *       dashboardsServiceClient.updateDashboardCallable().futureCall(request);
+   *   // Do something.
+   *   Dashboard response = future.get();
+   * }
+   * }
*/ public final UnaryCallable updateDashboardCallable() { return stub.updateDashboardCallable(); diff --git a/google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/package-info.java b/google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/package-info.java index a36544cd..abe998cb 100644 --- a/google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/package-info.java +++ b/google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/package-info.java @@ -23,6 +23,17 @@ * display widgets in a specific layout. * *

Sample for DashboardsServiceClient: + * + *

{@code
+ * try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
+ *   CreateDashboardRequest request =
+ *       CreateDashboardRequest.newBuilder()
+ *           .setParent("parent-995424086")
+ *           .setDashboard(Dashboard.newBuilder().build())
+ *           .build();
+ *   Dashboard response = dashboardsServiceClient.createDashboard(request);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.monitoring.dashboard.v1; diff --git a/synth.metadata b/synth.metadata index e56e2368..09488560 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-monitoring-dashboards.git", - "sha": "50c2bfcff3d439211e2e1f44d1903afc487aa5a4" + "sha": "dbdb5dcd94cd94953a768a228b5e4d9a4c840d72" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, {