Debian Codegraph @

metastore/apiv1/dataproc_metastore_client_example_test.go

raw
1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package metastore_test
18
19 import (
20 "context"
21
22 iampb "cloud.google.com/go/iam/apiv1/iampb"
23 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
24 metastore "cloud.google.com/go/metastore/apiv1"
25 metastorepb "cloud.google.com/go/metastore/apiv1/metastorepb"
26 "google.golang.org/api/iterator"
27 locationpb "google.golang.org/genproto/googleapis/cloud/location"
28 )
29
30 func ExampleNewDataprocMetastoreClient() {
31 ctx := context.Background()
32 // This snippet has been automatically generated and should be regarded as a code template only.
33 // It will require modifications to work:
34 // - It may require correct/in-range values for request initialization.
35 // - It may require specifying regional endpoints when creating the service client as shown in:
36 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
37 c, err := metastore.NewDataprocMetastoreClient(ctx)
38 if err != nil {
39 // TODO: Handle error.
40 }
41 defer c.Close()
42
43 // TODO: Use client.
44 _ = c
45 }
46
47 func ExampleNewDataprocMetastoreRESTClient() {
48 ctx := context.Background()
49 // This snippet has been automatically generated and should be regarded as a code template only.
50 // It will require modifications to work:
51 // - It may require correct/in-range values for request initialization.
52 // - It may require specifying regional endpoints when creating the service client as shown in:
53 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
54 c, err := metastore.NewDataprocMetastoreRESTClient(ctx)
55 if err != nil {
56 // TODO: Handle error.
57 }
58 defer c.Close()
59
60 // TODO: Use client.
61 _ = c
62 }
63
64 func ExampleDataprocMetastoreClient_AlterMetadataResourceLocation() {
65 ctx := context.Background()
66 // This snippet has been automatically generated and should be regarded as a code template only.
67 // It will require modifications to work:
68 // - It may require correct/in-range values for request initialization.
69 // - It may require specifying regional endpoints when creating the service client as shown in:
70 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
71 c, err := metastore.NewDataprocMetastoreClient(ctx)
72 if err != nil {
73 // TODO: Handle error.
74 }
75 defer c.Close()
76
77 req := &metastorepb.AlterMetadataResourceLocationRequest{
78 // TODO: Fill request struct fields.
79 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#AlterMetadataResourceLocationRequest.
80 }
81 op, err := c.AlterMetadataResourceLocation(ctx, req)
82 if err != nil {
83 // TODO: Handle error.
84 }
85
86 resp, err := op.Wait(ctx)
87 if err != nil {
88 // TODO: Handle error.
89 }
90 // TODO: Use resp.
91 _ = resp
92 }
93
94 func ExampleDataprocMetastoreClient_CreateBackup() {
95 ctx := context.Background()
96 // This snippet has been automatically generated and should be regarded as a code template only.
97 // It will require modifications to work:
98 // - It may require correct/in-range values for request initialization.
99 // - It may require specifying regional endpoints when creating the service client as shown in:
100 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
101 c, err := metastore.NewDataprocMetastoreClient(ctx)
102 if err != nil {
103 // TODO: Handle error.
104 }
105 defer c.Close()
106
107 req := &metastorepb.CreateBackupRequest{
108 // TODO: Fill request struct fields.
109 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#CreateBackupRequest.
110 }
111 op, err := c.CreateBackup(ctx, req)
112 if err != nil {
113 // TODO: Handle error.
114 }
115
116 resp, err := op.Wait(ctx)
117 if err != nil {
118 // TODO: Handle error.
119 }
120 // TODO: Use resp.
121 _ = resp
122 }
123
124 func ExampleDataprocMetastoreClient_CreateMetadataImport() {
125 ctx := context.Background()
126 // This snippet has been automatically generated and should be regarded as a code template only.
127 // It will require modifications to work:
128 // - It may require correct/in-range values for request initialization.
129 // - It may require specifying regional endpoints when creating the service client as shown in:
130 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
131 c, err := metastore.NewDataprocMetastoreClient(ctx)
132 if err != nil {
133 // TODO: Handle error.
134 }
135 defer c.Close()
136
137 req := &metastorepb.CreateMetadataImportRequest{
138 // TODO: Fill request struct fields.
139 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#CreateMetadataImportRequest.
140 }
141 op, err := c.CreateMetadataImport(ctx, req)
142 if err != nil {
143 // TODO: Handle error.
144 }
145
146 resp, err := op.Wait(ctx)
147 if err != nil {
148 // TODO: Handle error.
149 }
150 // TODO: Use resp.
151 _ = resp
152 }
153
154 func ExampleDataprocMetastoreClient_CreateService() {
155 ctx := context.Background()
156 // This snippet has been automatically generated and should be regarded as a code template only.
157 // It will require modifications to work:
158 // - It may require correct/in-range values for request initialization.
159 // - It may require specifying regional endpoints when creating the service client as shown in:
160 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
161 c, err := metastore.NewDataprocMetastoreClient(ctx)
162 if err != nil {
163 // TODO: Handle error.
164 }
165 defer c.Close()
166
167 req := &metastorepb.CreateServiceRequest{
168 // TODO: Fill request struct fields.
169 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#CreateServiceRequest.
170 }
171 op, err := c.CreateService(ctx, req)
172 if err != nil {
173 // TODO: Handle error.
174 }
175
176 resp, err := op.Wait(ctx)
177 if err != nil {
178 // TODO: Handle error.
179 }
180 // TODO: Use resp.
181 _ = resp
182 }
183
184 func ExampleDataprocMetastoreClient_DeleteBackup() {
185 ctx := context.Background()
186 // This snippet has been automatically generated and should be regarded as a code template only.
187 // It will require modifications to work:
188 // - It may require correct/in-range values for request initialization.
189 // - It may require specifying regional endpoints when creating the service client as shown in:
190 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
191 c, err := metastore.NewDataprocMetastoreClient(ctx)
192 if err != nil {
193 // TODO: Handle error.
194 }
195 defer c.Close()
196
197 req := &metastorepb.DeleteBackupRequest{
198 // TODO: Fill request struct fields.
199 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#DeleteBackupRequest.
200 }
201 op, err := c.DeleteBackup(ctx, req)
202 if err != nil {
203 // TODO: Handle error.
204 }
205
206 err = op.Wait(ctx)
207 if err != nil {
208 // TODO: Handle error.
209 }
210 }
211
212 func ExampleDataprocMetastoreClient_DeleteService() {
213 ctx := context.Background()
214 // This snippet has been automatically generated and should be regarded as a code template only.
215 // It will require modifications to work:
216 // - It may require correct/in-range values for request initialization.
217 // - It may require specifying regional endpoints when creating the service client as shown in:
218 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
219 c, err := metastore.NewDataprocMetastoreClient(ctx)
220 if err != nil {
221 // TODO: Handle error.
222 }
223 defer c.Close()
224
225 req := &metastorepb.DeleteServiceRequest{
226 // TODO: Fill request struct fields.
227 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#DeleteServiceRequest.
228 }
229 op, err := c.DeleteService(ctx, req)
230 if err != nil {
231 // TODO: Handle error.
232 }
233
234 err = op.Wait(ctx)
235 if err != nil {
236 // TODO: Handle error.
237 }
238 }
239
240 func ExampleDataprocMetastoreClient_ExportMetadata() {
241 ctx := context.Background()
242 // This snippet has been automatically generated and should be regarded as a code template only.
243 // It will require modifications to work:
244 // - It may require correct/in-range values for request initialization.
245 // - It may require specifying regional endpoints when creating the service client as shown in:
246 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
247 c, err := metastore.NewDataprocMetastoreClient(ctx)
248 if err != nil {
249 // TODO: Handle error.
250 }
251 defer c.Close()
252
253 req := &metastorepb.ExportMetadataRequest{
254 // TODO: Fill request struct fields.
255 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#ExportMetadataRequest.
256 }
257 op, err := c.ExportMetadata(ctx, req)
258 if err != nil {
259 // TODO: Handle error.
260 }
261
262 resp, err := op.Wait(ctx)
263 if err != nil {
264 // TODO: Handle error.
265 }
266 // TODO: Use resp.
267 _ = resp
268 }
269
270 func ExampleDataprocMetastoreClient_GetBackup() {
271 ctx := context.Background()
272 // This snippet has been automatically generated and should be regarded as a code template only.
273 // It will require modifications to work:
274 // - It may require correct/in-range values for request initialization.
275 // - It may require specifying regional endpoints when creating the service client as shown in:
276 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
277 c, err := metastore.NewDataprocMetastoreClient(ctx)
278 if err != nil {
279 // TODO: Handle error.
280 }
281 defer c.Close()
282
283 req := &metastorepb.GetBackupRequest{
284 // TODO: Fill request struct fields.
285 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#GetBackupRequest.
286 }
287 resp, err := c.GetBackup(ctx, req)
288 if err != nil {
289 // TODO: Handle error.
290 }
291 // TODO: Use resp.
292 _ = resp
293 }
294
295 func ExampleDataprocMetastoreClient_GetMetadataImport() {
296 ctx := context.Background()
297 // This snippet has been automatically generated and should be regarded as a code template only.
298 // It will require modifications to work:
299 // - It may require correct/in-range values for request initialization.
300 // - It may require specifying regional endpoints when creating the service client as shown in:
301 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
302 c, err := metastore.NewDataprocMetastoreClient(ctx)
303 if err != nil {
304 // TODO: Handle error.
305 }
306 defer c.Close()
307
308 req := &metastorepb.GetMetadataImportRequest{
309 // TODO: Fill request struct fields.
310 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#GetMetadataImportRequest.
311 }
312 resp, err := c.GetMetadataImport(ctx, req)
313 if err != nil {
314 // TODO: Handle error.
315 }
316 // TODO: Use resp.
317 _ = resp
318 }
319
320 func ExampleDataprocMetastoreClient_GetService() {
321 ctx := context.Background()
322 // This snippet has been automatically generated and should be regarded as a code template only.
323 // It will require modifications to work:
324 // - It may require correct/in-range values for request initialization.
325 // - It may require specifying regional endpoints when creating the service client as shown in:
326 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
327 c, err := metastore.NewDataprocMetastoreClient(ctx)
328 if err != nil {
329 // TODO: Handle error.
330 }
331 defer c.Close()
332
333 req := &metastorepb.GetServiceRequest{
334 // TODO: Fill request struct fields.
335 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#GetServiceRequest.
336 }
337 resp, err := c.GetService(ctx, req)
338 if err != nil {
339 // TODO: Handle error.
340 }
341 // TODO: Use resp.
342 _ = resp
343 }
344
345 func ExampleDataprocMetastoreClient_ListBackups() {
346 ctx := context.Background()
347 // This snippet has been automatically generated and should be regarded as a code template only.
348 // It will require modifications to work:
349 // - It may require correct/in-range values for request initialization.
350 // - It may require specifying regional endpoints when creating the service client as shown in:
351 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
352 c, err := metastore.NewDataprocMetastoreClient(ctx)
353 if err != nil {
354 // TODO: Handle error.
355 }
356 defer c.Close()
357
358 req := &metastorepb.ListBackupsRequest{
359 // TODO: Fill request struct fields.
360 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#ListBackupsRequest.
361 }
362 it := c.ListBackups(ctx, req)
363 for {
364 resp, err := it.Next()
365 if err == iterator.Done {
366 break
367 }
368 if err != nil {
369 // TODO: Handle error.
370 }
371 // TODO: Use resp.
372 _ = resp
373
374 // If you need to access the underlying RPC response,
375 // you can do so by casting the `Response` as below.
376 // Otherwise, remove this line. Only populated after
377 // first call to Next(). Not safe for concurrent access.
378 _ = it.Response.(*metastorepb.ListBackupsResponse)
379 }
380 }
381
382 func ExampleDataprocMetastoreClient_ListMetadataImports() {
383 ctx := context.Background()
384 // This snippet has been automatically generated and should be regarded as a code template only.
385 // It will require modifications to work:
386 // - It may require correct/in-range values for request initialization.
387 // - It may require specifying regional endpoints when creating the service client as shown in:
388 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
389 c, err := metastore.NewDataprocMetastoreClient(ctx)
390 if err != nil {
391 // TODO: Handle error.
392 }
393 defer c.Close()
394
395 req := &metastorepb.ListMetadataImportsRequest{
396 // TODO: Fill request struct fields.
397 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#ListMetadataImportsRequest.
398 }
399 it := c.ListMetadataImports(ctx, req)
400 for {
401 resp, err := it.Next()
402 if err == iterator.Done {
403 break
404 }
405 if err != nil {
406 // TODO: Handle error.
407 }
408 // TODO: Use resp.
409 _ = resp
410
411 // If you need to access the underlying RPC response,
412 // you can do so by casting the `Response` as below.
413 // Otherwise, remove this line. Only populated after
414 // first call to Next(). Not safe for concurrent access.
415 _ = it.Response.(*metastorepb.ListMetadataImportsResponse)
416 }
417 }
418
419 func ExampleDataprocMetastoreClient_ListServices() {
420 ctx := context.Background()
421 // This snippet has been automatically generated and should be regarded as a code template only.
422 // It will require modifications to work:
423 // - It may require correct/in-range values for request initialization.
424 // - It may require specifying regional endpoints when creating the service client as shown in:
425 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
426 c, err := metastore.NewDataprocMetastoreClient(ctx)
427 if err != nil {
428 // TODO: Handle error.
429 }
430 defer c.Close()
431
432 req := &metastorepb.ListServicesRequest{
433 // TODO: Fill request struct fields.
434 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#ListServicesRequest.
435 }
436 it := c.ListServices(ctx, req)
437 for {
438 resp, err := it.Next()
439 if err == iterator.Done {
440 break
441 }
442 if err != nil {
443 // TODO: Handle error.
444 }
445 // TODO: Use resp.
446 _ = resp
447
448 // If you need to access the underlying RPC response,
449 // you can do so by casting the `Response` as below.
450 // Otherwise, remove this line. Only populated after
451 // first call to Next(). Not safe for concurrent access.
452 _ = it.Response.(*metastorepb.ListServicesResponse)
453 }
454 }
455
456 func ExampleDataprocMetastoreClient_MoveTableToDatabase() {
457 ctx := context.Background()
458 // This snippet has been automatically generated and should be regarded as a code template only.
459 // It will require modifications to work:
460 // - It may require correct/in-range values for request initialization.
461 // - It may require specifying regional endpoints when creating the service client as shown in:
462 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
463 c, err := metastore.NewDataprocMetastoreClient(ctx)
464 if err != nil {
465 // TODO: Handle error.
466 }
467 defer c.Close()
468
469 req := &metastorepb.MoveTableToDatabaseRequest{
470 // TODO: Fill request struct fields.
471 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#MoveTableToDatabaseRequest.
472 }
473 op, err := c.MoveTableToDatabase(ctx, req)
474 if err != nil {
475 // TODO: Handle error.
476 }
477
478 resp, err := op.Wait(ctx)
479 if err != nil {
480 // TODO: Handle error.
481 }
482 // TODO: Use resp.
483 _ = resp
484 }
485
486 func ExampleDataprocMetastoreClient_QueryMetadata() {
487 ctx := context.Background()
488 // This snippet has been automatically generated and should be regarded as a code template only.
489 // It will require modifications to work:
490 // - It may require correct/in-range values for request initialization.
491 // - It may require specifying regional endpoints when creating the service client as shown in:
492 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
493 c, err := metastore.NewDataprocMetastoreClient(ctx)
494 if err != nil {
495 // TODO: Handle error.
496 }
497 defer c.Close()
498
499 req := &metastorepb.QueryMetadataRequest{
500 // TODO: Fill request struct fields.
501 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#QueryMetadataRequest.
502 }
503 op, err := c.QueryMetadata(ctx, req)
504 if err != nil {
505 // TODO: Handle error.
506 }
507
508 resp, err := op.Wait(ctx)
509 if err != nil {
510 // TODO: Handle error.
511 }
512 // TODO: Use resp.
513 _ = resp
514 }
515
516 func ExampleDataprocMetastoreClient_RestoreService() {
517 ctx := context.Background()
518 // This snippet has been automatically generated and should be regarded as a code template only.
519 // It will require modifications to work:
520 // - It may require correct/in-range values for request initialization.
521 // - It may require specifying regional endpoints when creating the service client as shown in:
522 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
523 c, err := metastore.NewDataprocMetastoreClient(ctx)
524 if err != nil {
525 // TODO: Handle error.
526 }
527 defer c.Close()
528
529 req := &metastorepb.RestoreServiceRequest{
530 // TODO: Fill request struct fields.
531 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#RestoreServiceRequest.
532 }
533 op, err := c.RestoreService(ctx, req)
534 if err != nil {
535 // TODO: Handle error.
536 }
537
538 resp, err := op.Wait(ctx)
539 if err != nil {
540 // TODO: Handle error.
541 }
542 // TODO: Use resp.
543 _ = resp
544 }
545
546 func ExampleDataprocMetastoreClient_UpdateMetadataImport() {
547 ctx := context.Background()
548 // This snippet has been automatically generated and should be regarded as a code template only.
549 // It will require modifications to work:
550 // - It may require correct/in-range values for request initialization.
551 // - It may require specifying regional endpoints when creating the service client as shown in:
552 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
553 c, err := metastore.NewDataprocMetastoreClient(ctx)
554 if err != nil {
555 // TODO: Handle error.
556 }
557 defer c.Close()
558
559 req := &metastorepb.UpdateMetadataImportRequest{
560 // TODO: Fill request struct fields.
561 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#UpdateMetadataImportRequest.
562 }
563 op, err := c.UpdateMetadataImport(ctx, req)
564 if err != nil {
565 // TODO: Handle error.
566 }
567
568 resp, err := op.Wait(ctx)
569 if err != nil {
570 // TODO: Handle error.
571 }
572 // TODO: Use resp.
573 _ = resp
574 }
575
576 func ExampleDataprocMetastoreClient_UpdateService() {
577 ctx := context.Background()
578 // This snippet has been automatically generated and should be regarded as a code template only.
579 // It will require modifications to work:
580 // - It may require correct/in-range values for request initialization.
581 // - It may require specifying regional endpoints when creating the service client as shown in:
582 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
583 c, err := metastore.NewDataprocMetastoreClient(ctx)
584 if err != nil {
585 // TODO: Handle error.
586 }
587 defer c.Close()
588
589 req := &metastorepb.UpdateServiceRequest{
590 // TODO: Fill request struct fields.
591 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1/metastorepb#UpdateServiceRequest.
592 }
593 op, err := c.UpdateService(ctx, req)
594 if err != nil {
595 // TODO: Handle error.
596 }
597
598 resp, err := op.Wait(ctx)
599 if err != nil {
600 // TODO: Handle error.
601 }
602 // TODO: Use resp.
603 _ = resp
604 }
605
606 func ExampleDataprocMetastoreClient_GetLocation() {
607 ctx := context.Background()
608 // This snippet has been automatically generated and should be regarded as a code template only.
609 // It will require modifications to work:
610 // - It may require correct/in-range values for request initialization.
611 // - It may require specifying regional endpoints when creating the service client as shown in:
612 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
613 c, err := metastore.NewDataprocMetastoreClient(ctx)
614 if err != nil {
615 // TODO: Handle error.
616 }
617 defer c.Close()
618
619 req := &locationpb.GetLocationRequest{
620 // TODO: Fill request struct fields.
621 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
622 }
623 resp, err := c.GetLocation(ctx, req)
624 if err != nil {
625 // TODO: Handle error.
626 }
627 // TODO: Use resp.
628 _ = resp
629 }
630
631 func ExampleDataprocMetastoreClient_ListLocations() {
632 ctx := context.Background()
633 // This snippet has been automatically generated and should be regarded as a code template only.
634 // It will require modifications to work:
635 // - It may require correct/in-range values for request initialization.
636 // - It may require specifying regional endpoints when creating the service client as shown in:
637 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
638 c, err := metastore.NewDataprocMetastoreClient(ctx)
639 if err != nil {
640 // TODO: Handle error.
641 }
642 defer c.Close()
643
644 req := &locationpb.ListLocationsRequest{
645 // TODO: Fill request struct fields.
646 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
647 }
648 it := c.ListLocations(ctx, req)
649 for {
650 resp, err := it.Next()
651 if err == iterator.Done {
652 break
653 }
654 if err != nil {
655 // TODO: Handle error.
656 }
657 // TODO: Use resp.
658 _ = resp
659
660 // If you need to access the underlying RPC response,
661 // you can do so by casting the `Response` as below.
662 // Otherwise, remove this line. Only populated after
663 // first call to Next(). Not safe for concurrent access.
664 _ = it.Response.(*locationpb.ListLocationsResponse)
665 }
666 }
667
668 func ExampleDataprocMetastoreClient_GetIamPolicy() {
669 ctx := context.Background()
670 // This snippet has been automatically generated and should be regarded as a code template only.
671 // It will require modifications to work:
672 // - It may require correct/in-range values for request initialization.
673 // - It may require specifying regional endpoints when creating the service client as shown in:
674 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
675 c, err := metastore.NewDataprocMetastoreClient(ctx)
676 if err != nil {
677 // TODO: Handle error.
678 }
679 defer c.Close()
680
681 req := &iampb.GetIamPolicyRequest{
682 // TODO: Fill request struct fields.
683 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
684 }
685 resp, err := c.GetIamPolicy(ctx, req)
686 if err != nil {
687 // TODO: Handle error.
688 }
689 // TODO: Use resp.
690 _ = resp
691 }
692
693 func ExampleDataprocMetastoreClient_SetIamPolicy() {
694 ctx := context.Background()
695 // This snippet has been automatically generated and should be regarded as a code template only.
696 // It will require modifications to work:
697 // - It may require correct/in-range values for request initialization.
698 // - It may require specifying regional endpoints when creating the service client as shown in:
699 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
700 c, err := metastore.NewDataprocMetastoreClient(ctx)
701 if err != nil {
702 // TODO: Handle error.
703 }
704 defer c.Close()
705
706 req := &iampb.SetIamPolicyRequest{
707 // TODO: Fill request struct fields.
708 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
709 }
710 resp, err := c.SetIamPolicy(ctx, req)
711 if err != nil {
712 // TODO: Handle error.
713 }
714 // TODO: Use resp.
715 _ = resp
716 }
717
718 func ExampleDataprocMetastoreClient_TestIamPermissions() {
719 ctx := context.Background()
720 // This snippet has been automatically generated and should be regarded as a code template only.
721 // It will require modifications to work:
722 // - It may require correct/in-range values for request initialization.
723 // - It may require specifying regional endpoints when creating the service client as shown in:
724 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
725 c, err := metastore.NewDataprocMetastoreClient(ctx)
726 if err != nil {
727 // TODO: Handle error.
728 }
729 defer c.Close()
730
731 req := &iampb.TestIamPermissionsRequest{
732 // TODO: Fill request struct fields.
733 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
734 }
735 resp, err := c.TestIamPermissions(ctx, req)
736 if err != nil {
737 // TODO: Handle error.
738 }
739 // TODO: Use resp.
740 _ = resp
741 }
742
743 func ExampleDataprocMetastoreClient_CancelOperation() {
744 ctx := context.Background()
745 // This snippet has been automatically generated and should be regarded as a code template only.
746 // It will require modifications to work:
747 // - It may require correct/in-range values for request initialization.
748 // - It may require specifying regional endpoints when creating the service client as shown in:
749 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
750 c, err := metastore.NewDataprocMetastoreClient(ctx)
751 if err != nil {
752 // TODO: Handle error.
753 }
754 defer c.Close()
755
756 req := &longrunningpb.CancelOperationRequest{
757 // TODO: Fill request struct fields.
758 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
759 }
760 err = c.CancelOperation(ctx, req)
761 if err != nil {
762 // TODO: Handle error.
763 }
764 }
765
766 func ExampleDataprocMetastoreClient_DeleteOperation() {
767 ctx := context.Background()
768 // This snippet has been automatically generated and should be regarded as a code template only.
769 // It will require modifications to work:
770 // - It may require correct/in-range values for request initialization.
771 // - It may require specifying regional endpoints when creating the service client as shown in:
772 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
773 c, err := metastore.NewDataprocMetastoreClient(ctx)
774 if err != nil {
775 // TODO: Handle error.
776 }
777 defer c.Close()
778
779 req := &longrunningpb.DeleteOperationRequest{
780 // TODO: Fill request struct fields.
781 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
782 }
783 err = c.DeleteOperation(ctx, req)
784 if err != nil {
785 // TODO: Handle error.
786 }
787 }
788
789 func ExampleDataprocMetastoreClient_GetOperation() {
790 ctx := context.Background()
791 // This snippet has been automatically generated and should be regarded as a code template only.
792 // It will require modifications to work:
793 // - It may require correct/in-range values for request initialization.
794 // - It may require specifying regional endpoints when creating the service client as shown in:
795 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
796 c, err := metastore.NewDataprocMetastoreClient(ctx)
797 if err != nil {
798 // TODO: Handle error.
799 }
800 defer c.Close()
801
802 req := &longrunningpb.GetOperationRequest{
803 // TODO: Fill request struct fields.
804 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
805 }
806 resp, err := c.GetOperation(ctx, req)
807 if err != nil {
808 // TODO: Handle error.
809 }
810 // TODO: Use resp.
811 _ = resp
812 }
813
814 func ExampleDataprocMetastoreClient_ListOperations() {
815 ctx := context.Background()
816 // This snippet has been automatically generated and should be regarded as a code template only.
817 // It will require modifications to work:
818 // - It may require correct/in-range values for request initialization.
819 // - It may require specifying regional endpoints when creating the service client as shown in:
820 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
821 c, err := metastore.NewDataprocMetastoreClient(ctx)
822 if err != nil {
823 // TODO: Handle error.
824 }
825 defer c.Close()
826
827 req := &longrunningpb.ListOperationsRequest{
828 // TODO: Fill request struct fields.
829 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
830 }
831 it := c.ListOperations(ctx, req)
832 for {
833 resp, err := it.Next()
834 if err == iterator.Done {
835 break
836 }
837 if err != nil {
838 // TODO: Handle error.
839 }
840 // TODO: Use resp.
841 _ = resp
842
843 // If you need to access the underlying RPC response,
844 // you can do so by casting the `Response` as below.
845 // Otherwise, remove this line. Only populated after
846 // first call to Next(). Not safe for concurrent access.
847 _ = it.Response.(*longrunningpb.ListOperationsResponse)
848 }
849 }