1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package biglake
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "io"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 biglakepb "cloud.google.com/go/bigquery/biglake/apiv1/biglakepb"
30 gax "github.com/googleapis/gax-go/v2"
31 "google.golang.org/api/googleapi"
32 "google.golang.org/api/iterator"
33 "google.golang.org/api/option"
34 "google.golang.org/api/option/internaloption"
35 gtransport "google.golang.org/api/transport/grpc"
36 httptransport "google.golang.org/api/transport/http"
37 "google.golang.org/grpc"
38 "google.golang.org/grpc/codes"
39 "google.golang.org/protobuf/encoding/protojson"
40 "google.golang.org/protobuf/proto"
41 )
42
43 var newMetastoreClientHook clientHook
44
45
46 type MetastoreCallOptions struct {
47 CreateCatalog []gax.CallOption
48 DeleteCatalog []gax.CallOption
49 GetCatalog []gax.CallOption
50 ListCatalogs []gax.CallOption
51 CreateDatabase []gax.CallOption
52 DeleteDatabase []gax.CallOption
53 UpdateDatabase []gax.CallOption
54 GetDatabase []gax.CallOption
55 ListDatabases []gax.CallOption
56 CreateTable []gax.CallOption
57 DeleteTable []gax.CallOption
58 UpdateTable []gax.CallOption
59 RenameTable []gax.CallOption
60 GetTable []gax.CallOption
61 ListTables []gax.CallOption
62 }
63
64 func defaultMetastoreGRPCClientOptions() []option.ClientOption {
65 return []option.ClientOption{
66 internaloption.WithDefaultEndpoint("biglake.googleapis.com:443"),
67 internaloption.WithDefaultEndpointTemplate("biglake.UNIVERSE_DOMAIN:443"),
68 internaloption.WithDefaultMTLSEndpoint("biglake.mtls.googleapis.com:443"),
69 internaloption.WithDefaultUniverseDomain("googleapis.com"),
70 internaloption.WithDefaultAudience("https://biglake.googleapis.com/"),
71 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
72 internaloption.EnableJwtWithScope(),
73 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
74 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
75 }
76 }
77
78 func defaultMetastoreCallOptions() *MetastoreCallOptions {
79 return &MetastoreCallOptions{
80 CreateCatalog: []gax.CallOption{
81 gax.WithTimeout(60000 * time.Millisecond),
82 gax.WithRetry(func() gax.Retryer {
83 return gax.OnCodes([]codes.Code{
84 codes.DeadlineExceeded,
85 codes.Unavailable,
86 }, gax.Backoff{
87 Initial: 1000 * time.Millisecond,
88 Max: 10000 * time.Millisecond,
89 Multiplier: 1.30,
90 })
91 }),
92 },
93 DeleteCatalog: []gax.CallOption{
94 gax.WithTimeout(60000 * time.Millisecond),
95 gax.WithRetry(func() gax.Retryer {
96 return gax.OnCodes([]codes.Code{
97 codes.DeadlineExceeded,
98 codes.Unavailable,
99 }, gax.Backoff{
100 Initial: 1000 * time.Millisecond,
101 Max: 10000 * time.Millisecond,
102 Multiplier: 1.30,
103 })
104 }),
105 },
106 GetCatalog: []gax.CallOption{
107 gax.WithTimeout(60000 * time.Millisecond),
108 gax.WithRetry(func() gax.Retryer {
109 return gax.OnCodes([]codes.Code{
110 codes.DeadlineExceeded,
111 codes.Unavailable,
112 }, gax.Backoff{
113 Initial: 1000 * time.Millisecond,
114 Max: 10000 * time.Millisecond,
115 Multiplier: 1.30,
116 })
117 }),
118 },
119 ListCatalogs: []gax.CallOption{
120 gax.WithTimeout(60000 * time.Millisecond),
121 gax.WithRetry(func() gax.Retryer {
122 return gax.OnCodes([]codes.Code{
123 codes.DeadlineExceeded,
124 codes.Unavailable,
125 }, gax.Backoff{
126 Initial: 1000 * time.Millisecond,
127 Max: 10000 * time.Millisecond,
128 Multiplier: 1.30,
129 })
130 }),
131 },
132 CreateDatabase: []gax.CallOption{
133 gax.WithTimeout(60000 * time.Millisecond),
134 gax.WithRetry(func() gax.Retryer {
135 return gax.OnCodes([]codes.Code{
136 codes.DeadlineExceeded,
137 codes.Unavailable,
138 }, gax.Backoff{
139 Initial: 1000 * time.Millisecond,
140 Max: 10000 * time.Millisecond,
141 Multiplier: 1.30,
142 })
143 }),
144 },
145 DeleteDatabase: []gax.CallOption{
146 gax.WithTimeout(60000 * time.Millisecond),
147 gax.WithRetry(func() gax.Retryer {
148 return gax.OnCodes([]codes.Code{
149 codes.DeadlineExceeded,
150 codes.Unavailable,
151 }, gax.Backoff{
152 Initial: 1000 * time.Millisecond,
153 Max: 10000 * time.Millisecond,
154 Multiplier: 1.30,
155 })
156 }),
157 },
158 UpdateDatabase: []gax.CallOption{
159 gax.WithTimeout(60000 * time.Millisecond),
160 gax.WithRetry(func() gax.Retryer {
161 return gax.OnCodes([]codes.Code{
162 codes.DeadlineExceeded,
163 codes.Unavailable,
164 }, gax.Backoff{
165 Initial: 1000 * time.Millisecond,
166 Max: 10000 * time.Millisecond,
167 Multiplier: 1.30,
168 })
169 }),
170 },
171 GetDatabase: []gax.CallOption{
172 gax.WithTimeout(60000 * time.Millisecond),
173 gax.WithRetry(func() gax.Retryer {
174 return gax.OnCodes([]codes.Code{
175 codes.DeadlineExceeded,
176 codes.Unavailable,
177 }, gax.Backoff{
178 Initial: 1000 * time.Millisecond,
179 Max: 10000 * time.Millisecond,
180 Multiplier: 1.30,
181 })
182 }),
183 },
184 ListDatabases: []gax.CallOption{
185 gax.WithTimeout(60000 * time.Millisecond),
186 gax.WithRetry(func() gax.Retryer {
187 return gax.OnCodes([]codes.Code{
188 codes.DeadlineExceeded,
189 codes.Unavailable,
190 }, gax.Backoff{
191 Initial: 1000 * time.Millisecond,
192 Max: 10000 * time.Millisecond,
193 Multiplier: 1.30,
194 })
195 }),
196 },
197 CreateTable: []gax.CallOption{
198 gax.WithTimeout(60000 * time.Millisecond),
199 gax.WithRetry(func() gax.Retryer {
200 return gax.OnCodes([]codes.Code{
201 codes.DeadlineExceeded,
202 codes.Unavailable,
203 }, gax.Backoff{
204 Initial: 1000 * time.Millisecond,
205 Max: 10000 * time.Millisecond,
206 Multiplier: 1.30,
207 })
208 }),
209 },
210 DeleteTable: []gax.CallOption{
211 gax.WithTimeout(60000 * time.Millisecond),
212 gax.WithRetry(func() gax.Retryer {
213 return gax.OnCodes([]codes.Code{
214 codes.DeadlineExceeded,
215 codes.Unavailable,
216 }, gax.Backoff{
217 Initial: 1000 * time.Millisecond,
218 Max: 10000 * time.Millisecond,
219 Multiplier: 1.30,
220 })
221 }),
222 },
223 UpdateTable: []gax.CallOption{
224 gax.WithTimeout(60000 * time.Millisecond),
225 gax.WithRetry(func() gax.Retryer {
226 return gax.OnCodes([]codes.Code{
227 codes.DeadlineExceeded,
228 codes.Unavailable,
229 }, gax.Backoff{
230 Initial: 1000 * time.Millisecond,
231 Max: 10000 * time.Millisecond,
232 Multiplier: 1.30,
233 })
234 }),
235 },
236 RenameTable: []gax.CallOption{
237 gax.WithTimeout(60000 * time.Millisecond),
238 gax.WithRetry(func() gax.Retryer {
239 return gax.OnCodes([]codes.Code{
240 codes.DeadlineExceeded,
241 codes.Unavailable,
242 }, gax.Backoff{
243 Initial: 1000 * time.Millisecond,
244 Max: 10000 * time.Millisecond,
245 Multiplier: 1.30,
246 })
247 }),
248 },
249 GetTable: []gax.CallOption{
250 gax.WithTimeout(60000 * time.Millisecond),
251 gax.WithRetry(func() gax.Retryer {
252 return gax.OnCodes([]codes.Code{
253 codes.DeadlineExceeded,
254 codes.Unavailable,
255 }, gax.Backoff{
256 Initial: 1000 * time.Millisecond,
257 Max: 10000 * time.Millisecond,
258 Multiplier: 1.30,
259 })
260 }),
261 },
262 ListTables: []gax.CallOption{
263 gax.WithTimeout(60000 * time.Millisecond),
264 gax.WithRetry(func() gax.Retryer {
265 return gax.OnCodes([]codes.Code{
266 codes.DeadlineExceeded,
267 codes.Unavailable,
268 }, gax.Backoff{
269 Initial: 1000 * time.Millisecond,
270 Max: 10000 * time.Millisecond,
271 Multiplier: 1.30,
272 })
273 }),
274 },
275 }
276 }
277
278 func defaultMetastoreRESTCallOptions() *MetastoreCallOptions {
279 return &MetastoreCallOptions{
280 CreateCatalog: []gax.CallOption{
281 gax.WithTimeout(60000 * time.Millisecond),
282 gax.WithRetry(func() gax.Retryer {
283 return gax.OnHTTPCodes(gax.Backoff{
284 Initial: 1000 * time.Millisecond,
285 Max: 10000 * time.Millisecond,
286 Multiplier: 1.30,
287 },
288 http.StatusGatewayTimeout,
289 http.StatusServiceUnavailable)
290 }),
291 },
292 DeleteCatalog: []gax.CallOption{
293 gax.WithTimeout(60000 * time.Millisecond),
294 gax.WithRetry(func() gax.Retryer {
295 return gax.OnHTTPCodes(gax.Backoff{
296 Initial: 1000 * time.Millisecond,
297 Max: 10000 * time.Millisecond,
298 Multiplier: 1.30,
299 },
300 http.StatusGatewayTimeout,
301 http.StatusServiceUnavailable)
302 }),
303 },
304 GetCatalog: []gax.CallOption{
305 gax.WithTimeout(60000 * time.Millisecond),
306 gax.WithRetry(func() gax.Retryer {
307 return gax.OnHTTPCodes(gax.Backoff{
308 Initial: 1000 * time.Millisecond,
309 Max: 10000 * time.Millisecond,
310 Multiplier: 1.30,
311 },
312 http.StatusGatewayTimeout,
313 http.StatusServiceUnavailable)
314 }),
315 },
316 ListCatalogs: []gax.CallOption{
317 gax.WithTimeout(60000 * time.Millisecond),
318 gax.WithRetry(func() gax.Retryer {
319 return gax.OnHTTPCodes(gax.Backoff{
320 Initial: 1000 * time.Millisecond,
321 Max: 10000 * time.Millisecond,
322 Multiplier: 1.30,
323 },
324 http.StatusGatewayTimeout,
325 http.StatusServiceUnavailable)
326 }),
327 },
328 CreateDatabase: []gax.CallOption{
329 gax.WithTimeout(60000 * time.Millisecond),
330 gax.WithRetry(func() gax.Retryer {
331 return gax.OnHTTPCodes(gax.Backoff{
332 Initial: 1000 * time.Millisecond,
333 Max: 10000 * time.Millisecond,
334 Multiplier: 1.30,
335 },
336 http.StatusGatewayTimeout,
337 http.StatusServiceUnavailable)
338 }),
339 },
340 DeleteDatabase: []gax.CallOption{
341 gax.WithTimeout(60000 * time.Millisecond),
342 gax.WithRetry(func() gax.Retryer {
343 return gax.OnHTTPCodes(gax.Backoff{
344 Initial: 1000 * time.Millisecond,
345 Max: 10000 * time.Millisecond,
346 Multiplier: 1.30,
347 },
348 http.StatusGatewayTimeout,
349 http.StatusServiceUnavailable)
350 }),
351 },
352 UpdateDatabase: []gax.CallOption{
353 gax.WithTimeout(60000 * time.Millisecond),
354 gax.WithRetry(func() gax.Retryer {
355 return gax.OnHTTPCodes(gax.Backoff{
356 Initial: 1000 * time.Millisecond,
357 Max: 10000 * time.Millisecond,
358 Multiplier: 1.30,
359 },
360 http.StatusGatewayTimeout,
361 http.StatusServiceUnavailable)
362 }),
363 },
364 GetDatabase: []gax.CallOption{
365 gax.WithTimeout(60000 * time.Millisecond),
366 gax.WithRetry(func() gax.Retryer {
367 return gax.OnHTTPCodes(gax.Backoff{
368 Initial: 1000 * time.Millisecond,
369 Max: 10000 * time.Millisecond,
370 Multiplier: 1.30,
371 },
372 http.StatusGatewayTimeout,
373 http.StatusServiceUnavailable)
374 }),
375 },
376 ListDatabases: []gax.CallOption{
377 gax.WithTimeout(60000 * time.Millisecond),
378 gax.WithRetry(func() gax.Retryer {
379 return gax.OnHTTPCodes(gax.Backoff{
380 Initial: 1000 * time.Millisecond,
381 Max: 10000 * time.Millisecond,
382 Multiplier: 1.30,
383 },
384 http.StatusGatewayTimeout,
385 http.StatusServiceUnavailable)
386 }),
387 },
388 CreateTable: []gax.CallOption{
389 gax.WithTimeout(60000 * time.Millisecond),
390 gax.WithRetry(func() gax.Retryer {
391 return gax.OnHTTPCodes(gax.Backoff{
392 Initial: 1000 * time.Millisecond,
393 Max: 10000 * time.Millisecond,
394 Multiplier: 1.30,
395 },
396 http.StatusGatewayTimeout,
397 http.StatusServiceUnavailable)
398 }),
399 },
400 DeleteTable: []gax.CallOption{
401 gax.WithTimeout(60000 * time.Millisecond),
402 gax.WithRetry(func() gax.Retryer {
403 return gax.OnHTTPCodes(gax.Backoff{
404 Initial: 1000 * time.Millisecond,
405 Max: 10000 * time.Millisecond,
406 Multiplier: 1.30,
407 },
408 http.StatusGatewayTimeout,
409 http.StatusServiceUnavailable)
410 }),
411 },
412 UpdateTable: []gax.CallOption{
413 gax.WithTimeout(60000 * time.Millisecond),
414 gax.WithRetry(func() gax.Retryer {
415 return gax.OnHTTPCodes(gax.Backoff{
416 Initial: 1000 * time.Millisecond,
417 Max: 10000 * time.Millisecond,
418 Multiplier: 1.30,
419 },
420 http.StatusGatewayTimeout,
421 http.StatusServiceUnavailable)
422 }),
423 },
424 RenameTable: []gax.CallOption{
425 gax.WithTimeout(60000 * time.Millisecond),
426 gax.WithRetry(func() gax.Retryer {
427 return gax.OnHTTPCodes(gax.Backoff{
428 Initial: 1000 * time.Millisecond,
429 Max: 10000 * time.Millisecond,
430 Multiplier: 1.30,
431 },
432 http.StatusGatewayTimeout,
433 http.StatusServiceUnavailable)
434 }),
435 },
436 GetTable: []gax.CallOption{
437 gax.WithTimeout(60000 * time.Millisecond),
438 gax.WithRetry(func() gax.Retryer {
439 return gax.OnHTTPCodes(gax.Backoff{
440 Initial: 1000 * time.Millisecond,
441 Max: 10000 * time.Millisecond,
442 Multiplier: 1.30,
443 },
444 http.StatusGatewayTimeout,
445 http.StatusServiceUnavailable)
446 }),
447 },
448 ListTables: []gax.CallOption{
449 gax.WithTimeout(60000 * time.Millisecond),
450 gax.WithRetry(func() gax.Retryer {
451 return gax.OnHTTPCodes(gax.Backoff{
452 Initial: 1000 * time.Millisecond,
453 Max: 10000 * time.Millisecond,
454 Multiplier: 1.30,
455 },
456 http.StatusGatewayTimeout,
457 http.StatusServiceUnavailable)
458 }),
459 },
460 }
461 }
462
463
464 type internalMetastoreClient interface {
465 Close() error
466 setGoogleClientInfo(...string)
467 Connection() *grpc.ClientConn
468 CreateCatalog(context.Context, *biglakepb.CreateCatalogRequest, ...gax.CallOption) (*biglakepb.Catalog, error)
469 DeleteCatalog(context.Context, *biglakepb.DeleteCatalogRequest, ...gax.CallOption) (*biglakepb.Catalog, error)
470 GetCatalog(context.Context, *biglakepb.GetCatalogRequest, ...gax.CallOption) (*biglakepb.Catalog, error)
471 ListCatalogs(context.Context, *biglakepb.ListCatalogsRequest, ...gax.CallOption) *CatalogIterator
472 CreateDatabase(context.Context, *biglakepb.CreateDatabaseRequest, ...gax.CallOption) (*biglakepb.Database, error)
473 DeleteDatabase(context.Context, *biglakepb.DeleteDatabaseRequest, ...gax.CallOption) (*biglakepb.Database, error)
474 UpdateDatabase(context.Context, *biglakepb.UpdateDatabaseRequest, ...gax.CallOption) (*biglakepb.Database, error)
475 GetDatabase(context.Context, *biglakepb.GetDatabaseRequest, ...gax.CallOption) (*biglakepb.Database, error)
476 ListDatabases(context.Context, *biglakepb.ListDatabasesRequest, ...gax.CallOption) *DatabaseIterator
477 CreateTable(context.Context, *biglakepb.CreateTableRequest, ...gax.CallOption) (*biglakepb.Table, error)
478 DeleteTable(context.Context, *biglakepb.DeleteTableRequest, ...gax.CallOption) (*biglakepb.Table, error)
479 UpdateTable(context.Context, *biglakepb.UpdateTableRequest, ...gax.CallOption) (*biglakepb.Table, error)
480 RenameTable(context.Context, *biglakepb.RenameTableRequest, ...gax.CallOption) (*biglakepb.Table, error)
481 GetTable(context.Context, *biglakepb.GetTableRequest, ...gax.CallOption) (*biglakepb.Table, error)
482 ListTables(context.Context, *biglakepb.ListTablesRequest, ...gax.CallOption) *TableIterator
483 }
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502 type MetastoreClient struct {
503
504 internalClient internalMetastoreClient
505
506
507 CallOptions *MetastoreCallOptions
508 }
509
510
511
512
513
514 func (c *MetastoreClient) Close() error {
515 return c.internalClient.Close()
516 }
517
518
519
520
521 func (c *MetastoreClient) setGoogleClientInfo(keyval ...string) {
522 c.internalClient.setGoogleClientInfo(keyval...)
523 }
524
525
526
527
528
529 func (c *MetastoreClient) Connection() *grpc.ClientConn {
530 return c.internalClient.Connection()
531 }
532
533
534 func (c *MetastoreClient) CreateCatalog(ctx context.Context, req *biglakepb.CreateCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
535 return c.internalClient.CreateCatalog(ctx, req, opts...)
536 }
537
538
539 func (c *MetastoreClient) DeleteCatalog(ctx context.Context, req *biglakepb.DeleteCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
540 return c.internalClient.DeleteCatalog(ctx, req, opts...)
541 }
542
543
544 func (c *MetastoreClient) GetCatalog(ctx context.Context, req *biglakepb.GetCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
545 return c.internalClient.GetCatalog(ctx, req, opts...)
546 }
547
548
549 func (c *MetastoreClient) ListCatalogs(ctx context.Context, req *biglakepb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator {
550 return c.internalClient.ListCatalogs(ctx, req, opts...)
551 }
552
553
554 func (c *MetastoreClient) CreateDatabase(ctx context.Context, req *biglakepb.CreateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
555 return c.internalClient.CreateDatabase(ctx, req, opts...)
556 }
557
558
559 func (c *MetastoreClient) DeleteDatabase(ctx context.Context, req *biglakepb.DeleteDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
560 return c.internalClient.DeleteDatabase(ctx, req, opts...)
561 }
562
563
564 func (c *MetastoreClient) UpdateDatabase(ctx context.Context, req *biglakepb.UpdateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
565 return c.internalClient.UpdateDatabase(ctx, req, opts...)
566 }
567
568
569 func (c *MetastoreClient) GetDatabase(ctx context.Context, req *biglakepb.GetDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
570 return c.internalClient.GetDatabase(ctx, req, opts...)
571 }
572
573
574 func (c *MetastoreClient) ListDatabases(ctx context.Context, req *biglakepb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator {
575 return c.internalClient.ListDatabases(ctx, req, opts...)
576 }
577
578
579 func (c *MetastoreClient) CreateTable(ctx context.Context, req *biglakepb.CreateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
580 return c.internalClient.CreateTable(ctx, req, opts...)
581 }
582
583
584 func (c *MetastoreClient) DeleteTable(ctx context.Context, req *biglakepb.DeleteTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
585 return c.internalClient.DeleteTable(ctx, req, opts...)
586 }
587
588
589 func (c *MetastoreClient) UpdateTable(ctx context.Context, req *biglakepb.UpdateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
590 return c.internalClient.UpdateTable(ctx, req, opts...)
591 }
592
593
594 func (c *MetastoreClient) RenameTable(ctx context.Context, req *biglakepb.RenameTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
595 return c.internalClient.RenameTable(ctx, req, opts...)
596 }
597
598
599 func (c *MetastoreClient) GetTable(ctx context.Context, req *biglakepb.GetTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
600 return c.internalClient.GetTable(ctx, req, opts...)
601 }
602
603
604 func (c *MetastoreClient) ListTables(ctx context.Context, req *biglakepb.ListTablesRequest, opts ...gax.CallOption) *TableIterator {
605 return c.internalClient.ListTables(ctx, req, opts...)
606 }
607
608
609
610
611 type metastoreGRPCClient struct {
612
613 connPool gtransport.ConnPool
614
615
616 CallOptions **MetastoreCallOptions
617
618
619 metastoreClient biglakepb.MetastoreServiceClient
620
621
622 xGoogHeaders []string
623 }
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642 func NewMetastoreClient(ctx context.Context, opts ...option.ClientOption) (*MetastoreClient, error) {
643 clientOpts := defaultMetastoreGRPCClientOptions()
644 if newMetastoreClientHook != nil {
645 hookOpts, err := newMetastoreClientHook(ctx, clientHookParams{})
646 if err != nil {
647 return nil, err
648 }
649 clientOpts = append(clientOpts, hookOpts...)
650 }
651
652 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
653 if err != nil {
654 return nil, err
655 }
656 client := MetastoreClient{CallOptions: defaultMetastoreCallOptions()}
657
658 c := &metastoreGRPCClient{
659 connPool: connPool,
660 metastoreClient: biglakepb.NewMetastoreServiceClient(connPool),
661 CallOptions: &client.CallOptions,
662 }
663 c.setGoogleClientInfo()
664
665 client.internalClient = c
666
667 return &client, nil
668 }
669
670
671
672
673
674 func (c *metastoreGRPCClient) Connection() *grpc.ClientConn {
675 return c.connPool.Conn()
676 }
677
678
679
680
681 func (c *metastoreGRPCClient) setGoogleClientInfo(keyval ...string) {
682 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
683 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
684 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
685 }
686
687
688
689 func (c *metastoreGRPCClient) Close() error {
690 return c.connPool.Close()
691 }
692
693
694 type metastoreRESTClient struct {
695
696 endpoint string
697
698
699 httpClient *http.Client
700
701
702 xGoogHeaders []string
703
704
705 CallOptions **MetastoreCallOptions
706 }
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724 func NewMetastoreRESTClient(ctx context.Context, opts ...option.ClientOption) (*MetastoreClient, error) {
725 clientOpts := append(defaultMetastoreRESTClientOptions(), opts...)
726 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
727 if err != nil {
728 return nil, err
729 }
730
731 callOpts := defaultMetastoreRESTCallOptions()
732 c := &metastoreRESTClient{
733 endpoint: endpoint,
734 httpClient: httpClient,
735 CallOptions: &callOpts,
736 }
737 c.setGoogleClientInfo()
738
739 return &MetastoreClient{internalClient: c, CallOptions: callOpts}, nil
740 }
741
742 func defaultMetastoreRESTClientOptions() []option.ClientOption {
743 return []option.ClientOption{
744 internaloption.WithDefaultEndpoint("https://biglake.googleapis.com"),
745 internaloption.WithDefaultEndpointTemplate("https://biglake.UNIVERSE_DOMAIN"),
746 internaloption.WithDefaultMTLSEndpoint("https://biglake.mtls.googleapis.com"),
747 internaloption.WithDefaultUniverseDomain("googleapis.com"),
748 internaloption.WithDefaultAudience("https://biglake.googleapis.com/"),
749 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
750 }
751 }
752
753
754
755
756 func (c *metastoreRESTClient) setGoogleClientInfo(keyval ...string) {
757 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
758 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
759 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
760 }
761
762
763
764 func (c *metastoreRESTClient) Close() error {
765
766 c.httpClient = nil
767 return nil
768 }
769
770
771
772
773 func (c *metastoreRESTClient) Connection() *grpc.ClientConn {
774 return nil
775 }
776 func (c *metastoreGRPCClient) CreateCatalog(ctx context.Context, req *biglakepb.CreateCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
777 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
778
779 hds = append(c.xGoogHeaders, hds...)
780 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
781 opts = append((*c.CallOptions).CreateCatalog[0:len((*c.CallOptions).CreateCatalog):len((*c.CallOptions).CreateCatalog)], opts...)
782 var resp *biglakepb.Catalog
783 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
784 var err error
785 resp, err = c.metastoreClient.CreateCatalog(ctx, req, settings.GRPC...)
786 return err
787 }, opts...)
788 if err != nil {
789 return nil, err
790 }
791 return resp, nil
792 }
793
794 func (c *metastoreGRPCClient) DeleteCatalog(ctx context.Context, req *biglakepb.DeleteCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
795 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
796
797 hds = append(c.xGoogHeaders, hds...)
798 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
799 opts = append((*c.CallOptions).DeleteCatalog[0:len((*c.CallOptions).DeleteCatalog):len((*c.CallOptions).DeleteCatalog)], opts...)
800 var resp *biglakepb.Catalog
801 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
802 var err error
803 resp, err = c.metastoreClient.DeleteCatalog(ctx, req, settings.GRPC...)
804 return err
805 }, opts...)
806 if err != nil {
807 return nil, err
808 }
809 return resp, nil
810 }
811
812 func (c *metastoreGRPCClient) GetCatalog(ctx context.Context, req *biglakepb.GetCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
813 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
814
815 hds = append(c.xGoogHeaders, hds...)
816 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
817 opts = append((*c.CallOptions).GetCatalog[0:len((*c.CallOptions).GetCatalog):len((*c.CallOptions).GetCatalog)], opts...)
818 var resp *biglakepb.Catalog
819 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
820 var err error
821 resp, err = c.metastoreClient.GetCatalog(ctx, req, settings.GRPC...)
822 return err
823 }, opts...)
824 if err != nil {
825 return nil, err
826 }
827 return resp, nil
828 }
829
830 func (c *metastoreGRPCClient) ListCatalogs(ctx context.Context, req *biglakepb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator {
831 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
832
833 hds = append(c.xGoogHeaders, hds...)
834 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
835 opts = append((*c.CallOptions).ListCatalogs[0:len((*c.CallOptions).ListCatalogs):len((*c.CallOptions).ListCatalogs)], opts...)
836 it := &CatalogIterator{}
837 req = proto.Clone(req).(*biglakepb.ListCatalogsRequest)
838 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Catalog, string, error) {
839 resp := &biglakepb.ListCatalogsResponse{}
840 if pageToken != "" {
841 req.PageToken = pageToken
842 }
843 if pageSize > math.MaxInt32 {
844 req.PageSize = math.MaxInt32
845 } else if pageSize != 0 {
846 req.PageSize = int32(pageSize)
847 }
848 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
849 var err error
850 resp, err = c.metastoreClient.ListCatalogs(ctx, req, settings.GRPC...)
851 return err
852 }, opts...)
853 if err != nil {
854 return nil, "", err
855 }
856
857 it.Response = resp
858 return resp.GetCatalogs(), resp.GetNextPageToken(), nil
859 }
860 fetch := func(pageSize int, pageToken string) (string, error) {
861 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
862 if err != nil {
863 return "", err
864 }
865 it.items = append(it.items, items...)
866 return nextPageToken, nil
867 }
868
869 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
870 it.pageInfo.MaxSize = int(req.GetPageSize())
871 it.pageInfo.Token = req.GetPageToken()
872
873 return it
874 }
875
876 func (c *metastoreGRPCClient) CreateDatabase(ctx context.Context, req *biglakepb.CreateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
877 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
878
879 hds = append(c.xGoogHeaders, hds...)
880 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
881 opts = append((*c.CallOptions).CreateDatabase[0:len((*c.CallOptions).CreateDatabase):len((*c.CallOptions).CreateDatabase)], opts...)
882 var resp *biglakepb.Database
883 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
884 var err error
885 resp, err = c.metastoreClient.CreateDatabase(ctx, req, settings.GRPC...)
886 return err
887 }, opts...)
888 if err != nil {
889 return nil, err
890 }
891 return resp, nil
892 }
893
894 func (c *metastoreGRPCClient) DeleteDatabase(ctx context.Context, req *biglakepb.DeleteDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
895 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
896
897 hds = append(c.xGoogHeaders, hds...)
898 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
899 opts = append((*c.CallOptions).DeleteDatabase[0:len((*c.CallOptions).DeleteDatabase):len((*c.CallOptions).DeleteDatabase)], opts...)
900 var resp *biglakepb.Database
901 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
902 var err error
903 resp, err = c.metastoreClient.DeleteDatabase(ctx, req, settings.GRPC...)
904 return err
905 }, opts...)
906 if err != nil {
907 return nil, err
908 }
909 return resp, nil
910 }
911
912 func (c *metastoreGRPCClient) UpdateDatabase(ctx context.Context, req *biglakepb.UpdateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
913 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "database.name", url.QueryEscape(req.GetDatabase().GetName()))}
914
915 hds = append(c.xGoogHeaders, hds...)
916 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
917 opts = append((*c.CallOptions).UpdateDatabase[0:len((*c.CallOptions).UpdateDatabase):len((*c.CallOptions).UpdateDatabase)], opts...)
918 var resp *biglakepb.Database
919 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
920 var err error
921 resp, err = c.metastoreClient.UpdateDatabase(ctx, req, settings.GRPC...)
922 return err
923 }, opts...)
924 if err != nil {
925 return nil, err
926 }
927 return resp, nil
928 }
929
930 func (c *metastoreGRPCClient) GetDatabase(ctx context.Context, req *biglakepb.GetDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
931 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
932
933 hds = append(c.xGoogHeaders, hds...)
934 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
935 opts = append((*c.CallOptions).GetDatabase[0:len((*c.CallOptions).GetDatabase):len((*c.CallOptions).GetDatabase)], opts...)
936 var resp *biglakepb.Database
937 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
938 var err error
939 resp, err = c.metastoreClient.GetDatabase(ctx, req, settings.GRPC...)
940 return err
941 }, opts...)
942 if err != nil {
943 return nil, err
944 }
945 return resp, nil
946 }
947
948 func (c *metastoreGRPCClient) ListDatabases(ctx context.Context, req *biglakepb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator {
949 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
950
951 hds = append(c.xGoogHeaders, hds...)
952 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
953 opts = append((*c.CallOptions).ListDatabases[0:len((*c.CallOptions).ListDatabases):len((*c.CallOptions).ListDatabases)], opts...)
954 it := &DatabaseIterator{}
955 req = proto.Clone(req).(*biglakepb.ListDatabasesRequest)
956 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Database, string, error) {
957 resp := &biglakepb.ListDatabasesResponse{}
958 if pageToken != "" {
959 req.PageToken = pageToken
960 }
961 if pageSize > math.MaxInt32 {
962 req.PageSize = math.MaxInt32
963 } else if pageSize != 0 {
964 req.PageSize = int32(pageSize)
965 }
966 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
967 var err error
968 resp, err = c.metastoreClient.ListDatabases(ctx, req, settings.GRPC...)
969 return err
970 }, opts...)
971 if err != nil {
972 return nil, "", err
973 }
974
975 it.Response = resp
976 return resp.GetDatabases(), resp.GetNextPageToken(), nil
977 }
978 fetch := func(pageSize int, pageToken string) (string, error) {
979 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
980 if err != nil {
981 return "", err
982 }
983 it.items = append(it.items, items...)
984 return nextPageToken, nil
985 }
986
987 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
988 it.pageInfo.MaxSize = int(req.GetPageSize())
989 it.pageInfo.Token = req.GetPageToken()
990
991 return it
992 }
993
994 func (c *metastoreGRPCClient) CreateTable(ctx context.Context, req *biglakepb.CreateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
995 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
996
997 hds = append(c.xGoogHeaders, hds...)
998 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
999 opts = append((*c.CallOptions).CreateTable[0:len((*c.CallOptions).CreateTable):len((*c.CallOptions).CreateTable)], opts...)
1000 var resp *biglakepb.Table
1001 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1002 var err error
1003 resp, err = c.metastoreClient.CreateTable(ctx, req, settings.GRPC...)
1004 return err
1005 }, opts...)
1006 if err != nil {
1007 return nil, err
1008 }
1009 return resp, nil
1010 }
1011
1012 func (c *metastoreGRPCClient) DeleteTable(ctx context.Context, req *biglakepb.DeleteTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1013 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1014
1015 hds = append(c.xGoogHeaders, hds...)
1016 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1017 opts = append((*c.CallOptions).DeleteTable[0:len((*c.CallOptions).DeleteTable):len((*c.CallOptions).DeleteTable)], opts...)
1018 var resp *biglakepb.Table
1019 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1020 var err error
1021 resp, err = c.metastoreClient.DeleteTable(ctx, req, settings.GRPC...)
1022 return err
1023 }, opts...)
1024 if err != nil {
1025 return nil, err
1026 }
1027 return resp, nil
1028 }
1029
1030 func (c *metastoreGRPCClient) UpdateTable(ctx context.Context, req *biglakepb.UpdateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1031 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "table.name", url.QueryEscape(req.GetTable().GetName()))}
1032
1033 hds = append(c.xGoogHeaders, hds...)
1034 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1035 opts = append((*c.CallOptions).UpdateTable[0:len((*c.CallOptions).UpdateTable):len((*c.CallOptions).UpdateTable)], opts...)
1036 var resp *biglakepb.Table
1037 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1038 var err error
1039 resp, err = c.metastoreClient.UpdateTable(ctx, req, settings.GRPC...)
1040 return err
1041 }, opts...)
1042 if err != nil {
1043 return nil, err
1044 }
1045 return resp, nil
1046 }
1047
1048 func (c *metastoreGRPCClient) RenameTable(ctx context.Context, req *biglakepb.RenameTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1049 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1050
1051 hds = append(c.xGoogHeaders, hds...)
1052 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1053 opts = append((*c.CallOptions).RenameTable[0:len((*c.CallOptions).RenameTable):len((*c.CallOptions).RenameTable)], opts...)
1054 var resp *biglakepb.Table
1055 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1056 var err error
1057 resp, err = c.metastoreClient.RenameTable(ctx, req, settings.GRPC...)
1058 return err
1059 }, opts...)
1060 if err != nil {
1061 return nil, err
1062 }
1063 return resp, nil
1064 }
1065
1066 func (c *metastoreGRPCClient) GetTable(ctx context.Context, req *biglakepb.GetTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1067 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1068
1069 hds = append(c.xGoogHeaders, hds...)
1070 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1071 opts = append((*c.CallOptions).GetTable[0:len((*c.CallOptions).GetTable):len((*c.CallOptions).GetTable)], opts...)
1072 var resp *biglakepb.Table
1073 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1074 var err error
1075 resp, err = c.metastoreClient.GetTable(ctx, req, settings.GRPC...)
1076 return err
1077 }, opts...)
1078 if err != nil {
1079 return nil, err
1080 }
1081 return resp, nil
1082 }
1083
1084 func (c *metastoreGRPCClient) ListTables(ctx context.Context, req *biglakepb.ListTablesRequest, opts ...gax.CallOption) *TableIterator {
1085 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1086
1087 hds = append(c.xGoogHeaders, hds...)
1088 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1089 opts = append((*c.CallOptions).ListTables[0:len((*c.CallOptions).ListTables):len((*c.CallOptions).ListTables)], opts...)
1090 it := &TableIterator{}
1091 req = proto.Clone(req).(*biglakepb.ListTablesRequest)
1092 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Table, string, error) {
1093 resp := &biglakepb.ListTablesResponse{}
1094 if pageToken != "" {
1095 req.PageToken = pageToken
1096 }
1097 if pageSize > math.MaxInt32 {
1098 req.PageSize = math.MaxInt32
1099 } else if pageSize != 0 {
1100 req.PageSize = int32(pageSize)
1101 }
1102 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1103 var err error
1104 resp, err = c.metastoreClient.ListTables(ctx, req, settings.GRPC...)
1105 return err
1106 }, opts...)
1107 if err != nil {
1108 return nil, "", err
1109 }
1110
1111 it.Response = resp
1112 return resp.GetTables(), resp.GetNextPageToken(), nil
1113 }
1114 fetch := func(pageSize int, pageToken string) (string, error) {
1115 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1116 if err != nil {
1117 return "", err
1118 }
1119 it.items = append(it.items, items...)
1120 return nextPageToken, nil
1121 }
1122
1123 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1124 it.pageInfo.MaxSize = int(req.GetPageSize())
1125 it.pageInfo.Token = req.GetPageToken()
1126
1127 return it
1128 }
1129
1130
1131 func (c *metastoreRESTClient) CreateCatalog(ctx context.Context, req *biglakepb.CreateCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
1132 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1133 body := req.GetCatalog()
1134 jsonReq, err := m.Marshal(body)
1135 if err != nil {
1136 return nil, err
1137 }
1138
1139 baseUrl, err := url.Parse(c.endpoint)
1140 if err != nil {
1141 return nil, err
1142 }
1143 baseUrl.Path += fmt.Sprintf("/v1/%v/catalogs", req.GetParent())
1144
1145 params := url.Values{}
1146 params.Add("$alt", "json;enum-encoding=int")
1147 params.Add("catalogId", fmt.Sprintf("%v", req.GetCatalogId()))
1148
1149 baseUrl.RawQuery = params.Encode()
1150
1151
1152 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1153
1154 hds = append(c.xGoogHeaders, hds...)
1155 hds = append(hds, "Content-Type", "application/json")
1156 headers := gax.BuildHeaders(ctx, hds...)
1157 opts = append((*c.CallOptions).CreateCatalog[0:len((*c.CallOptions).CreateCatalog):len((*c.CallOptions).CreateCatalog)], opts...)
1158 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1159 resp := &biglakepb.Catalog{}
1160 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1161 if settings.Path != "" {
1162 baseUrl.Path = settings.Path
1163 }
1164 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1165 if err != nil {
1166 return err
1167 }
1168 httpReq = httpReq.WithContext(ctx)
1169 httpReq.Header = headers
1170
1171 httpRsp, err := c.httpClient.Do(httpReq)
1172 if err != nil {
1173 return err
1174 }
1175 defer httpRsp.Body.Close()
1176
1177 if err = googleapi.CheckResponse(httpRsp); err != nil {
1178 return err
1179 }
1180
1181 buf, err := io.ReadAll(httpRsp.Body)
1182 if err != nil {
1183 return err
1184 }
1185
1186 if err := unm.Unmarshal(buf, resp); err != nil {
1187 return err
1188 }
1189
1190 return nil
1191 }, opts...)
1192 if e != nil {
1193 return nil, e
1194 }
1195 return resp, nil
1196 }
1197
1198
1199 func (c *metastoreRESTClient) DeleteCatalog(ctx context.Context, req *biglakepb.DeleteCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
1200 baseUrl, err := url.Parse(c.endpoint)
1201 if err != nil {
1202 return nil, err
1203 }
1204 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1205
1206 params := url.Values{}
1207 params.Add("$alt", "json;enum-encoding=int")
1208
1209 baseUrl.RawQuery = params.Encode()
1210
1211
1212 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1213
1214 hds = append(c.xGoogHeaders, hds...)
1215 hds = append(hds, "Content-Type", "application/json")
1216 headers := gax.BuildHeaders(ctx, hds...)
1217 opts = append((*c.CallOptions).DeleteCatalog[0:len((*c.CallOptions).DeleteCatalog):len((*c.CallOptions).DeleteCatalog)], opts...)
1218 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1219 resp := &biglakepb.Catalog{}
1220 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1221 if settings.Path != "" {
1222 baseUrl.Path = settings.Path
1223 }
1224 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1225 if err != nil {
1226 return err
1227 }
1228 httpReq = httpReq.WithContext(ctx)
1229 httpReq.Header = headers
1230
1231 httpRsp, err := c.httpClient.Do(httpReq)
1232 if err != nil {
1233 return err
1234 }
1235 defer httpRsp.Body.Close()
1236
1237 if err = googleapi.CheckResponse(httpRsp); err != nil {
1238 return err
1239 }
1240
1241 buf, err := io.ReadAll(httpRsp.Body)
1242 if err != nil {
1243 return err
1244 }
1245
1246 if err := unm.Unmarshal(buf, resp); err != nil {
1247 return err
1248 }
1249
1250 return nil
1251 }, opts...)
1252 if e != nil {
1253 return nil, e
1254 }
1255 return resp, nil
1256 }
1257
1258
1259 func (c *metastoreRESTClient) GetCatalog(ctx context.Context, req *biglakepb.GetCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
1260 baseUrl, err := url.Parse(c.endpoint)
1261 if err != nil {
1262 return nil, err
1263 }
1264 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1265
1266 params := url.Values{}
1267 params.Add("$alt", "json;enum-encoding=int")
1268
1269 baseUrl.RawQuery = params.Encode()
1270
1271
1272 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1273
1274 hds = append(c.xGoogHeaders, hds...)
1275 hds = append(hds, "Content-Type", "application/json")
1276 headers := gax.BuildHeaders(ctx, hds...)
1277 opts = append((*c.CallOptions).GetCatalog[0:len((*c.CallOptions).GetCatalog):len((*c.CallOptions).GetCatalog)], opts...)
1278 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1279 resp := &biglakepb.Catalog{}
1280 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1281 if settings.Path != "" {
1282 baseUrl.Path = settings.Path
1283 }
1284 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1285 if err != nil {
1286 return err
1287 }
1288 httpReq = httpReq.WithContext(ctx)
1289 httpReq.Header = headers
1290
1291 httpRsp, err := c.httpClient.Do(httpReq)
1292 if err != nil {
1293 return err
1294 }
1295 defer httpRsp.Body.Close()
1296
1297 if err = googleapi.CheckResponse(httpRsp); err != nil {
1298 return err
1299 }
1300
1301 buf, err := io.ReadAll(httpRsp.Body)
1302 if err != nil {
1303 return err
1304 }
1305
1306 if err := unm.Unmarshal(buf, resp); err != nil {
1307 return err
1308 }
1309
1310 return nil
1311 }, opts...)
1312 if e != nil {
1313 return nil, e
1314 }
1315 return resp, nil
1316 }
1317
1318
1319 func (c *metastoreRESTClient) ListCatalogs(ctx context.Context, req *biglakepb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator {
1320 it := &CatalogIterator{}
1321 req = proto.Clone(req).(*biglakepb.ListCatalogsRequest)
1322 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1323 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Catalog, string, error) {
1324 resp := &biglakepb.ListCatalogsResponse{}
1325 if pageToken != "" {
1326 req.PageToken = pageToken
1327 }
1328 if pageSize > math.MaxInt32 {
1329 req.PageSize = math.MaxInt32
1330 } else if pageSize != 0 {
1331 req.PageSize = int32(pageSize)
1332 }
1333 baseUrl, err := url.Parse(c.endpoint)
1334 if err != nil {
1335 return nil, "", err
1336 }
1337 baseUrl.Path += fmt.Sprintf("/v1/%v/catalogs", req.GetParent())
1338
1339 params := url.Values{}
1340 params.Add("$alt", "json;enum-encoding=int")
1341 if req.GetPageSize() != 0 {
1342 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1343 }
1344 if req.GetPageToken() != "" {
1345 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1346 }
1347
1348 baseUrl.RawQuery = params.Encode()
1349
1350
1351 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1352 headers := gax.BuildHeaders(ctx, hds...)
1353 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1354 if settings.Path != "" {
1355 baseUrl.Path = settings.Path
1356 }
1357 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1358 if err != nil {
1359 return err
1360 }
1361 httpReq.Header = headers
1362
1363 httpRsp, err := c.httpClient.Do(httpReq)
1364 if err != nil {
1365 return err
1366 }
1367 defer httpRsp.Body.Close()
1368
1369 if err = googleapi.CheckResponse(httpRsp); err != nil {
1370 return err
1371 }
1372
1373 buf, err := io.ReadAll(httpRsp.Body)
1374 if err != nil {
1375 return err
1376 }
1377
1378 if err := unm.Unmarshal(buf, resp); err != nil {
1379 return err
1380 }
1381
1382 return nil
1383 }, opts...)
1384 if e != nil {
1385 return nil, "", e
1386 }
1387 it.Response = resp
1388 return resp.GetCatalogs(), resp.GetNextPageToken(), nil
1389 }
1390
1391 fetch := func(pageSize int, pageToken string) (string, error) {
1392 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1393 if err != nil {
1394 return "", err
1395 }
1396 it.items = append(it.items, items...)
1397 return nextPageToken, nil
1398 }
1399
1400 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1401 it.pageInfo.MaxSize = int(req.GetPageSize())
1402 it.pageInfo.Token = req.GetPageToken()
1403
1404 return it
1405 }
1406
1407
1408 func (c *metastoreRESTClient) CreateDatabase(ctx context.Context, req *biglakepb.CreateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1409 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1410 body := req.GetDatabase()
1411 jsonReq, err := m.Marshal(body)
1412 if err != nil {
1413 return nil, err
1414 }
1415
1416 baseUrl, err := url.Parse(c.endpoint)
1417 if err != nil {
1418 return nil, err
1419 }
1420 baseUrl.Path += fmt.Sprintf("/v1/%v/databases", req.GetParent())
1421
1422 params := url.Values{}
1423 params.Add("$alt", "json;enum-encoding=int")
1424 params.Add("databaseId", fmt.Sprintf("%v", req.GetDatabaseId()))
1425
1426 baseUrl.RawQuery = params.Encode()
1427
1428
1429 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1430
1431 hds = append(c.xGoogHeaders, hds...)
1432 hds = append(hds, "Content-Type", "application/json")
1433 headers := gax.BuildHeaders(ctx, hds...)
1434 opts = append((*c.CallOptions).CreateDatabase[0:len((*c.CallOptions).CreateDatabase):len((*c.CallOptions).CreateDatabase)], opts...)
1435 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1436 resp := &biglakepb.Database{}
1437 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1438 if settings.Path != "" {
1439 baseUrl.Path = settings.Path
1440 }
1441 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1442 if err != nil {
1443 return err
1444 }
1445 httpReq = httpReq.WithContext(ctx)
1446 httpReq.Header = headers
1447
1448 httpRsp, err := c.httpClient.Do(httpReq)
1449 if err != nil {
1450 return err
1451 }
1452 defer httpRsp.Body.Close()
1453
1454 if err = googleapi.CheckResponse(httpRsp); err != nil {
1455 return err
1456 }
1457
1458 buf, err := io.ReadAll(httpRsp.Body)
1459 if err != nil {
1460 return err
1461 }
1462
1463 if err := unm.Unmarshal(buf, resp); err != nil {
1464 return err
1465 }
1466
1467 return nil
1468 }, opts...)
1469 if e != nil {
1470 return nil, e
1471 }
1472 return resp, nil
1473 }
1474
1475
1476 func (c *metastoreRESTClient) DeleteDatabase(ctx context.Context, req *biglakepb.DeleteDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1477 baseUrl, err := url.Parse(c.endpoint)
1478 if err != nil {
1479 return nil, err
1480 }
1481 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1482
1483 params := url.Values{}
1484 params.Add("$alt", "json;enum-encoding=int")
1485
1486 baseUrl.RawQuery = params.Encode()
1487
1488
1489 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1490
1491 hds = append(c.xGoogHeaders, hds...)
1492 hds = append(hds, "Content-Type", "application/json")
1493 headers := gax.BuildHeaders(ctx, hds...)
1494 opts = append((*c.CallOptions).DeleteDatabase[0:len((*c.CallOptions).DeleteDatabase):len((*c.CallOptions).DeleteDatabase)], opts...)
1495 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1496 resp := &biglakepb.Database{}
1497 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1498 if settings.Path != "" {
1499 baseUrl.Path = settings.Path
1500 }
1501 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1502 if err != nil {
1503 return err
1504 }
1505 httpReq = httpReq.WithContext(ctx)
1506 httpReq.Header = headers
1507
1508 httpRsp, err := c.httpClient.Do(httpReq)
1509 if err != nil {
1510 return err
1511 }
1512 defer httpRsp.Body.Close()
1513
1514 if err = googleapi.CheckResponse(httpRsp); err != nil {
1515 return err
1516 }
1517
1518 buf, err := io.ReadAll(httpRsp.Body)
1519 if err != nil {
1520 return err
1521 }
1522
1523 if err := unm.Unmarshal(buf, resp); err != nil {
1524 return err
1525 }
1526
1527 return nil
1528 }, opts...)
1529 if e != nil {
1530 return nil, e
1531 }
1532 return resp, nil
1533 }
1534
1535
1536 func (c *metastoreRESTClient) UpdateDatabase(ctx context.Context, req *biglakepb.UpdateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1537 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1538 body := req.GetDatabase()
1539 jsonReq, err := m.Marshal(body)
1540 if err != nil {
1541 return nil, err
1542 }
1543
1544 baseUrl, err := url.Parse(c.endpoint)
1545 if err != nil {
1546 return nil, err
1547 }
1548 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetDatabase().GetName())
1549
1550 params := url.Values{}
1551 params.Add("$alt", "json;enum-encoding=int")
1552 if req.GetUpdateMask() != nil {
1553 updateMask, err := protojson.Marshal(req.GetUpdateMask())
1554 if err != nil {
1555 return nil, err
1556 }
1557 params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
1558 }
1559
1560 baseUrl.RawQuery = params.Encode()
1561
1562
1563 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "database.name", url.QueryEscape(req.GetDatabase().GetName()))}
1564
1565 hds = append(c.xGoogHeaders, hds...)
1566 hds = append(hds, "Content-Type", "application/json")
1567 headers := gax.BuildHeaders(ctx, hds...)
1568 opts = append((*c.CallOptions).UpdateDatabase[0:len((*c.CallOptions).UpdateDatabase):len((*c.CallOptions).UpdateDatabase)], opts...)
1569 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1570 resp := &biglakepb.Database{}
1571 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1572 if settings.Path != "" {
1573 baseUrl.Path = settings.Path
1574 }
1575 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1576 if err != nil {
1577 return err
1578 }
1579 httpReq = httpReq.WithContext(ctx)
1580 httpReq.Header = headers
1581
1582 httpRsp, err := c.httpClient.Do(httpReq)
1583 if err != nil {
1584 return err
1585 }
1586 defer httpRsp.Body.Close()
1587
1588 if err = googleapi.CheckResponse(httpRsp); err != nil {
1589 return err
1590 }
1591
1592 buf, err := io.ReadAll(httpRsp.Body)
1593 if err != nil {
1594 return err
1595 }
1596
1597 if err := unm.Unmarshal(buf, resp); err != nil {
1598 return err
1599 }
1600
1601 return nil
1602 }, opts...)
1603 if e != nil {
1604 return nil, e
1605 }
1606 return resp, nil
1607 }
1608
1609
1610 func (c *metastoreRESTClient) GetDatabase(ctx context.Context, req *biglakepb.GetDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1611 baseUrl, err := url.Parse(c.endpoint)
1612 if err != nil {
1613 return nil, err
1614 }
1615 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1616
1617 params := url.Values{}
1618 params.Add("$alt", "json;enum-encoding=int")
1619
1620 baseUrl.RawQuery = params.Encode()
1621
1622
1623 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1624
1625 hds = append(c.xGoogHeaders, hds...)
1626 hds = append(hds, "Content-Type", "application/json")
1627 headers := gax.BuildHeaders(ctx, hds...)
1628 opts = append((*c.CallOptions).GetDatabase[0:len((*c.CallOptions).GetDatabase):len((*c.CallOptions).GetDatabase)], opts...)
1629 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1630 resp := &biglakepb.Database{}
1631 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1632 if settings.Path != "" {
1633 baseUrl.Path = settings.Path
1634 }
1635 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1636 if err != nil {
1637 return err
1638 }
1639 httpReq = httpReq.WithContext(ctx)
1640 httpReq.Header = headers
1641
1642 httpRsp, err := c.httpClient.Do(httpReq)
1643 if err != nil {
1644 return err
1645 }
1646 defer httpRsp.Body.Close()
1647
1648 if err = googleapi.CheckResponse(httpRsp); err != nil {
1649 return err
1650 }
1651
1652 buf, err := io.ReadAll(httpRsp.Body)
1653 if err != nil {
1654 return err
1655 }
1656
1657 if err := unm.Unmarshal(buf, resp); err != nil {
1658 return err
1659 }
1660
1661 return nil
1662 }, opts...)
1663 if e != nil {
1664 return nil, e
1665 }
1666 return resp, nil
1667 }
1668
1669
1670 func (c *metastoreRESTClient) ListDatabases(ctx context.Context, req *biglakepb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator {
1671 it := &DatabaseIterator{}
1672 req = proto.Clone(req).(*biglakepb.ListDatabasesRequest)
1673 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1674 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Database, string, error) {
1675 resp := &biglakepb.ListDatabasesResponse{}
1676 if pageToken != "" {
1677 req.PageToken = pageToken
1678 }
1679 if pageSize > math.MaxInt32 {
1680 req.PageSize = math.MaxInt32
1681 } else if pageSize != 0 {
1682 req.PageSize = int32(pageSize)
1683 }
1684 baseUrl, err := url.Parse(c.endpoint)
1685 if err != nil {
1686 return nil, "", err
1687 }
1688 baseUrl.Path += fmt.Sprintf("/v1/%v/databases", req.GetParent())
1689
1690 params := url.Values{}
1691 params.Add("$alt", "json;enum-encoding=int")
1692 if req.GetPageSize() != 0 {
1693 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1694 }
1695 if req.GetPageToken() != "" {
1696 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1697 }
1698
1699 baseUrl.RawQuery = params.Encode()
1700
1701
1702 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1703 headers := gax.BuildHeaders(ctx, hds...)
1704 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1705 if settings.Path != "" {
1706 baseUrl.Path = settings.Path
1707 }
1708 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1709 if err != nil {
1710 return err
1711 }
1712 httpReq.Header = headers
1713
1714 httpRsp, err := c.httpClient.Do(httpReq)
1715 if err != nil {
1716 return err
1717 }
1718 defer httpRsp.Body.Close()
1719
1720 if err = googleapi.CheckResponse(httpRsp); err != nil {
1721 return err
1722 }
1723
1724 buf, err := io.ReadAll(httpRsp.Body)
1725 if err != nil {
1726 return err
1727 }
1728
1729 if err := unm.Unmarshal(buf, resp); err != nil {
1730 return err
1731 }
1732
1733 return nil
1734 }, opts...)
1735 if e != nil {
1736 return nil, "", e
1737 }
1738 it.Response = resp
1739 return resp.GetDatabases(), resp.GetNextPageToken(), nil
1740 }
1741
1742 fetch := func(pageSize int, pageToken string) (string, error) {
1743 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1744 if err != nil {
1745 return "", err
1746 }
1747 it.items = append(it.items, items...)
1748 return nextPageToken, nil
1749 }
1750
1751 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1752 it.pageInfo.MaxSize = int(req.GetPageSize())
1753 it.pageInfo.Token = req.GetPageToken()
1754
1755 return it
1756 }
1757
1758
1759 func (c *metastoreRESTClient) CreateTable(ctx context.Context, req *biglakepb.CreateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1760 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1761 body := req.GetTable()
1762 jsonReq, err := m.Marshal(body)
1763 if err != nil {
1764 return nil, err
1765 }
1766
1767 baseUrl, err := url.Parse(c.endpoint)
1768 if err != nil {
1769 return nil, err
1770 }
1771 baseUrl.Path += fmt.Sprintf("/v1/%v/tables", req.GetParent())
1772
1773 params := url.Values{}
1774 params.Add("$alt", "json;enum-encoding=int")
1775 params.Add("tableId", fmt.Sprintf("%v", req.GetTableId()))
1776
1777 baseUrl.RawQuery = params.Encode()
1778
1779
1780 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1781
1782 hds = append(c.xGoogHeaders, hds...)
1783 hds = append(hds, "Content-Type", "application/json")
1784 headers := gax.BuildHeaders(ctx, hds...)
1785 opts = append((*c.CallOptions).CreateTable[0:len((*c.CallOptions).CreateTable):len((*c.CallOptions).CreateTable)], opts...)
1786 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1787 resp := &biglakepb.Table{}
1788 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1789 if settings.Path != "" {
1790 baseUrl.Path = settings.Path
1791 }
1792 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1793 if err != nil {
1794 return err
1795 }
1796 httpReq = httpReq.WithContext(ctx)
1797 httpReq.Header = headers
1798
1799 httpRsp, err := c.httpClient.Do(httpReq)
1800 if err != nil {
1801 return err
1802 }
1803 defer httpRsp.Body.Close()
1804
1805 if err = googleapi.CheckResponse(httpRsp); err != nil {
1806 return err
1807 }
1808
1809 buf, err := io.ReadAll(httpRsp.Body)
1810 if err != nil {
1811 return err
1812 }
1813
1814 if err := unm.Unmarshal(buf, resp); err != nil {
1815 return err
1816 }
1817
1818 return nil
1819 }, opts...)
1820 if e != nil {
1821 return nil, e
1822 }
1823 return resp, nil
1824 }
1825
1826
1827 func (c *metastoreRESTClient) DeleteTable(ctx context.Context, req *biglakepb.DeleteTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1828 baseUrl, err := url.Parse(c.endpoint)
1829 if err != nil {
1830 return nil, err
1831 }
1832 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1833
1834 params := url.Values{}
1835 params.Add("$alt", "json;enum-encoding=int")
1836
1837 baseUrl.RawQuery = params.Encode()
1838
1839
1840 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1841
1842 hds = append(c.xGoogHeaders, hds...)
1843 hds = append(hds, "Content-Type", "application/json")
1844 headers := gax.BuildHeaders(ctx, hds...)
1845 opts = append((*c.CallOptions).DeleteTable[0:len((*c.CallOptions).DeleteTable):len((*c.CallOptions).DeleteTable)], opts...)
1846 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1847 resp := &biglakepb.Table{}
1848 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1849 if settings.Path != "" {
1850 baseUrl.Path = settings.Path
1851 }
1852 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1853 if err != nil {
1854 return err
1855 }
1856 httpReq = httpReq.WithContext(ctx)
1857 httpReq.Header = headers
1858
1859 httpRsp, err := c.httpClient.Do(httpReq)
1860 if err != nil {
1861 return err
1862 }
1863 defer httpRsp.Body.Close()
1864
1865 if err = googleapi.CheckResponse(httpRsp); err != nil {
1866 return err
1867 }
1868
1869 buf, err := io.ReadAll(httpRsp.Body)
1870 if err != nil {
1871 return err
1872 }
1873
1874 if err := unm.Unmarshal(buf, resp); err != nil {
1875 return err
1876 }
1877
1878 return nil
1879 }, opts...)
1880 if e != nil {
1881 return nil, e
1882 }
1883 return resp, nil
1884 }
1885
1886
1887 func (c *metastoreRESTClient) UpdateTable(ctx context.Context, req *biglakepb.UpdateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1888 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1889 body := req.GetTable()
1890 jsonReq, err := m.Marshal(body)
1891 if err != nil {
1892 return nil, err
1893 }
1894
1895 baseUrl, err := url.Parse(c.endpoint)
1896 if err != nil {
1897 return nil, err
1898 }
1899 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetTable().GetName())
1900
1901 params := url.Values{}
1902 params.Add("$alt", "json;enum-encoding=int")
1903 if req.GetUpdateMask() != nil {
1904 updateMask, err := protojson.Marshal(req.GetUpdateMask())
1905 if err != nil {
1906 return nil, err
1907 }
1908 params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
1909 }
1910
1911 baseUrl.RawQuery = params.Encode()
1912
1913
1914 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "table.name", url.QueryEscape(req.GetTable().GetName()))}
1915
1916 hds = append(c.xGoogHeaders, hds...)
1917 hds = append(hds, "Content-Type", "application/json")
1918 headers := gax.BuildHeaders(ctx, hds...)
1919 opts = append((*c.CallOptions).UpdateTable[0:len((*c.CallOptions).UpdateTable):len((*c.CallOptions).UpdateTable)], opts...)
1920 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1921 resp := &biglakepb.Table{}
1922 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1923 if settings.Path != "" {
1924 baseUrl.Path = settings.Path
1925 }
1926 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1927 if err != nil {
1928 return err
1929 }
1930 httpReq = httpReq.WithContext(ctx)
1931 httpReq.Header = headers
1932
1933 httpRsp, err := c.httpClient.Do(httpReq)
1934 if err != nil {
1935 return err
1936 }
1937 defer httpRsp.Body.Close()
1938
1939 if err = googleapi.CheckResponse(httpRsp); err != nil {
1940 return err
1941 }
1942
1943 buf, err := io.ReadAll(httpRsp.Body)
1944 if err != nil {
1945 return err
1946 }
1947
1948 if err := unm.Unmarshal(buf, resp); err != nil {
1949 return err
1950 }
1951
1952 return nil
1953 }, opts...)
1954 if e != nil {
1955 return nil, e
1956 }
1957 return resp, nil
1958 }
1959
1960
1961 func (c *metastoreRESTClient) RenameTable(ctx context.Context, req *biglakepb.RenameTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1962 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1963 jsonReq, err := m.Marshal(req)
1964 if err != nil {
1965 return nil, err
1966 }
1967
1968 baseUrl, err := url.Parse(c.endpoint)
1969 if err != nil {
1970 return nil, err
1971 }
1972 baseUrl.Path += fmt.Sprintf("/v1/%v:rename", req.GetName())
1973
1974 params := url.Values{}
1975 params.Add("$alt", "json;enum-encoding=int")
1976
1977 baseUrl.RawQuery = params.Encode()
1978
1979
1980 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1981
1982 hds = append(c.xGoogHeaders, hds...)
1983 hds = append(hds, "Content-Type", "application/json")
1984 headers := gax.BuildHeaders(ctx, hds...)
1985 opts = append((*c.CallOptions).RenameTable[0:len((*c.CallOptions).RenameTable):len((*c.CallOptions).RenameTable)], opts...)
1986 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1987 resp := &biglakepb.Table{}
1988 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1989 if settings.Path != "" {
1990 baseUrl.Path = settings.Path
1991 }
1992 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1993 if err != nil {
1994 return err
1995 }
1996 httpReq = httpReq.WithContext(ctx)
1997 httpReq.Header = headers
1998
1999 httpRsp, err := c.httpClient.Do(httpReq)
2000 if err != nil {
2001 return err
2002 }
2003 defer httpRsp.Body.Close()
2004
2005 if err = googleapi.CheckResponse(httpRsp); err != nil {
2006 return err
2007 }
2008
2009 buf, err := io.ReadAll(httpRsp.Body)
2010 if err != nil {
2011 return err
2012 }
2013
2014 if err := unm.Unmarshal(buf, resp); err != nil {
2015 return err
2016 }
2017
2018 return nil
2019 }, opts...)
2020 if e != nil {
2021 return nil, e
2022 }
2023 return resp, nil
2024 }
2025
2026
2027 func (c *metastoreRESTClient) GetTable(ctx context.Context, req *biglakepb.GetTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
2028 baseUrl, err := url.Parse(c.endpoint)
2029 if err != nil {
2030 return nil, err
2031 }
2032 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2033
2034 params := url.Values{}
2035 params.Add("$alt", "json;enum-encoding=int")
2036
2037 baseUrl.RawQuery = params.Encode()
2038
2039
2040 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2041
2042 hds = append(c.xGoogHeaders, hds...)
2043 hds = append(hds, "Content-Type", "application/json")
2044 headers := gax.BuildHeaders(ctx, hds...)
2045 opts = append((*c.CallOptions).GetTable[0:len((*c.CallOptions).GetTable):len((*c.CallOptions).GetTable)], opts...)
2046 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2047 resp := &biglakepb.Table{}
2048 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2049 if settings.Path != "" {
2050 baseUrl.Path = settings.Path
2051 }
2052 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2053 if err != nil {
2054 return err
2055 }
2056 httpReq = httpReq.WithContext(ctx)
2057 httpReq.Header = headers
2058
2059 httpRsp, err := c.httpClient.Do(httpReq)
2060 if err != nil {
2061 return err
2062 }
2063 defer httpRsp.Body.Close()
2064
2065 if err = googleapi.CheckResponse(httpRsp); err != nil {
2066 return err
2067 }
2068
2069 buf, err := io.ReadAll(httpRsp.Body)
2070 if err != nil {
2071 return err
2072 }
2073
2074 if err := unm.Unmarshal(buf, resp); err != nil {
2075 return err
2076 }
2077
2078 return nil
2079 }, opts...)
2080 if e != nil {
2081 return nil, e
2082 }
2083 return resp, nil
2084 }
2085
2086
2087 func (c *metastoreRESTClient) ListTables(ctx context.Context, req *biglakepb.ListTablesRequest, opts ...gax.CallOption) *TableIterator {
2088 it := &TableIterator{}
2089 req = proto.Clone(req).(*biglakepb.ListTablesRequest)
2090 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2091 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Table, string, error) {
2092 resp := &biglakepb.ListTablesResponse{}
2093 if pageToken != "" {
2094 req.PageToken = pageToken
2095 }
2096 if pageSize > math.MaxInt32 {
2097 req.PageSize = math.MaxInt32
2098 } else if pageSize != 0 {
2099 req.PageSize = int32(pageSize)
2100 }
2101 baseUrl, err := url.Parse(c.endpoint)
2102 if err != nil {
2103 return nil, "", err
2104 }
2105 baseUrl.Path += fmt.Sprintf("/v1/%v/tables", req.GetParent())
2106
2107 params := url.Values{}
2108 params.Add("$alt", "json;enum-encoding=int")
2109 if req.GetPageSize() != 0 {
2110 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2111 }
2112 if req.GetPageToken() != "" {
2113 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2114 }
2115 if req.GetView() != 0 {
2116 params.Add("view", fmt.Sprintf("%v", req.GetView()))
2117 }
2118
2119 baseUrl.RawQuery = params.Encode()
2120
2121
2122 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2123 headers := gax.BuildHeaders(ctx, hds...)
2124 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2125 if settings.Path != "" {
2126 baseUrl.Path = settings.Path
2127 }
2128 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2129 if err != nil {
2130 return err
2131 }
2132 httpReq.Header = headers
2133
2134 httpRsp, err := c.httpClient.Do(httpReq)
2135 if err != nil {
2136 return err
2137 }
2138 defer httpRsp.Body.Close()
2139
2140 if err = googleapi.CheckResponse(httpRsp); err != nil {
2141 return err
2142 }
2143
2144 buf, err := io.ReadAll(httpRsp.Body)
2145 if err != nil {
2146 return err
2147 }
2148
2149 if err := unm.Unmarshal(buf, resp); err != nil {
2150 return err
2151 }
2152
2153 return nil
2154 }, opts...)
2155 if e != nil {
2156 return nil, "", e
2157 }
2158 it.Response = resp
2159 return resp.GetTables(), resp.GetNextPageToken(), nil
2160 }
2161
2162 fetch := func(pageSize int, pageToken string) (string, error) {
2163 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2164 if err != nil {
2165 return "", err
2166 }
2167 it.items = append(it.items, items...)
2168 return nextPageToken, nil
2169 }
2170
2171 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2172 it.pageInfo.MaxSize = int(req.GetPageSize())
2173 it.pageInfo.Token = req.GetPageToken()
2174
2175 return it
2176 }
2177
View as plain text