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