Debian Codegraph @

metastore/apiv1beta/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/apiv1beta"
25 metastorepb "cloud.google.com/go/metastore/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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/apiv1beta/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_RemoveIamPolicy() {
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.RemoveIamPolicyRequest{
530 // TODO: Fill request struct fields.
531 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1beta/metastorepb#RemoveIamPolicyRequest.
532 }
533 resp, err := c.RemoveIamPolicy(ctx, req)
534 if err != nil {
535 // TODO: Handle error.
536 }
537 // TODO: Use resp.
538 _ = resp
539 }
540
541 func ExampleDataprocMetastoreClient_RestoreService() {
542 ctx := context.Background()
543 // This snippet has been automatically generated and should be regarded as a code template only.
544 // It will require modifications to work:
545 // - It may require correct/in-range values for request initialization.
546 // - It may require specifying regional endpoints when creating the service client as shown in:
547 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
548 c, err := metastore.NewDataprocMetastoreClient(ctx)
549 if err != nil {
550 // TODO: Handle error.
551 }
552 defer c.Close()
553
554 req := &metastorepb.RestoreServiceRequest{
555 // TODO: Fill request struct fields.
556 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1beta/metastorepb#RestoreServiceRequest.
557 }
558 op, err := c.RestoreService(ctx, req)
559 if err != nil {
560 // TODO: Handle error.
561 }
562
563 resp, err := op.Wait(ctx)
564 if err != nil {
565 // TODO: Handle error.
566 }
567 // TODO: Use resp.
568 _ = resp
569 }
570
571 func ExampleDataprocMetastoreClient_UpdateMetadataImport() {
572 ctx := context.Background()
573 // This snippet has been automatically generated and should be regarded as a code template only.
574 // It will require modifications to work:
575 // - It may require correct/in-range values for request initialization.
576 // - It may require specifying regional endpoints when creating the service client as shown in:
577 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
578 c, err := metastore.NewDataprocMetastoreClient(ctx)
579 if err != nil {
580 // TODO: Handle error.
581 }
582 defer c.Close()
583
584 req := &metastorepb.UpdateMetadataImportRequest{
585 // TODO: Fill request struct fields.
586 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1beta/metastorepb#UpdateMetadataImportRequest.
587 }
588 op, err := c.UpdateMetadataImport(ctx, req)
589 if err != nil {
590 // TODO: Handle error.
591 }
592
593 resp, err := op.Wait(ctx)
594 if err != nil {
595 // TODO: Handle error.
596 }
597 // TODO: Use resp.
598 _ = resp
599 }
600
601 func ExampleDataprocMetastoreClient_UpdateService() {
602 ctx := context.Background()
603 // This snippet has been automatically generated and should be regarded as a code template only.
604 // It will require modifications to work:
605 // - It may require correct/in-range values for request initialization.
606 // - It may require specifying regional endpoints when creating the service client as shown in:
607 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
608 c, err := metastore.NewDataprocMetastoreClient(ctx)
609 if err != nil {
610 // TODO: Handle error.
611 }
612 defer c.Close()
613
614 req := &metastorepb.UpdateServiceRequest{
615 // TODO: Fill request struct fields.
616 // See https://pkg.go.dev/cloud.google.com/go/metastore/apiv1beta/metastorepb#UpdateServiceRequest.
617 }
618 op, err := c.UpdateService(ctx, req)
619 if err != nil {
620 // TODO: Handle error.
621 }
622
623 resp, err := op.Wait(ctx)
624 if err != nil {
625 // TODO: Handle error.
626 }
627 // TODO: Use resp.
628 _ = resp
629 }
630
631 func ExampleDataprocMetastoreClient_GetLocation() {
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.GetLocationRequest{
645 // TODO: Fill request struct fields.
646 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
647 }
648 resp, err := c.GetLocation(ctx, req)
649 if err != nil {
650 // TODO: Handle error.
651 }
652 // TODO: Use resp.
653 _ = resp
654 }
655
656 func ExampleDataprocMetastoreClient_ListLocations() {
657 ctx := context.Background()
658 // This snippet has been automatically generated and should be regarded as a code template only.
659 // It will require modifications to work:
660 // - It may require correct/in-range values for request initialization.
661 // - It may require specifying regional endpoints when creating the service client as shown in:
662 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
663 c, err := metastore.NewDataprocMetastoreClient(ctx)
664 if err != nil {
665 // TODO: Handle error.
666 }
667 defer c.Close()
668
669 req := &locationpb.ListLocationsRequest{
670 // TODO: Fill request struct fields.
671 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
672 }
673 it := c.ListLocations(ctx, req)
674 for {
675 resp, err := it.Next()
676 if err == iterator.Done {
677 break
678 }
679 if err != nil {
680 // TODO: Handle error.
681 }
682 // TODO: Use resp.
683 _ = resp
684
685 // If you need to access the underlying RPC response,
686 // you can do so by casting the `Response` as below.
687 // Otherwise, remove this line. Only populated after
688 // first call to Next(). Not safe for concurrent access.
689 _ = it.Response.(*locationpb.ListLocationsResponse)
690 }
691 }
692
693 func ExampleDataprocMetastoreClient_GetIamPolicy() {
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.GetIamPolicyRequest{
707 // TODO: Fill request struct fields.
708 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
709 }
710 resp, err := c.GetIamPolicy(ctx, req)
711 if err != nil {
712 // TODO: Handle error.
713 }
714 // TODO: Use resp.
715 _ = resp
716 }
717
718 func ExampleDataprocMetastoreClient_SetIamPolicy() {
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.SetIamPolicyRequest{
732 // TODO: Fill request struct fields.
733 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
734 }
735 resp, err := c.SetIamPolicy(ctx, req)
736 if err != nil {
737 // TODO: Handle error.
738 }
739 // TODO: Use resp.
740 _ = resp
741 }
742
743 func ExampleDataprocMetastoreClient_TestIamPermissions() {
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 := &iampb.TestIamPermissionsRequest{
757 // TODO: Fill request struct fields.
758 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
759 }
760 resp, err := c.TestIamPermissions(ctx, req)
761 if err != nil {
762 // TODO: Handle error.
763 }
764 // TODO: Use resp.
765 _ = resp
766 }
767
768 func ExampleDataprocMetastoreClient_CancelOperation() {
769 ctx := context.Background()
770 // This snippet has been automatically generated and should be regarded as a code template only.
771 // It will require modifications to work:
772 // - It may require correct/in-range values for request initialization.
773 // - It may require specifying regional endpoints when creating the service client as shown in:
774 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
775 c, err := metastore.NewDataprocMetastoreClient(ctx)
776 if err != nil {
777 // TODO: Handle error.
778 }
779 defer c.Close()
780
781 req := &longrunningpb.CancelOperationRequest{
782 // TODO: Fill request struct fields.
783 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
784 }
785 err = c.CancelOperation(ctx, req)
786 if err != nil {
787 // TODO: Handle error.
788 }
789 }
790
791 func ExampleDataprocMetastoreClient_DeleteOperation() {
792 ctx := context.Background()
793 // This snippet has been automatically generated and should be regarded as a code template only.
794 // It will require modifications to work:
795 // - It may require correct/in-range values for request initialization.
796 // - It may require specifying regional endpoints when creating the service client as shown in:
797 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
798 c, err := metastore.NewDataprocMetastoreClient(ctx)
799 if err != nil {
800 // TODO: Handle error.
801 }
802 defer c.Close()
803
804 req := &longrunningpb.DeleteOperationRequest{
805 // TODO: Fill request struct fields.
806 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
807 }
808 err = c.DeleteOperation(ctx, req)
809 if err != nil {
810 // TODO: Handle error.
811 }
812 }
813
814 func ExampleDataprocMetastoreClient_GetOperation() {
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.GetOperationRequest{
828 // TODO: Fill request struct fields.
829 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
830 }
831 resp, err := c.GetOperation(ctx, req)
832 if err != nil {
833 // TODO: Handle error.
834 }
835 // TODO: Use resp.
836 _ = resp
837 }
838
839 func ExampleDataprocMetastoreClient_ListOperations() {
840 ctx := context.Background()
841 // This snippet has been automatically generated and should be regarded as a code template only.
842 // It will require modifications to work:
843 // - It may require correct/in-range values for request initialization.
844 // - It may require specifying regional endpoints when creating the service client as shown in:
845 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
846 c, err := metastore.NewDataprocMetastoreClient(ctx)
847 if err != nil {
848 // TODO: Handle error.
849 }
850 defer c.Close()
851
852 req := &longrunningpb.ListOperationsRequest{
853 // TODO: Fill request struct fields.
854 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
855 }
856 it := c.ListOperations(ctx, req)
857 for {
858 resp, err := it.Next()
859 if err == iterator.Done {
860 break
861 }
862 if err != nil {
863 // TODO: Handle error.
864 }
865 // TODO: Use resp.
866 _ = resp
867
868 // If you need to access the underlying RPC response,
869 // you can do so by casting the `Response` as below.
870 // Otherwise, remove this line. Only populated after
871 // first call to Next(). Not safe for concurrent access.
872 _ = it.Response.(*longrunningpb.ListOperationsResponse)
873 }
874 }