Debian Codegraph @

bigquery/biglake/apiv1alpha1/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 biglake_test
18
19 import (
20 "context"
21
22 biglake "cloud.google.com/go/bigquery/biglake/apiv1alpha1"
23 biglakepb "cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb"
24 "google.golang.org/api/iterator"
25 )
26
27 func ExampleNewMetastoreClient() {
28 ctx := context.Background()
29 // This snippet has been automatically generated and should be regarded as a code template only.
30 // It will require modifications to work:
31 // - It may require correct/in-range values for request initialization.
32 // - It may require specifying regional endpoints when creating the service client as shown in:
33 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
34 c, err := biglake.NewMetastoreClient(ctx)
35 if err != nil {
36 // TODO: Handle error.
37 }
38 defer c.Close()
39
40 // TODO: Use client.
41 _ = c
42 }
43
44 func ExampleNewMetastoreRESTClient() {
45 ctx := context.Background()
46 // This snippet has been automatically generated and should be regarded as a code template only.
47 // It will require modifications to work:
48 // - It may require correct/in-range values for request initialization.
49 // - It may require specifying regional endpoints when creating the service client as shown in:
50 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
51 c, err := biglake.NewMetastoreRESTClient(ctx)
52 if err != nil {
53 // TODO: Handle error.
54 }
55 defer c.Close()
56
57 // TODO: Use client.
58 _ = c
59 }
60
61 func ExampleMetastoreClient_CheckLock() {
62 ctx := context.Background()
63 // This snippet has been automatically generated and should be regarded as a code template only.
64 // It will require modifications to work:
65 // - It may require correct/in-range values for request initialization.
66 // - It may require specifying regional endpoints when creating the service client as shown in:
67 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
68 c, err := biglake.NewMetastoreClient(ctx)
69 if err != nil {
70 // TODO: Handle error.
71 }
72 defer c.Close()
73
74 req := &biglakepb.CheckLockRequest{
75 // TODO: Fill request struct fields.
76 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#CheckLockRequest.
77 }
78 resp, err := c.CheckLock(ctx, req)
79 if err != nil {
80 // TODO: Handle error.
81 }
82 // TODO: Use resp.
83 _ = resp
84 }
85
86 func ExampleMetastoreClient_CreateCatalog() {
87 ctx := context.Background()
88 // This snippet has been automatically generated and should be regarded as a code template only.
89 // It will require modifications to work:
90 // - It may require correct/in-range values for request initialization.
91 // - It may require specifying regional endpoints when creating the service client as shown in:
92 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
93 c, err := biglake.NewMetastoreClient(ctx)
94 if err != nil {
95 // TODO: Handle error.
96 }
97 defer c.Close()
98
99 req := &biglakepb.CreateCatalogRequest{
100 // TODO: Fill request struct fields.
101 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#CreateCatalogRequest.
102 }
103 resp, err := c.CreateCatalog(ctx, req)
104 if err != nil {
105 // TODO: Handle error.
106 }
107 // TODO: Use resp.
108 _ = resp
109 }
110
111 func ExampleMetastoreClient_CreateDatabase() {
112 ctx := context.Background()
113 // This snippet has been automatically generated and should be regarded as a code template only.
114 // It will require modifications to work:
115 // - It may require correct/in-range values for request initialization.
116 // - It may require specifying regional endpoints when creating the service client as shown in:
117 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
118 c, err := biglake.NewMetastoreClient(ctx)
119 if err != nil {
120 // TODO: Handle error.
121 }
122 defer c.Close()
123
124 req := &biglakepb.CreateDatabaseRequest{
125 // TODO: Fill request struct fields.
126 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#CreateDatabaseRequest.
127 }
128 resp, err := c.CreateDatabase(ctx, req)
129 if err != nil {
130 // TODO: Handle error.
131 }
132 // TODO: Use resp.
133 _ = resp
134 }
135
136 func ExampleMetastoreClient_CreateLock() {
137 ctx := context.Background()
138 // This snippet has been automatically generated and should be regarded as a code template only.
139 // It will require modifications to work:
140 // - It may require correct/in-range values for request initialization.
141 // - It may require specifying regional endpoints when creating the service client as shown in:
142 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
143 c, err := biglake.NewMetastoreClient(ctx)
144 if err != nil {
145 // TODO: Handle error.
146 }
147 defer c.Close()
148
149 req := &biglakepb.CreateLockRequest{
150 // TODO: Fill request struct fields.
151 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#CreateLockRequest.
152 }
153 resp, err := c.CreateLock(ctx, req)
154 if err != nil {
155 // TODO: Handle error.
156 }
157 // TODO: Use resp.
158 _ = resp
159 }
160
161 func ExampleMetastoreClient_CreateTable() {
162 ctx := context.Background()
163 // This snippet has been automatically generated and should be regarded as a code template only.
164 // It will require modifications to work:
165 // - It may require correct/in-range values for request initialization.
166 // - It may require specifying regional endpoints when creating the service client as shown in:
167 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
168 c, err := biglake.NewMetastoreClient(ctx)
169 if err != nil {
170 // TODO: Handle error.
171 }
172 defer c.Close()
173
174 req := &biglakepb.CreateTableRequest{
175 // TODO: Fill request struct fields.
176 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#CreateTableRequest.
177 }
178 resp, err := c.CreateTable(ctx, req)
179 if err != nil {
180 // TODO: Handle error.
181 }
182 // TODO: Use resp.
183 _ = resp
184 }
185
186 func ExampleMetastoreClient_DeleteCatalog() {
187 ctx := context.Background()
188 // This snippet has been automatically generated and should be regarded as a code template only.
189 // It will require modifications to work:
190 // - It may require correct/in-range values for request initialization.
191 // - It may require specifying regional endpoints when creating the service client as shown in:
192 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
193 c, err := biglake.NewMetastoreClient(ctx)
194 if err != nil {
195 // TODO: Handle error.
196 }
197 defer c.Close()
198
199 req := &biglakepb.DeleteCatalogRequest{
200 // TODO: Fill request struct fields.
201 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#DeleteCatalogRequest.
202 }
203 resp, err := c.DeleteCatalog(ctx, req)
204 if err != nil {
205 // TODO: Handle error.
206 }
207 // TODO: Use resp.
208 _ = resp
209 }
210
211 func ExampleMetastoreClient_DeleteDatabase() {
212 ctx := context.Background()
213 // This snippet has been automatically generated and should be regarded as a code template only.
214 // It will require modifications to work:
215 // - It may require correct/in-range values for request initialization.
216 // - It may require specifying regional endpoints when creating the service client as shown in:
217 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
218 c, err := biglake.NewMetastoreClient(ctx)
219 if err != nil {
220 // TODO: Handle error.
221 }
222 defer c.Close()
223
224 req := &biglakepb.DeleteDatabaseRequest{
225 // TODO: Fill request struct fields.
226 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#DeleteDatabaseRequest.
227 }
228 resp, err := c.DeleteDatabase(ctx, req)
229 if err != nil {
230 // TODO: Handle error.
231 }
232 // TODO: Use resp.
233 _ = resp
234 }
235
236 func ExampleMetastoreClient_DeleteLock() {
237 ctx := context.Background()
238 // This snippet has been automatically generated and should be regarded as a code template only.
239 // It will require modifications to work:
240 // - It may require correct/in-range values for request initialization.
241 // - It may require specifying regional endpoints when creating the service client as shown in:
242 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
243 c, err := biglake.NewMetastoreClient(ctx)
244 if err != nil {
245 // TODO: Handle error.
246 }
247 defer c.Close()
248
249 req := &biglakepb.DeleteLockRequest{
250 // TODO: Fill request struct fields.
251 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#DeleteLockRequest.
252 }
253 err = c.DeleteLock(ctx, req)
254 if err != nil {
255 // TODO: Handle error.
256 }
257 }
258
259 func ExampleMetastoreClient_DeleteTable() {
260 ctx := context.Background()
261 // This snippet has been automatically generated and should be regarded as a code template only.
262 // It will require modifications to work:
263 // - It may require correct/in-range values for request initialization.
264 // - It may require specifying regional endpoints when creating the service client as shown in:
265 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
266 c, err := biglake.NewMetastoreClient(ctx)
267 if err != nil {
268 // TODO: Handle error.
269 }
270 defer c.Close()
271
272 req := &biglakepb.DeleteTableRequest{
273 // TODO: Fill request struct fields.
274 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#DeleteTableRequest.
275 }
276 resp, err := c.DeleteTable(ctx, req)
277 if err != nil {
278 // TODO: Handle error.
279 }
280 // TODO: Use resp.
281 _ = resp
282 }
283
284 func ExampleMetastoreClient_GetCatalog() {
285 ctx := context.Background()
286 // This snippet has been automatically generated and should be regarded as a code template only.
287 // It will require modifications to work:
288 // - It may require correct/in-range values for request initialization.
289 // - It may require specifying regional endpoints when creating the service client as shown in:
290 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
291 c, err := biglake.NewMetastoreClient(ctx)
292 if err != nil {
293 // TODO: Handle error.
294 }
295 defer c.Close()
296
297 req := &biglakepb.GetCatalogRequest{
298 // TODO: Fill request struct fields.
299 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#GetCatalogRequest.
300 }
301 resp, err := c.GetCatalog(ctx, req)
302 if err != nil {
303 // TODO: Handle error.
304 }
305 // TODO: Use resp.
306 _ = resp
307 }
308
309 func ExampleMetastoreClient_GetDatabase() {
310 ctx := context.Background()
311 // This snippet has been automatically generated and should be regarded as a code template only.
312 // It will require modifications to work:
313 // - It may require correct/in-range values for request initialization.
314 // - It may require specifying regional endpoints when creating the service client as shown in:
315 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
316 c, err := biglake.NewMetastoreClient(ctx)
317 if err != nil {
318 // TODO: Handle error.
319 }
320 defer c.Close()
321
322 req := &biglakepb.GetDatabaseRequest{
323 // TODO: Fill request struct fields.
324 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#GetDatabaseRequest.
325 }
326 resp, err := c.GetDatabase(ctx, req)
327 if err != nil {
328 // TODO: Handle error.
329 }
330 // TODO: Use resp.
331 _ = resp
332 }
333
334 func ExampleMetastoreClient_GetTable() {
335 ctx := context.Background()
336 // This snippet has been automatically generated and should be regarded as a code template only.
337 // It will require modifications to work:
338 // - It may require correct/in-range values for request initialization.
339 // - It may require specifying regional endpoints when creating the service client as shown in:
340 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
341 c, err := biglake.NewMetastoreClient(ctx)
342 if err != nil {
343 // TODO: Handle error.
344 }
345 defer c.Close()
346
347 req := &biglakepb.GetTableRequest{
348 // TODO: Fill request struct fields.
349 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#GetTableRequest.
350 }
351 resp, err := c.GetTable(ctx, req)
352 if err != nil {
353 // TODO: Handle error.
354 }
355 // TODO: Use resp.
356 _ = resp
357 }
358
359 func ExampleMetastoreClient_ListCatalogs() {
360 ctx := context.Background()
361 // This snippet has been automatically generated and should be regarded as a code template only.
362 // It will require modifications to work:
363 // - It may require correct/in-range values for request initialization.
364 // - It may require specifying regional endpoints when creating the service client as shown in:
365 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
366 c, err := biglake.NewMetastoreClient(ctx)
367 if err != nil {
368 // TODO: Handle error.
369 }
370 defer c.Close()
371
372 req := &biglakepb.ListCatalogsRequest{
373 // TODO: Fill request struct fields.
374 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#ListCatalogsRequest.
375 }
376 it := c.ListCatalogs(ctx, req)
377 for {
378 resp, err := it.Next()
379 if err == iterator.Done {
380 break
381 }
382 if err != nil {
383 // TODO: Handle error.
384 }
385 // TODO: Use resp.
386 _ = resp
387
388 // If you need to access the underlying RPC response,
389 // you can do so by casting the `Response` as below.
390 // Otherwise, remove this line. Only populated after
391 // first call to Next(). Not safe for concurrent access.
392 _ = it.Response.(*biglakepb.ListCatalogsResponse)
393 }
394 }
395
396 func ExampleMetastoreClient_ListDatabases() {
397 ctx := context.Background()
398 // This snippet has been automatically generated and should be regarded as a code template only.
399 // It will require modifications to work:
400 // - It may require correct/in-range values for request initialization.
401 // - It may require specifying regional endpoints when creating the service client as shown in:
402 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
403 c, err := biglake.NewMetastoreClient(ctx)
404 if err != nil {
405 // TODO: Handle error.
406 }
407 defer c.Close()
408
409 req := &biglakepb.ListDatabasesRequest{
410 // TODO: Fill request struct fields.
411 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#ListDatabasesRequest.
412 }
413 it := c.ListDatabases(ctx, req)
414 for {
415 resp, err := it.Next()
416 if err == iterator.Done {
417 break
418 }
419 if err != nil {
420 // TODO: Handle error.
421 }
422 // TODO: Use resp.
423 _ = resp
424
425 // If you need to access the underlying RPC response,
426 // you can do so by casting the `Response` as below.
427 // Otherwise, remove this line. Only populated after
428 // first call to Next(). Not safe for concurrent access.
429 _ = it.Response.(*biglakepb.ListDatabasesResponse)
430 }
431 }
432
433 func ExampleMetastoreClient_ListLocks() {
434 ctx := context.Background()
435 // This snippet has been automatically generated and should be regarded as a code template only.
436 // It will require modifications to work:
437 // - It may require correct/in-range values for request initialization.
438 // - It may require specifying regional endpoints when creating the service client as shown in:
439 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
440 c, err := biglake.NewMetastoreClient(ctx)
441 if err != nil {
442 // TODO: Handle error.
443 }
444 defer c.Close()
445
446 req := &biglakepb.ListLocksRequest{
447 // TODO: Fill request struct fields.
448 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#ListLocksRequest.
449 }
450 it := c.ListLocks(ctx, req)
451 for {
452 resp, err := it.Next()
453 if err == iterator.Done {
454 break
455 }
456 if err != nil {
457 // TODO: Handle error.
458 }
459 // TODO: Use resp.
460 _ = resp
461
462 // If you need to access the underlying RPC response,
463 // you can do so by casting the `Response` as below.
464 // Otherwise, remove this line. Only populated after
465 // first call to Next(). Not safe for concurrent access.
466 _ = it.Response.(*biglakepb.ListLocksResponse)
467 }
468 }
469
470 func ExampleMetastoreClient_ListTables() {
471 ctx := context.Background()
472 // This snippet has been automatically generated and should be regarded as a code template only.
473 // It will require modifications to work:
474 // - It may require correct/in-range values for request initialization.
475 // - It may require specifying regional endpoints when creating the service client as shown in:
476 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
477 c, err := biglake.NewMetastoreClient(ctx)
478 if err != nil {
479 // TODO: Handle error.
480 }
481 defer c.Close()
482
483 req := &biglakepb.ListTablesRequest{
484 // TODO: Fill request struct fields.
485 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#ListTablesRequest.
486 }
487 it := c.ListTables(ctx, req)
488 for {
489 resp, err := it.Next()
490 if err == iterator.Done {
491 break
492 }
493 if err != nil {
494 // TODO: Handle error.
495 }
496 // TODO: Use resp.
497 _ = resp
498
499 // If you need to access the underlying RPC response,
500 // you can do so by casting the `Response` as below.
501 // Otherwise, remove this line. Only populated after
502 // first call to Next(). Not safe for concurrent access.
503 _ = it.Response.(*biglakepb.ListTablesResponse)
504 }
505 }
506
507 func ExampleMetastoreClient_RenameTable() {
508 ctx := context.Background()
509 // This snippet has been automatically generated and should be regarded as a code template only.
510 // It will require modifications to work:
511 // - It may require correct/in-range values for request initialization.
512 // - It may require specifying regional endpoints when creating the service client as shown in:
513 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
514 c, err := biglake.NewMetastoreClient(ctx)
515 if err != nil {
516 // TODO: Handle error.
517 }
518 defer c.Close()
519
520 req := &biglakepb.RenameTableRequest{
521 // TODO: Fill request struct fields.
522 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#RenameTableRequest.
523 }
524 resp, err := c.RenameTable(ctx, req)
525 if err != nil {
526 // TODO: Handle error.
527 }
528 // TODO: Use resp.
529 _ = resp
530 }
531
532 func ExampleMetastoreClient_UpdateDatabase() {
533 ctx := context.Background()
534 // This snippet has been automatically generated and should be regarded as a code template only.
535 // It will require modifications to work:
536 // - It may require correct/in-range values for request initialization.
537 // - It may require specifying regional endpoints when creating the service client as shown in:
538 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
539 c, err := biglake.NewMetastoreClient(ctx)
540 if err != nil {
541 // TODO: Handle error.
542 }
543 defer c.Close()
544
545 req := &biglakepb.UpdateDatabaseRequest{
546 // TODO: Fill request struct fields.
547 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#UpdateDatabaseRequest.
548 }
549 resp, err := c.UpdateDatabase(ctx, req)
550 if err != nil {
551 // TODO: Handle error.
552 }
553 // TODO: Use resp.
554 _ = resp
555 }
556
557 func ExampleMetastoreClient_UpdateTable() {
558 ctx := context.Background()
559 // This snippet has been automatically generated and should be regarded as a code template only.
560 // It will require modifications to work:
561 // - It may require correct/in-range values for request initialization.
562 // - It may require specifying regional endpoints when creating the service client as shown in:
563 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
564 c, err := biglake.NewMetastoreClient(ctx)
565 if err != nil {
566 // TODO: Handle error.
567 }
568 defer c.Close()
569
570 req := &biglakepb.UpdateTableRequest{
571 // TODO: Fill request struct fields.
572 // See https://pkg.go.dev/cloud.google.com/go/bigquery/biglake/apiv1alpha1/biglakepb#UpdateTableRequest.
573 }
574 resp, err := c.UpdateTable(ctx, req)
575 if err != nil {
576 // TODO: Handle error.
577 }
578 // TODO: Use resp.
579 _ = resp
580 }