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

Commit c7d5323

Browse files
docs: generate sample code in the Java microgenerator (#296)
This PR was generated using Autosynth. 🌈 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: googleapis/googleapis@8d8c008
1 parent dbdb5dc commit c7d5323

File tree

3 files changed

+174
-3
lines changed

3 files changed

+174
-3
lines changed

Diff for: google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/DashboardsServiceClient.java

+160
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@
5050
* <p>This class provides the ability to make remote calls to the backing service through method
5151
* calls that map to API methods. Sample code to get started:
5252
*
53+
* <pre>{@code
54+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
55+
* CreateDashboardRequest request =
56+
* CreateDashboardRequest.newBuilder()
57+
* .setParent("parent-995424086")
58+
* .setDashboard(Dashboard.newBuilder().build())
59+
* .build();
60+
* Dashboard response = dashboardsServiceClient.createDashboard(request);
61+
* }
62+
* }</pre>
63+
*
5364
* <p>Note: close() needs to be called on the DashboardsServiceClient object to clean up resources
5465
* such as threads. In the example above, try-with-resources is used, which automatically calls
5566
* close().
@@ -159,6 +170,19 @@ public DashboardsServiceStub getStub() {
159170
* <p>This method requires the `monitoring.dashboards.create` permission on the specified project.
160171
* For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
161172
*
173+
* <p>Sample code:
174+
*
175+
* <pre>{@code
176+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
177+
* CreateDashboardRequest request =
178+
* CreateDashboardRequest.newBuilder()
179+
* .setParent("parent-995424086")
180+
* .setDashboard(Dashboard.newBuilder().build())
181+
* .build();
182+
* Dashboard response = dashboardsServiceClient.createDashboard(request);
183+
* }
184+
* }</pre>
185+
*
162186
* @param request The request object containing all of the parameters for the API call.
163187
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
164188
*/
@@ -174,6 +198,20 @@ public final Dashboard createDashboard(CreateDashboardRequest request) {
174198
* For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
175199
*
176200
* <p>Sample code:
201+
*
202+
* <pre>{@code
203+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
204+
* CreateDashboardRequest request =
205+
* CreateDashboardRequest.newBuilder()
206+
* .setParent("parent-995424086")
207+
* .setDashboard(Dashboard.newBuilder().build())
208+
* .build();
209+
* ApiFuture<Dashboard> future =
210+
* dashboardsServiceClient.createDashboardCallable().futureCall(request);
211+
* // Do something.
212+
* Dashboard response = future.get();
213+
* }
214+
* }</pre>
177215
*/
178216
public final UnaryCallable<CreateDashboardRequest, Dashboard> createDashboardCallable() {
179217
return stub.createDashboardCallable();
@@ -186,6 +224,22 @@ public final UnaryCallable<CreateDashboardRequest, Dashboard> createDashboardCal
186224
* <p>This method requires the `monitoring.dashboards.list` permission on the specified project.
187225
* For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
188226
*
227+
* <p>Sample code:
228+
*
229+
* <pre>{@code
230+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
231+
* ListDashboardsRequest request =
232+
* ListDashboardsRequest.newBuilder()
233+
* .setParent(ProjectName.of("[PROJECT]").toString())
234+
* .setPageSize(883849137)
235+
* .setPageToken("pageToken873572522")
236+
* .build();
237+
* for (Dashboard element : dashboardsServiceClient.listDashboards(request).iterateAll()) {
238+
* // doThingsWith(element);
239+
* }
240+
* }
241+
* }</pre>
242+
*
189243
* @param request The request object containing all of the parameters for the API call.
190244
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
191245
*/
@@ -201,6 +255,23 @@ public final ListDashboardsPagedResponse listDashboards(ListDashboardsRequest re
201255
* For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
202256
*
203257
* <p>Sample code:
258+
*
259+
* <pre>{@code
260+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
261+
* ListDashboardsRequest request =
262+
* ListDashboardsRequest.newBuilder()
263+
* .setParent(ProjectName.of("[PROJECT]").toString())
264+
* .setPageSize(883849137)
265+
* .setPageToken("pageToken873572522")
266+
* .build();
267+
* ApiFuture<Dashboard> future =
268+
* dashboardsServiceClient.listDashboardsPagedCallable().futureCall(request);
269+
* // Do something.
270+
* for (Dashboard element : future.get().iterateAll()) {
271+
* // doThingsWith(element);
272+
* }
273+
* }
274+
* }</pre>
204275
*/
205276
public final UnaryCallable<ListDashboardsRequest, ListDashboardsPagedResponse>
206277
listDashboardsPagedCallable() {
@@ -215,6 +286,24 @@ public final ListDashboardsPagedResponse listDashboards(ListDashboardsRequest re
215286
* For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
216287
*
217288
* <p>Sample code:
289+
*
290+
* <pre>{@code
291+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
292+
* while (true) {
293+
* ListDashboardsResponse response =
294+
* dashboardsServiceClient.listDashboardsCallable().call(request);
295+
* for (Dashboard element : response.getResponsesList()) {
296+
* // doThingsWith(element);
297+
* }
298+
* String nextPageToken = response.getNextPageToken();
299+
* if (!Strings.isNullOrEmpty(nextPageToken)) {
300+
* request = request.toBuilder().setPageToken(nextPageToken).build();
301+
* } else {
302+
* break;
303+
* }
304+
* }
305+
* }
306+
* }</pre>
218307
*/
219308
public final UnaryCallable<ListDashboardsRequest, ListDashboardsResponse>
220309
listDashboardsCallable() {
@@ -228,6 +317,18 @@ public final ListDashboardsPagedResponse listDashboards(ListDashboardsRequest re
228317
* <p>This method requires the `monitoring.dashboards.get` permission on the specified dashboard.
229318
* For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
230319
*
320+
* <p>Sample code:
321+
*
322+
* <pre>{@code
323+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
324+
* GetDashboardRequest request =
325+
* GetDashboardRequest.newBuilder()
326+
* .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
327+
* .build();
328+
* Dashboard response = dashboardsServiceClient.getDashboard(request);
329+
* }
330+
* }</pre>
331+
*
231332
* @param request The request object containing all of the parameters for the API call.
232333
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
233334
*/
@@ -243,6 +344,19 @@ public final Dashboard getDashboard(GetDashboardRequest request) {
243344
* For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
244345
*
245346
* <p>Sample code:
347+
*
348+
* <pre>{@code
349+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
350+
* GetDashboardRequest request =
351+
* GetDashboardRequest.newBuilder()
352+
* .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
353+
* .build();
354+
* ApiFuture<Dashboard> future =
355+
* dashboardsServiceClient.getDashboardCallable().futureCall(request);
356+
* // Do something.
357+
* Dashboard response = future.get();
358+
* }
359+
* }</pre>
246360
*/
247361
public final UnaryCallable<GetDashboardRequest, Dashboard> getDashboardCallable() {
248362
return stub.getDashboardCallable();
@@ -255,6 +369,18 @@ public final UnaryCallable<GetDashboardRequest, Dashboard> getDashboardCallable(
255369
* <p>This method requires the `monitoring.dashboards.delete` permission on the specified
256370
* dashboard. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
257371
*
372+
* <p>Sample code:
373+
*
374+
* <pre>{@code
375+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
376+
* DeleteDashboardRequest request =
377+
* DeleteDashboardRequest.newBuilder()
378+
* .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
379+
* .build();
380+
* dashboardsServiceClient.deleteDashboard(request);
381+
* }
382+
* }</pre>
383+
*
258384
* @param request The request object containing all of the parameters for the API call.
259385
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
260386
*/
@@ -270,6 +396,19 @@ public final void deleteDashboard(DeleteDashboardRequest request) {
270396
* dashboard. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
271397
*
272398
* <p>Sample code:
399+
*
400+
* <pre>{@code
401+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
402+
* DeleteDashboardRequest request =
403+
* DeleteDashboardRequest.newBuilder()
404+
* .setName(DashboardName.of("[PROJECT]", "[DASHBOARD]").toString())
405+
* .build();
406+
* ApiFuture<Empty> future =
407+
* dashboardsServiceClient.deleteDashboardCallable().futureCall(request);
408+
* // Do something.
409+
* future.get();
410+
* }
411+
* }</pre>
273412
*/
274413
public final UnaryCallable<DeleteDashboardRequest, Empty> deleteDashboardCallable() {
275414
return stub.deleteDashboardCallable();
@@ -282,6 +421,16 @@ public final UnaryCallable<DeleteDashboardRequest, Empty> deleteDashboardCallabl
282421
* <p>This method requires the `monitoring.dashboards.update` permission on the specified
283422
* dashboard. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
284423
*
424+
* <p>Sample code:
425+
*
426+
* <pre>{@code
427+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
428+
* UpdateDashboardRequest request =
429+
* UpdateDashboardRequest.newBuilder().setDashboard(Dashboard.newBuilder().build()).build();
430+
* Dashboard response = dashboardsServiceClient.updateDashboard(request);
431+
* }
432+
* }</pre>
433+
*
285434
* @param request The request object containing all of the parameters for the API call.
286435
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
287436
*/
@@ -297,6 +446,17 @@ public final Dashboard updateDashboard(UpdateDashboardRequest request) {
297446
* dashboard. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).
298447
*
299448
* <p>Sample code:
449+
*
450+
* <pre>{@code
451+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
452+
* UpdateDashboardRequest request =
453+
* UpdateDashboardRequest.newBuilder().setDashboard(Dashboard.newBuilder().build()).build();
454+
* ApiFuture<Dashboard> future =
455+
* dashboardsServiceClient.updateDashboardCallable().futureCall(request);
456+
* // Do something.
457+
* Dashboard response = future.get();
458+
* }
459+
* }</pre>
300460
*/
301461
public final UnaryCallable<UpdateDashboardRequest, Dashboard> updateDashboardCallable() {
302462
return stub.updateDashboardCallable();

Diff for: google-cloud-monitoring-dashboard/src/main/java/com/google/cloud/monitoring/dashboard/v1/package-info.java

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
* display widgets in a specific layout.
2424
*
2525
* <p>Sample for DashboardsServiceClient:
26+
*
27+
* <pre>{@code
28+
* try (DashboardsServiceClient dashboardsServiceClient = DashboardsServiceClient.create()) {
29+
* CreateDashboardRequest request =
30+
* CreateDashboardRequest.newBuilder()
31+
* .setParent("parent-995424086")
32+
* .setDashboard(Dashboard.newBuilder().build())
33+
* .build();
34+
* Dashboard response = dashboardsServiceClient.createDashboard(request);
35+
* }
36+
* }</pre>
2637
*/
2738
@Generated("by gapic-generator-java")
2839
package com.google.cloud.monitoring.dashboard.v1;

Diff for: synth.metadata

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/java-monitoring-dashboards.git",
7-
"sha": "50c2bfcff3d439211e2e1f44d1903afc487aa5a4"
7+
"sha": "dbdb5dcd94cd94953a768a228b5e4d9a4c840d72"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3",
15-
"internalRef": "350949863"
14+
"sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb",
15+
"internalRef": "356341083"
1616
}
1717
},
1818
{

0 commit comments

Comments
 (0)