Debian Codegraph @

bigquery/biglake/apiv1alpha1/metastore_client.go

raw
1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package biglake
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
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/iterator"
32 "google.golang.org/api/option"
33 "google.golang.org/api/option/internaloption"
34 gtransport "google.golang.org/api/transport/grpc"
35 httptransport "google.golang.org/api/transport/http"
36 "google.golang.org/grpc"
37 "google.golang.org/grpc/codes"
38 "google.golang.org/protobuf/encoding/protojson"
39 "google.golang.org/protobuf/proto"
40 )
41
42 var newMetastoreClientHook clientHook
43
44 // MetastoreCallOptions contains the retry settings for each method of MetastoreClient.
45 type MetastoreCallOptions struct {
46 CreateCatalog []gax.CallOption
47 DeleteCatalog []gax.CallOption
48 GetCatalog []gax.CallOption
49 ListCatalogs []gax.CallOption
50 CreateDatabase []gax.CallOption
51 DeleteDatabase []gax.CallOption
52 UpdateDatabase []gax.CallOption
53 GetDatabase []gax.CallOption
54 ListDatabases []gax.CallOption
55 CreateTable []gax.CallOption
56 DeleteTable []gax.CallOption
57 UpdateTable []gax.CallOption
58 RenameTable []gax.CallOption
59 GetTable []gax.CallOption
60 ListTables []gax.CallOption
61 CreateLock []gax.CallOption
62 DeleteLock []gax.CallOption
63 CheckLock []gax.CallOption
64 ListLocks []gax.CallOption
65 }
66
67 func defaultMetastoreGRPCClientOptions() []option.ClientOption {
68 return []option.ClientOption{
69 internaloption.WithDefaultEndpoint("biglake.googleapis.com:443"),
70 internaloption.WithDefaultEndpointTemplate("biglake.UNIVERSE_DOMAIN:443"),
71 internaloption.WithDefaultMTLSEndpoint("biglake.mtls.googleapis.com:443"),
72 internaloption.WithDefaultUniverseDomain("googleapis.com"),
73 internaloption.WithDefaultAudience("https://biglake.googleapis.com/"),
74 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
75 internaloption.EnableJwtWithScope(),
76 internaloption.EnableNewAuthLibrary(),
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 // internalMetastoreClient is an interface that defines the methods available from BigLake API.
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 // MetastoreClient is a client for interacting with BigLake API.
594 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
595 //
596 // BigLake Metastore is a serverless, highly available, multi-tenant runtime
597 // metastore for Google Cloud Data Analytics products.
598 //
599 // The BigLake Metastore API defines the following resource model:
600 //
601 // A collection of Google Cloud projects: /projects/*
602 //
603 // Each project has a collection of available locations: /locations/*
604 //
605 // Each location has a collection of catalogs: /catalogs/*
606 //
607 // Each catalog has a collection of databases: /databases/*
608 //
609 // Each database has a collection of tables: /tables/*
610 type MetastoreClient struct {
611 // The internal transport-dependent client.
612 internalClient internalMetastoreClient
613
614 // The call options for this service.
615 CallOptions *MetastoreCallOptions
616 }
617
618 // Wrapper methods routed to the internal client.
619
620 // Close closes the connection to the API service. The user should invoke this when
621 // the client is no longer required.
622 func (c *MetastoreClient) Close() error {
623 return c.internalClient.Close()
624 }
625
626 // setGoogleClientInfo sets the name and version of the application in
627 // the `x-goog-api-client` header passed on each request. Intended for
628 // use by Google-written clients.
629 func (c *MetastoreClient) setGoogleClientInfo(keyval ...string) {
630 c.internalClient.setGoogleClientInfo(keyval...)
631 }
632
633 // Connection returns a connection to the API service.
634 //
635 // Deprecated: Connections are now pooled so this method does not always
636 // return the same resource.
637 func (c *MetastoreClient) Connection() *grpc.ClientConn {
638 return c.internalClient.Connection()
639 }
640
641 // CreateCatalog creates a new catalog.
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 // DeleteCatalog deletes an existing catalog specified by the catalog ID.
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 // GetCatalog gets the catalog specified by the resource name.
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 // ListCatalogs list all catalogs in a specified project.
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 // CreateDatabase creates a new database.
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 // DeleteDatabase deletes an existing database specified by the database ID.
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 // UpdateDatabase updates an existing database specified by the database ID.
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 // GetDatabase gets the database specified by the resource name.
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 // ListDatabases list all databases in a specified catalog.
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 // CreateTable creates a new table.
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 // DeleteTable deletes an existing table specified by the table ID.
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 // UpdateTable updates an existing table specified by the table ID.
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 // RenameTable renames an existing table specified by the table ID.
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 // GetTable gets the table specified by the resource name.
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 // ListTables list all tables in a specified database.
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 // CreateLock creates a new lock.
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 // DeleteLock deletes an existing lock specified by the lock ID.
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 // CheckLock checks the state of a lock specified by the lock ID.
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 // ListLocks list all locks in a specified database.
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 // metastoreGRPCClient is a client for interacting with BigLake API over gRPC transport.
737 //
738 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
739 type metastoreGRPCClient struct {
740 // Connection pool of gRPC connections to the service.
741 connPool gtransport.ConnPool
742
743 // Points back to the CallOptions field of the containing MetastoreClient
744 CallOptions **MetastoreCallOptions
745
746 // The gRPC API client.
747 metastoreClient biglakepb.MetastoreServiceClient
748
749 // The x-goog-* metadata to be sent with each request.
750 xGoogHeaders []string
751
752 logger *slog.Logger
753 }
754
755 // NewMetastoreClient creates a new metastore service client based on gRPC.
756 // The returned client must be Closed when it is done being used to clean up its underlying connections.
757 //
758 // BigLake Metastore is a serverless, highly available, multi-tenant runtime
759 // metastore for Google Cloud Data Analytics products.
760 //
761 // The BigLake Metastore API defines the following resource model:
762 //
763 // A collection of Google Cloud projects: /projects/*
764 //
765 // Each project has a collection of available locations: /locations/*
766 //
767 // Each location has a collection of catalogs: /catalogs/*
768 //
769 // Each catalog has a collection of databases: /databases/*
770 //
771 // Each database has a collection of tables: /tables/*
772 func NewMetastoreClient(ctx context.Context, opts ...option.ClientOption) (*MetastoreClient, error) {
773 clientOpts := defaultMetastoreGRPCClientOptions()
774 if newMetastoreClientHook != nil {
775 hookOpts, err := newMetastoreClientHook(ctx, clientHookParams{})
776 if err != nil {
777 return nil, err
778 }
779 clientOpts = append(clientOpts, hookOpts...)
780 }
781
782 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
783 if err != nil {
784 return nil, err
785 }
786 client := MetastoreClient{CallOptions: defaultMetastoreCallOptions()}
787
788 c := &metastoreGRPCClient{
789 connPool: connPool,
790 metastoreClient: biglakepb.NewMetastoreServiceClient(connPool),
791 CallOptions: &client.CallOptions,
792 logger: internaloption.GetLogger(opts),
793 }
794 c.setGoogleClientInfo()
795
796 client.internalClient = c
797
798 return &client, nil
799 }
800
801 // Connection returns a connection to the API service.
802 //
803 // Deprecated: Connections are now pooled so this method does not always
804 // return the same resource.
805 func (c *metastoreGRPCClient) Connection() *grpc.ClientConn {
806 return c.connPool.Conn()
807 }
808
809 // setGoogleClientInfo sets the name and version of the application in
810 // the `x-goog-api-client` header passed on each request. Intended for
811 // use by Google-written clients.
812 func (c *metastoreGRPCClient) setGoogleClientInfo(keyval ...string) {
813 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
814 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
815 c.xGoogHeaders = []string{
816 "x-goog-api-client", gax.XGoogHeader(kv...),
817 }
818 }
819
820 // Close closes the connection to the API service. The user should invoke this when
821 // the client is no longer required.
822 func (c *metastoreGRPCClient) Close() error {
823 return c.connPool.Close()
824 }
825
826 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
827 type metastoreRESTClient struct {
828 // The http endpoint to connect to.
829 endpoint string
830
831 // The http client.
832 httpClient *http.Client
833
834 // The x-goog-* headers to be sent with each request.
835 xGoogHeaders []string
836
837 // Points back to the CallOptions field of the containing MetastoreClient
838 CallOptions **MetastoreCallOptions
839
840 logger *slog.Logger
841 }
842
843 // NewMetastoreRESTClient creates a new metastore service rest client.
844 //
845 // BigLake Metastore is a serverless, highly available, multi-tenant runtime
846 // metastore for Google Cloud Data Analytics products.
847 //
848 // The BigLake Metastore API defines the following resource model:
849 //
850 // A collection of Google Cloud projects: /projects/*
851 //
852 // Each project has a collection of available locations: /locations/*
853 //
854 // Each location has a collection of catalogs: /catalogs/*
855 //
856 // Each catalog has a collection of databases: /databases/*
857 //
858 // Each database has a collection of tables: /tables/*
859 func NewMetastoreRESTClient(ctx context.Context, opts ...option.ClientOption) (*MetastoreClient, error) {
860 clientOpts := append(defaultMetastoreRESTClientOptions(), opts...)
861 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
862 if err != nil {
863 return nil, err
864 }
865
866 callOpts := defaultMetastoreRESTCallOptions()
867 c := &metastoreRESTClient{
868 endpoint: endpoint,
869 httpClient: httpClient,
870 CallOptions: &callOpts,
871 logger: internaloption.GetLogger(opts),
872 }
873 c.setGoogleClientInfo()
874
875 return &MetastoreClient{internalClient: c, CallOptions: callOpts}, nil
876 }
877
878 func defaultMetastoreRESTClientOptions() []option.ClientOption {
879 return []option.ClientOption{
880 internaloption.WithDefaultEndpoint("https://biglake.googleapis.com"),
881 internaloption.WithDefaultEndpointTemplate("https://biglake.UNIVERSE_DOMAIN"),
882 internaloption.WithDefaultMTLSEndpoint("https://biglake.mtls.googleapis.com"),
883 internaloption.WithDefaultUniverseDomain("googleapis.com"),
884 internaloption.WithDefaultAudience("https://biglake.googleapis.com/"),
885 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
886 internaloption.EnableNewAuthLibrary(),
887 }
888 }
889
890 // setGoogleClientInfo sets the name and version of the application in
891 // the `x-goog-api-client` header passed on each request. Intended for
892 // use by Google-written clients.
893 func (c *metastoreRESTClient) setGoogleClientInfo(keyval ...string) {
894 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
895 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
896 c.xGoogHeaders = []string{
897 "x-goog-api-client", gax.XGoogHeader(kv...),
898 }
899 }
900
901 // Close closes the connection to the API service. The user should invoke this when
902 // the client is no longer required.
903 func (c *metastoreRESTClient) Close() error {
904 // Replace httpClient with nil to force cleanup.
905 c.httpClient = nil
906 return nil
907 }
908
909 // Connection returns a connection to the API service.
910 //
911 // Deprecated: This method always returns nil.
912 func (c *metastoreRESTClient) Connection() *grpc.ClientConn {
913 return nil
914 }
915 func (c *metastoreGRPCClient) CreateCatalog(ctx context.Context, req *biglakepb.CreateCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
916 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
917
918 hds = append(c.xGoogHeaders, hds...)
919 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
920 opts = append((*c.CallOptions).CreateCatalog[0:len((*c.CallOptions).CreateCatalog):len((*c.CallOptions).CreateCatalog)], opts...)
921 var resp *biglakepb.Catalog
922 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
923 var err error
924 resp, err = executeRPC(ctx, c.metastoreClient.CreateCatalog, req, settings.GRPC, c.logger, "CreateCatalog")
925 return err
926 }, opts...)
927 if err != nil {
928 return nil, err
929 }
930 return resp, nil
931 }
932
933 func (c *metastoreGRPCClient) DeleteCatalog(ctx context.Context, req *biglakepb.DeleteCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
934 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
935
936 hds = append(c.xGoogHeaders, hds...)
937 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
938 opts = append((*c.CallOptions).DeleteCatalog[0:len((*c.CallOptions).DeleteCatalog):len((*c.CallOptions).DeleteCatalog)], opts...)
939 var resp *biglakepb.Catalog
940 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
941 var err error
942 resp, err = executeRPC(ctx, c.metastoreClient.DeleteCatalog, req, settings.GRPC, c.logger, "DeleteCatalog")
943 return err
944 }, opts...)
945 if err != nil {
946 return nil, err
947 }
948 return resp, nil
949 }
950
951 func (c *metastoreGRPCClient) GetCatalog(ctx context.Context, req *biglakepb.GetCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
952 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
953
954 hds = append(c.xGoogHeaders, hds...)
955 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
956 opts = append((*c.CallOptions).GetCatalog[0:len((*c.CallOptions).GetCatalog):len((*c.CallOptions).GetCatalog)], opts...)
957 var resp *biglakepb.Catalog
958 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
959 var err error
960 resp, err = executeRPC(ctx, c.metastoreClient.GetCatalog, req, settings.GRPC, c.logger, "GetCatalog")
961 return err
962 }, opts...)
963 if err != nil {
964 return nil, err
965 }
966 return resp, nil
967 }
968
969 func (c *metastoreGRPCClient) ListCatalogs(ctx context.Context, req *biglakepb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator {
970 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
971
972 hds = append(c.xGoogHeaders, hds...)
973 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
974 opts = append((*c.CallOptions).ListCatalogs[0:len((*c.CallOptions).ListCatalogs):len((*c.CallOptions).ListCatalogs)], opts...)
975 it := &CatalogIterator{}
976 req = proto.Clone(req).(*biglakepb.ListCatalogsRequest)
977 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Catalog, string, error) {
978 resp := &biglakepb.ListCatalogsResponse{}
979 if pageToken != "" {
980 req.PageToken = pageToken
981 }
982 if pageSize > math.MaxInt32 {
983 req.PageSize = math.MaxInt32
984 } else if pageSize != 0 {
985 req.PageSize = int32(pageSize)
986 }
987 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
988 var err error
989 resp, err = executeRPC(ctx, c.metastoreClient.ListCatalogs, req, settings.GRPC, c.logger, "ListCatalogs")
990 return err
991 }, opts...)
992 if err != nil {
993 return nil, "", err
994 }
995
996 it.Response = resp
997 return resp.GetCatalogs(), resp.GetNextPageToken(), nil
998 }
999 fetch := func(pageSize int, pageToken string) (string, error) {
1000 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1001 if err != nil {
1002 return "", err
1003 }
1004 it.items = append(it.items, items...)
1005 return nextPageToken, nil
1006 }
1007
1008 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1009 it.pageInfo.MaxSize = int(req.GetPageSize())
1010 it.pageInfo.Token = req.GetPageToken()
1011
1012 return it
1013 }
1014
1015 func (c *metastoreGRPCClient) CreateDatabase(ctx context.Context, req *biglakepb.CreateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1016 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1017
1018 hds = append(c.xGoogHeaders, hds...)
1019 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1020 opts = append((*c.CallOptions).CreateDatabase[0:len((*c.CallOptions).CreateDatabase):len((*c.CallOptions).CreateDatabase)], opts...)
1021 var resp *biglakepb.Database
1022 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1023 var err error
1024 resp, err = executeRPC(ctx, c.metastoreClient.CreateDatabase, req, settings.GRPC, c.logger, "CreateDatabase")
1025 return err
1026 }, opts...)
1027 if err != nil {
1028 return nil, err
1029 }
1030 return resp, nil
1031 }
1032
1033 func (c *metastoreGRPCClient) DeleteDatabase(ctx context.Context, req *biglakepb.DeleteDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1034 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1035
1036 hds = append(c.xGoogHeaders, hds...)
1037 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1038 opts = append((*c.CallOptions).DeleteDatabase[0:len((*c.CallOptions).DeleteDatabase):len((*c.CallOptions).DeleteDatabase)], opts...)
1039 var resp *biglakepb.Database
1040 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1041 var err error
1042 resp, err = executeRPC(ctx, c.metastoreClient.DeleteDatabase, req, settings.GRPC, c.logger, "DeleteDatabase")
1043 return err
1044 }, opts...)
1045 if err != nil {
1046 return nil, err
1047 }
1048 return resp, nil
1049 }
1050
1051 func (c *metastoreGRPCClient) UpdateDatabase(ctx context.Context, req *biglakepb.UpdateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1052 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "database.name", url.QueryEscape(req.GetDatabase().GetName()))}
1053
1054 hds = append(c.xGoogHeaders, hds...)
1055 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1056 opts = append((*c.CallOptions).UpdateDatabase[0:len((*c.CallOptions).UpdateDatabase):len((*c.CallOptions).UpdateDatabase)], opts...)
1057 var resp *biglakepb.Database
1058 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1059 var err error
1060 resp, err = executeRPC(ctx, c.metastoreClient.UpdateDatabase, req, settings.GRPC, c.logger, "UpdateDatabase")
1061 return err
1062 }, opts...)
1063 if err != nil {
1064 return nil, err
1065 }
1066 return resp, nil
1067 }
1068
1069 func (c *metastoreGRPCClient) GetDatabase(ctx context.Context, req *biglakepb.GetDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1070 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1071
1072 hds = append(c.xGoogHeaders, hds...)
1073 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1074 opts = append((*c.CallOptions).GetDatabase[0:len((*c.CallOptions).GetDatabase):len((*c.CallOptions).GetDatabase)], opts...)
1075 var resp *biglakepb.Database
1076 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1077 var err error
1078 resp, err = executeRPC(ctx, c.metastoreClient.GetDatabase, req, settings.GRPC, c.logger, "GetDatabase")
1079 return err
1080 }, opts...)
1081 if err != nil {
1082 return nil, err
1083 }
1084 return resp, nil
1085 }
1086
1087 func (c *metastoreGRPCClient) ListDatabases(ctx context.Context, req *biglakepb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator {
1088 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1089
1090 hds = append(c.xGoogHeaders, hds...)
1091 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1092 opts = append((*c.CallOptions).ListDatabases[0:len((*c.CallOptions).ListDatabases):len((*c.CallOptions).ListDatabases)], opts...)
1093 it := &DatabaseIterator{}
1094 req = proto.Clone(req).(*biglakepb.ListDatabasesRequest)
1095 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Database, string, error) {
1096 resp := &biglakepb.ListDatabasesResponse{}
1097 if pageToken != "" {
1098 req.PageToken = pageToken
1099 }
1100 if pageSize > math.MaxInt32 {
1101 req.PageSize = math.MaxInt32
1102 } else if pageSize != 0 {
1103 req.PageSize = int32(pageSize)
1104 }
1105 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1106 var err error
1107 resp, err = executeRPC(ctx, c.metastoreClient.ListDatabases, req, settings.GRPC, c.logger, "ListDatabases")
1108 return err
1109 }, opts...)
1110 if err != nil {
1111 return nil, "", err
1112 }
1113
1114 it.Response = resp
1115 return resp.GetDatabases(), resp.GetNextPageToken(), nil
1116 }
1117 fetch := func(pageSize int, pageToken string) (string, error) {
1118 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1119 if err != nil {
1120 return "", err
1121 }
1122 it.items = append(it.items, items...)
1123 return nextPageToken, nil
1124 }
1125
1126 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1127 it.pageInfo.MaxSize = int(req.GetPageSize())
1128 it.pageInfo.Token = req.GetPageToken()
1129
1130 return it
1131 }
1132
1133 func (c *metastoreGRPCClient) CreateTable(ctx context.Context, req *biglakepb.CreateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1134 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1135
1136 hds = append(c.xGoogHeaders, hds...)
1137 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1138 opts = append((*c.CallOptions).CreateTable[0:len((*c.CallOptions).CreateTable):len((*c.CallOptions).CreateTable)], opts...)
1139 var resp *biglakepb.Table
1140 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1141 var err error
1142 resp, err = executeRPC(ctx, c.metastoreClient.CreateTable, req, settings.GRPC, c.logger, "CreateTable")
1143 return err
1144 }, opts...)
1145 if err != nil {
1146 return nil, err
1147 }
1148 return resp, nil
1149 }
1150
1151 func (c *metastoreGRPCClient) DeleteTable(ctx context.Context, req *biglakepb.DeleteTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1152 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1153
1154 hds = append(c.xGoogHeaders, hds...)
1155 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1156 opts = append((*c.CallOptions).DeleteTable[0:len((*c.CallOptions).DeleteTable):len((*c.CallOptions).DeleteTable)], opts...)
1157 var resp *biglakepb.Table
1158 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1159 var err error
1160 resp, err = executeRPC(ctx, c.metastoreClient.DeleteTable, req, settings.GRPC, c.logger, "DeleteTable")
1161 return err
1162 }, opts...)
1163 if err != nil {
1164 return nil, err
1165 }
1166 return resp, nil
1167 }
1168
1169 func (c *metastoreGRPCClient) UpdateTable(ctx context.Context, req *biglakepb.UpdateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1170 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "table.name", url.QueryEscape(req.GetTable().GetName()))}
1171
1172 hds = append(c.xGoogHeaders, hds...)
1173 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1174 opts = append((*c.CallOptions).UpdateTable[0:len((*c.CallOptions).UpdateTable):len((*c.CallOptions).UpdateTable)], opts...)
1175 var resp *biglakepb.Table
1176 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1177 var err error
1178 resp, err = executeRPC(ctx, c.metastoreClient.UpdateTable, req, settings.GRPC, c.logger, "UpdateTable")
1179 return err
1180 }, opts...)
1181 if err != nil {
1182 return nil, err
1183 }
1184 return resp, nil
1185 }
1186
1187 func (c *metastoreGRPCClient) RenameTable(ctx context.Context, req *biglakepb.RenameTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1188 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1189
1190 hds = append(c.xGoogHeaders, hds...)
1191 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1192 opts = append((*c.CallOptions).RenameTable[0:len((*c.CallOptions).RenameTable):len((*c.CallOptions).RenameTable)], opts...)
1193 var resp *biglakepb.Table
1194 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1195 var err error
1196 resp, err = executeRPC(ctx, c.metastoreClient.RenameTable, req, settings.GRPC, c.logger, "RenameTable")
1197 return err
1198 }, opts...)
1199 if err != nil {
1200 return nil, err
1201 }
1202 return resp, nil
1203 }
1204
1205 func (c *metastoreGRPCClient) GetTable(ctx context.Context, req *biglakepb.GetTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1206 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1207
1208 hds = append(c.xGoogHeaders, hds...)
1209 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1210 opts = append((*c.CallOptions).GetTable[0:len((*c.CallOptions).GetTable):len((*c.CallOptions).GetTable)], opts...)
1211 var resp *biglakepb.Table
1212 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1213 var err error
1214 resp, err = executeRPC(ctx, c.metastoreClient.GetTable, req, settings.GRPC, c.logger, "GetTable")
1215 return err
1216 }, opts...)
1217 if err != nil {
1218 return nil, err
1219 }
1220 return resp, nil
1221 }
1222
1223 func (c *metastoreGRPCClient) ListTables(ctx context.Context, req *biglakepb.ListTablesRequest, opts ...gax.CallOption) *TableIterator {
1224 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1225
1226 hds = append(c.xGoogHeaders, hds...)
1227 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1228 opts = append((*c.CallOptions).ListTables[0:len((*c.CallOptions).ListTables):len((*c.CallOptions).ListTables)], opts...)
1229 it := &TableIterator{}
1230 req = proto.Clone(req).(*biglakepb.ListTablesRequest)
1231 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Table, string, error) {
1232 resp := &biglakepb.ListTablesResponse{}
1233 if pageToken != "" {
1234 req.PageToken = pageToken
1235 }
1236 if pageSize > math.MaxInt32 {
1237 req.PageSize = math.MaxInt32
1238 } else if pageSize != 0 {
1239 req.PageSize = int32(pageSize)
1240 }
1241 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1242 var err error
1243 resp, err = executeRPC(ctx, c.metastoreClient.ListTables, req, settings.GRPC, c.logger, "ListTables")
1244 return err
1245 }, opts...)
1246 if err != nil {
1247 return nil, "", err
1248 }
1249
1250 it.Response = resp
1251 return resp.GetTables(), resp.GetNextPageToken(), nil
1252 }
1253 fetch := func(pageSize int, pageToken string) (string, error) {
1254 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1255 if err != nil {
1256 return "", err
1257 }
1258 it.items = append(it.items, items...)
1259 return nextPageToken, nil
1260 }
1261
1262 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1263 it.pageInfo.MaxSize = int(req.GetPageSize())
1264 it.pageInfo.Token = req.GetPageToken()
1265
1266 return it
1267 }
1268
1269 func (c *metastoreGRPCClient) CreateLock(ctx context.Context, req *biglakepb.CreateLockRequest, opts ...gax.CallOption) (*biglakepb.Lock, error) {
1270 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1271
1272 hds = append(c.xGoogHeaders, hds...)
1273 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1274 opts = append((*c.CallOptions).CreateLock[0:len((*c.CallOptions).CreateLock):len((*c.CallOptions).CreateLock)], opts...)
1275 var resp *biglakepb.Lock
1276 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1277 var err error
1278 resp, err = executeRPC(ctx, c.metastoreClient.CreateLock, req, settings.GRPC, c.logger, "CreateLock")
1279 return err
1280 }, opts...)
1281 if err != nil {
1282 return nil, err
1283 }
1284 return resp, nil
1285 }
1286
1287 func (c *metastoreGRPCClient) DeleteLock(ctx context.Context, req *biglakepb.DeleteLockRequest, opts ...gax.CallOption) error {
1288 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1289
1290 hds = append(c.xGoogHeaders, hds...)
1291 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1292 opts = append((*c.CallOptions).DeleteLock[0:len((*c.CallOptions).DeleteLock):len((*c.CallOptions).DeleteLock)], opts...)
1293 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1294 var err error
1295 _, err = executeRPC(ctx, c.metastoreClient.DeleteLock, req, settings.GRPC, c.logger, "DeleteLock")
1296 return err
1297 }, opts...)
1298 return err
1299 }
1300
1301 func (c *metastoreGRPCClient) CheckLock(ctx context.Context, req *biglakepb.CheckLockRequest, opts ...gax.CallOption) (*biglakepb.Lock, error) {
1302 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1303
1304 hds = append(c.xGoogHeaders, hds...)
1305 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1306 opts = append((*c.CallOptions).CheckLock[0:len((*c.CallOptions).CheckLock):len((*c.CallOptions).CheckLock)], opts...)
1307 var resp *biglakepb.Lock
1308 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1309 var err error
1310 resp, err = executeRPC(ctx, c.metastoreClient.CheckLock, req, settings.GRPC, c.logger, "CheckLock")
1311 return err
1312 }, opts...)
1313 if err != nil {
1314 return nil, err
1315 }
1316 return resp, nil
1317 }
1318
1319 func (c *metastoreGRPCClient) ListLocks(ctx context.Context, req *biglakepb.ListLocksRequest, opts ...gax.CallOption) *LockIterator {
1320 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1321
1322 hds = append(c.xGoogHeaders, hds...)
1323 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1324 opts = append((*c.CallOptions).ListLocks[0:len((*c.CallOptions).ListLocks):len((*c.CallOptions).ListLocks)], opts...)
1325 it := &LockIterator{}
1326 req = proto.Clone(req).(*biglakepb.ListLocksRequest)
1327 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Lock, string, error) {
1328 resp := &biglakepb.ListLocksResponse{}
1329 if pageToken != "" {
1330 req.PageToken = pageToken
1331 }
1332 if pageSize > math.MaxInt32 {
1333 req.PageSize = math.MaxInt32
1334 } else if pageSize != 0 {
1335 req.PageSize = int32(pageSize)
1336 }
1337 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1338 var err error
1339 resp, err = executeRPC(ctx, c.metastoreClient.ListLocks, req, settings.GRPC, c.logger, "ListLocks")
1340 return err
1341 }, opts...)
1342 if err != nil {
1343 return nil, "", err
1344 }
1345
1346 it.Response = resp
1347 return resp.GetLocks(), resp.GetNextPageToken(), nil
1348 }
1349 fetch := func(pageSize int, pageToken string) (string, error) {
1350 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1351 if err != nil {
1352 return "", err
1353 }
1354 it.items = append(it.items, items...)
1355 return nextPageToken, nil
1356 }
1357
1358 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1359 it.pageInfo.MaxSize = int(req.GetPageSize())
1360 it.pageInfo.Token = req.GetPageToken()
1361
1362 return it
1363 }
1364
1365 // CreateCatalog creates a new catalog.
1366 func (c *metastoreRESTClient) CreateCatalog(ctx context.Context, req *biglakepb.CreateCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
1367 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1368 body := req.GetCatalog()
1369 jsonReq, err := m.Marshal(body)
1370 if err != nil {
1371 return nil, err
1372 }
1373
1374 baseUrl, err := url.Parse(c.endpoint)
1375 if err != nil {
1376 return nil, err
1377 }
1378 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v/catalogs", req.GetParent())
1379
1380 params := url.Values{}
1381 params.Add("$alt", "json;enum-encoding=int")
1382 params.Add("catalogId", fmt.Sprintf("%v", req.GetCatalogId()))
1383
1384 baseUrl.RawQuery = params.Encode()
1385
1386 // Build HTTP headers from client and context metadata.
1387 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1388
1389 hds = append(c.xGoogHeaders, hds...)
1390 hds = append(hds, "Content-Type", "application/json")
1391 headers := gax.BuildHeaders(ctx, hds...)
1392 opts = append((*c.CallOptions).CreateCatalog[0:len((*c.CallOptions).CreateCatalog):len((*c.CallOptions).CreateCatalog)], opts...)
1393 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1394 resp := &biglakepb.Catalog{}
1395 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1396 if settings.Path != "" {
1397 baseUrl.Path = settings.Path
1398 }
1399 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1400 if err != nil {
1401 return err
1402 }
1403 httpReq = httpReq.WithContext(ctx)
1404 httpReq.Header = headers
1405
1406 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateCatalog")
1407 if err != nil {
1408 return err
1409 }
1410
1411 if err := unm.Unmarshal(buf, resp); err != nil {
1412 return err
1413 }
1414
1415 return nil
1416 }, opts...)
1417 if e != nil {
1418 return nil, e
1419 }
1420 return resp, nil
1421 }
1422
1423 // DeleteCatalog deletes an existing catalog specified by the catalog ID.
1424 func (c *metastoreRESTClient) DeleteCatalog(ctx context.Context, req *biglakepb.DeleteCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
1425 baseUrl, err := url.Parse(c.endpoint)
1426 if err != nil {
1427 return nil, err
1428 }
1429 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetName())
1430
1431 params := url.Values{}
1432 params.Add("$alt", "json;enum-encoding=int")
1433
1434 baseUrl.RawQuery = params.Encode()
1435
1436 // Build HTTP headers from client and context metadata.
1437 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1438
1439 hds = append(c.xGoogHeaders, hds...)
1440 hds = append(hds, "Content-Type", "application/json")
1441 headers := gax.BuildHeaders(ctx, hds...)
1442 opts = append((*c.CallOptions).DeleteCatalog[0:len((*c.CallOptions).DeleteCatalog):len((*c.CallOptions).DeleteCatalog)], opts...)
1443 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1444 resp := &biglakepb.Catalog{}
1445 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1446 if settings.Path != "" {
1447 baseUrl.Path = settings.Path
1448 }
1449 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1450 if err != nil {
1451 return err
1452 }
1453 httpReq = httpReq.WithContext(ctx)
1454 httpReq.Header = headers
1455
1456 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteCatalog")
1457 if err != nil {
1458 return err
1459 }
1460
1461 if err := unm.Unmarshal(buf, resp); err != nil {
1462 return err
1463 }
1464
1465 return nil
1466 }, opts...)
1467 if e != nil {
1468 return nil, e
1469 }
1470 return resp, nil
1471 }
1472
1473 // GetCatalog gets the catalog specified by the resource name.
1474 func (c *metastoreRESTClient) GetCatalog(ctx context.Context, req *biglakepb.GetCatalogRequest, opts ...gax.CallOption) (*biglakepb.Catalog, error) {
1475 baseUrl, err := url.Parse(c.endpoint)
1476 if err != nil {
1477 return nil, err
1478 }
1479 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetName())
1480
1481 params := url.Values{}
1482 params.Add("$alt", "json;enum-encoding=int")
1483
1484 baseUrl.RawQuery = params.Encode()
1485
1486 // Build HTTP headers from client and context metadata.
1487 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1488
1489 hds = append(c.xGoogHeaders, hds...)
1490 hds = append(hds, "Content-Type", "application/json")
1491 headers := gax.BuildHeaders(ctx, hds...)
1492 opts = append((*c.CallOptions).GetCatalog[0:len((*c.CallOptions).GetCatalog):len((*c.CallOptions).GetCatalog)], opts...)
1493 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1494 resp := &biglakepb.Catalog{}
1495 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1496 if settings.Path != "" {
1497 baseUrl.Path = settings.Path
1498 }
1499 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1500 if err != nil {
1501 return err
1502 }
1503 httpReq = httpReq.WithContext(ctx)
1504 httpReq.Header = headers
1505
1506 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetCatalog")
1507 if err != nil {
1508 return err
1509 }
1510
1511 if err := unm.Unmarshal(buf, resp); err != nil {
1512 return err
1513 }
1514
1515 return nil
1516 }, opts...)
1517 if e != nil {
1518 return nil, e
1519 }
1520 return resp, nil
1521 }
1522
1523 // ListCatalogs list all catalogs in a specified project.
1524 func (c *metastoreRESTClient) ListCatalogs(ctx context.Context, req *biglakepb.ListCatalogsRequest, opts ...gax.CallOption) *CatalogIterator {
1525 it := &CatalogIterator{}
1526 req = proto.Clone(req).(*biglakepb.ListCatalogsRequest)
1527 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1528 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Catalog, string, error) {
1529 resp := &biglakepb.ListCatalogsResponse{}
1530 if pageToken != "" {
1531 req.PageToken = pageToken
1532 }
1533 if pageSize > math.MaxInt32 {
1534 req.PageSize = math.MaxInt32
1535 } else if pageSize != 0 {
1536 req.PageSize = int32(pageSize)
1537 }
1538 baseUrl, err := url.Parse(c.endpoint)
1539 if err != nil {
1540 return nil, "", err
1541 }
1542 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v/catalogs", req.GetParent())
1543
1544 params := url.Values{}
1545 params.Add("$alt", "json;enum-encoding=int")
1546 if req.GetPageSize() != 0 {
1547 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1548 }
1549 if req.GetPageToken() != "" {
1550 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1551 }
1552
1553 baseUrl.RawQuery = params.Encode()
1554
1555 // Build HTTP headers from client and context metadata.
1556 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1557 headers := gax.BuildHeaders(ctx, hds...)
1558 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1559 if settings.Path != "" {
1560 baseUrl.Path = settings.Path
1561 }
1562 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1563 if err != nil {
1564 return err
1565 }
1566 httpReq.Header = headers
1567
1568 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListCatalogs")
1569 if err != nil {
1570 return err
1571 }
1572 if err := unm.Unmarshal(buf, resp); err != nil {
1573 return err
1574 }
1575
1576 return nil
1577 }, opts...)
1578 if e != nil {
1579 return nil, "", e
1580 }
1581 it.Response = resp
1582 return resp.GetCatalogs(), resp.GetNextPageToken(), nil
1583 }
1584
1585 fetch := func(pageSize int, pageToken string) (string, error) {
1586 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1587 if err != nil {
1588 return "", err
1589 }
1590 it.items = append(it.items, items...)
1591 return nextPageToken, nil
1592 }
1593
1594 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1595 it.pageInfo.MaxSize = int(req.GetPageSize())
1596 it.pageInfo.Token = req.GetPageToken()
1597
1598 return it
1599 }
1600
1601 // CreateDatabase creates a new database.
1602 func (c *metastoreRESTClient) CreateDatabase(ctx context.Context, req *biglakepb.CreateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1603 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1604 body := req.GetDatabase()
1605 jsonReq, err := m.Marshal(body)
1606 if err != nil {
1607 return nil, err
1608 }
1609
1610 baseUrl, err := url.Parse(c.endpoint)
1611 if err != nil {
1612 return nil, err
1613 }
1614 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v/databases", req.GetParent())
1615
1616 params := url.Values{}
1617 params.Add("$alt", "json;enum-encoding=int")
1618 params.Add("databaseId", fmt.Sprintf("%v", req.GetDatabaseId()))
1619
1620 baseUrl.RawQuery = params.Encode()
1621
1622 // Build HTTP headers from client and context metadata.
1623 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
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).CreateDatabase[0:len((*c.CallOptions).CreateDatabase):len((*c.CallOptions).CreateDatabase)], 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("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1636 if err != nil {
1637 return err
1638 }
1639 httpReq = httpReq.WithContext(ctx)
1640 httpReq.Header = headers
1641
1642 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateDatabase")
1643 if err != nil {
1644 return err
1645 }
1646
1647 if err := unm.Unmarshal(buf, resp); err != nil {
1648 return err
1649 }
1650
1651 return nil
1652 }, opts...)
1653 if e != nil {
1654 return nil, e
1655 }
1656 return resp, nil
1657 }
1658
1659 // DeleteDatabase deletes an existing database specified by the database ID.
1660 func (c *metastoreRESTClient) DeleteDatabase(ctx context.Context, req *biglakepb.DeleteDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1661 baseUrl, err := url.Parse(c.endpoint)
1662 if err != nil {
1663 return nil, err
1664 }
1665 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetName())
1666
1667 params := url.Values{}
1668 params.Add("$alt", "json;enum-encoding=int")
1669
1670 baseUrl.RawQuery = params.Encode()
1671
1672 // Build HTTP headers from client and context metadata.
1673 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1674
1675 hds = append(c.xGoogHeaders, hds...)
1676 hds = append(hds, "Content-Type", "application/json")
1677 headers := gax.BuildHeaders(ctx, hds...)
1678 opts = append((*c.CallOptions).DeleteDatabase[0:len((*c.CallOptions).DeleteDatabase):len((*c.CallOptions).DeleteDatabase)], opts...)
1679 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1680 resp := &biglakepb.Database{}
1681 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1682 if settings.Path != "" {
1683 baseUrl.Path = settings.Path
1684 }
1685 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1686 if err != nil {
1687 return err
1688 }
1689 httpReq = httpReq.WithContext(ctx)
1690 httpReq.Header = headers
1691
1692 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteDatabase")
1693 if err != nil {
1694 return err
1695 }
1696
1697 if err := unm.Unmarshal(buf, resp); err != nil {
1698 return err
1699 }
1700
1701 return nil
1702 }, opts...)
1703 if e != nil {
1704 return nil, e
1705 }
1706 return resp, nil
1707 }
1708
1709 // UpdateDatabase updates an existing database specified by the database ID.
1710 func (c *metastoreRESTClient) UpdateDatabase(ctx context.Context, req *biglakepb.UpdateDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1711 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1712 body := req.GetDatabase()
1713 jsonReq, err := m.Marshal(body)
1714 if err != nil {
1715 return nil, err
1716 }
1717
1718 baseUrl, err := url.Parse(c.endpoint)
1719 if err != nil {
1720 return nil, err
1721 }
1722 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetDatabase().GetName())
1723
1724 params := url.Values{}
1725 params.Add("$alt", "json;enum-encoding=int")
1726 if req.GetUpdateMask() != nil {
1727 field, err := protojson.Marshal(req.GetUpdateMask())
1728 if err != nil {
1729 return nil, err
1730 }
1731 params.Add("updateMask", string(field[1:len(field)-1]))
1732 }
1733
1734 baseUrl.RawQuery = params.Encode()
1735
1736 // Build HTTP headers from client and context metadata.
1737 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "database.name", url.QueryEscape(req.GetDatabase().GetName()))}
1738
1739 hds = append(c.xGoogHeaders, hds...)
1740 hds = append(hds, "Content-Type", "application/json")
1741 headers := gax.BuildHeaders(ctx, hds...)
1742 opts = append((*c.CallOptions).UpdateDatabase[0:len((*c.CallOptions).UpdateDatabase):len((*c.CallOptions).UpdateDatabase)], opts...)
1743 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1744 resp := &biglakepb.Database{}
1745 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1746 if settings.Path != "" {
1747 baseUrl.Path = settings.Path
1748 }
1749 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1750 if err != nil {
1751 return err
1752 }
1753 httpReq = httpReq.WithContext(ctx)
1754 httpReq.Header = headers
1755
1756 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateDatabase")
1757 if err != nil {
1758 return err
1759 }
1760
1761 if err := unm.Unmarshal(buf, resp); err != nil {
1762 return err
1763 }
1764
1765 return nil
1766 }, opts...)
1767 if e != nil {
1768 return nil, e
1769 }
1770 return resp, nil
1771 }
1772
1773 // GetDatabase gets the database specified by the resource name.
1774 func (c *metastoreRESTClient) GetDatabase(ctx context.Context, req *biglakepb.GetDatabaseRequest, opts ...gax.CallOption) (*biglakepb.Database, error) {
1775 baseUrl, err := url.Parse(c.endpoint)
1776 if err != nil {
1777 return nil, err
1778 }
1779 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetName())
1780
1781 params := url.Values{}
1782 params.Add("$alt", "json;enum-encoding=int")
1783
1784 baseUrl.RawQuery = params.Encode()
1785
1786 // Build HTTP headers from client and context metadata.
1787 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.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).GetDatabase[0:len((*c.CallOptions).GetDatabase):len((*c.CallOptions).GetDatabase)], 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("GET", baseUrl.String(), nil)
1800 if err != nil {
1801 return err
1802 }
1803 httpReq = httpReq.WithContext(ctx)
1804 httpReq.Header = headers
1805
1806 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDatabase")
1807 if err != nil {
1808 return err
1809 }
1810
1811 if err := unm.Unmarshal(buf, resp); err != nil {
1812 return err
1813 }
1814
1815 return nil
1816 }, opts...)
1817 if e != nil {
1818 return nil, e
1819 }
1820 return resp, nil
1821 }
1822
1823 // ListDatabases list all databases in a specified catalog.
1824 func (c *metastoreRESTClient) ListDatabases(ctx context.Context, req *biglakepb.ListDatabasesRequest, opts ...gax.CallOption) *DatabaseIterator {
1825 it := &DatabaseIterator{}
1826 req = proto.Clone(req).(*biglakepb.ListDatabasesRequest)
1827 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1828 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Database, string, error) {
1829 resp := &biglakepb.ListDatabasesResponse{}
1830 if pageToken != "" {
1831 req.PageToken = pageToken
1832 }
1833 if pageSize > math.MaxInt32 {
1834 req.PageSize = math.MaxInt32
1835 } else if pageSize != 0 {
1836 req.PageSize = int32(pageSize)
1837 }
1838 baseUrl, err := url.Parse(c.endpoint)
1839 if err != nil {
1840 return nil, "", err
1841 }
1842 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v/databases", req.GetParent())
1843
1844 params := url.Values{}
1845 params.Add("$alt", "json;enum-encoding=int")
1846 if req.GetPageSize() != 0 {
1847 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1848 }
1849 if req.GetPageToken() != "" {
1850 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1851 }
1852
1853 baseUrl.RawQuery = params.Encode()
1854
1855 // Build HTTP headers from client and context metadata.
1856 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1857 headers := gax.BuildHeaders(ctx, hds...)
1858 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1859 if settings.Path != "" {
1860 baseUrl.Path = settings.Path
1861 }
1862 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1863 if err != nil {
1864 return err
1865 }
1866 httpReq.Header = headers
1867
1868 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDatabases")
1869 if err != nil {
1870 return err
1871 }
1872 if err := unm.Unmarshal(buf, resp); err != nil {
1873 return err
1874 }
1875
1876 return nil
1877 }, opts...)
1878 if e != nil {
1879 return nil, "", e
1880 }
1881 it.Response = resp
1882 return resp.GetDatabases(), resp.GetNextPageToken(), nil
1883 }
1884
1885 fetch := func(pageSize int, pageToken string) (string, error) {
1886 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1887 if err != nil {
1888 return "", err
1889 }
1890 it.items = append(it.items, items...)
1891 return nextPageToken, nil
1892 }
1893
1894 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1895 it.pageInfo.MaxSize = int(req.GetPageSize())
1896 it.pageInfo.Token = req.GetPageToken()
1897
1898 return it
1899 }
1900
1901 // CreateTable creates a new table.
1902 func (c *metastoreRESTClient) CreateTable(ctx context.Context, req *biglakepb.CreateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1903 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1904 body := req.GetTable()
1905 jsonReq, err := m.Marshal(body)
1906 if err != nil {
1907 return nil, err
1908 }
1909
1910 baseUrl, err := url.Parse(c.endpoint)
1911 if err != nil {
1912 return nil, err
1913 }
1914 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v/tables", req.GetParent())
1915
1916 params := url.Values{}
1917 params.Add("$alt", "json;enum-encoding=int")
1918 params.Add("tableId", fmt.Sprintf("%v", req.GetTableId()))
1919
1920 baseUrl.RawQuery = params.Encode()
1921
1922 // Build HTTP headers from client and context metadata.
1923 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1924
1925 hds = append(c.xGoogHeaders, hds...)
1926 hds = append(hds, "Content-Type", "application/json")
1927 headers := gax.BuildHeaders(ctx, hds...)
1928 opts = append((*c.CallOptions).CreateTable[0:len((*c.CallOptions).CreateTable):len((*c.CallOptions).CreateTable)], opts...)
1929 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1930 resp := &biglakepb.Table{}
1931 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1932 if settings.Path != "" {
1933 baseUrl.Path = settings.Path
1934 }
1935 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1936 if err != nil {
1937 return err
1938 }
1939 httpReq = httpReq.WithContext(ctx)
1940 httpReq.Header = headers
1941
1942 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateTable")
1943 if err != nil {
1944 return err
1945 }
1946
1947 if err := unm.Unmarshal(buf, resp); err != nil {
1948 return err
1949 }
1950
1951 return nil
1952 }, opts...)
1953 if e != nil {
1954 return nil, e
1955 }
1956 return resp, nil
1957 }
1958
1959 // DeleteTable deletes an existing table specified by the table ID.
1960 func (c *metastoreRESTClient) DeleteTable(ctx context.Context, req *biglakepb.DeleteTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
1961 baseUrl, err := url.Parse(c.endpoint)
1962 if err != nil {
1963 return nil, err
1964 }
1965 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetName())
1966
1967 params := url.Values{}
1968 params.Add("$alt", "json;enum-encoding=int")
1969
1970 baseUrl.RawQuery = params.Encode()
1971
1972 // Build HTTP headers from client and context metadata.
1973 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1974
1975 hds = append(c.xGoogHeaders, hds...)
1976 hds = append(hds, "Content-Type", "application/json")
1977 headers := gax.BuildHeaders(ctx, hds...)
1978 opts = append((*c.CallOptions).DeleteTable[0:len((*c.CallOptions).DeleteTable):len((*c.CallOptions).DeleteTable)], opts...)
1979 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1980 resp := &biglakepb.Table{}
1981 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1982 if settings.Path != "" {
1983 baseUrl.Path = settings.Path
1984 }
1985 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1986 if err != nil {
1987 return err
1988 }
1989 httpReq = httpReq.WithContext(ctx)
1990 httpReq.Header = headers
1991
1992 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteTable")
1993 if err != nil {
1994 return err
1995 }
1996
1997 if err := unm.Unmarshal(buf, resp); err != nil {
1998 return err
1999 }
2000
2001 return nil
2002 }, opts...)
2003 if e != nil {
2004 return nil, e
2005 }
2006 return resp, nil
2007 }
2008
2009 // UpdateTable updates an existing table specified by the table ID.
2010 func (c *metastoreRESTClient) UpdateTable(ctx context.Context, req *biglakepb.UpdateTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
2011 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2012 body := req.GetTable()
2013 jsonReq, err := m.Marshal(body)
2014 if err != nil {
2015 return nil, err
2016 }
2017
2018 baseUrl, err := url.Parse(c.endpoint)
2019 if err != nil {
2020 return nil, err
2021 }
2022 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetTable().GetName())
2023
2024 params := url.Values{}
2025 params.Add("$alt", "json;enum-encoding=int")
2026 if req.GetUpdateMask() != nil {
2027 field, err := protojson.Marshal(req.GetUpdateMask())
2028 if err != nil {
2029 return nil, err
2030 }
2031 params.Add("updateMask", string(field[1:len(field)-1]))
2032 }
2033
2034 baseUrl.RawQuery = params.Encode()
2035
2036 // Build HTTP headers from client and context metadata.
2037 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "table.name", url.QueryEscape(req.GetTable().GetName()))}
2038
2039 hds = append(c.xGoogHeaders, hds...)
2040 hds = append(hds, "Content-Type", "application/json")
2041 headers := gax.BuildHeaders(ctx, hds...)
2042 opts = append((*c.CallOptions).UpdateTable[0:len((*c.CallOptions).UpdateTable):len((*c.CallOptions).UpdateTable)], opts...)
2043 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2044 resp := &biglakepb.Table{}
2045 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2046 if settings.Path != "" {
2047 baseUrl.Path = settings.Path
2048 }
2049 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2050 if err != nil {
2051 return err
2052 }
2053 httpReq = httpReq.WithContext(ctx)
2054 httpReq.Header = headers
2055
2056 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateTable")
2057 if err != nil {
2058 return err
2059 }
2060
2061 if err := unm.Unmarshal(buf, resp); err != nil {
2062 return err
2063 }
2064
2065 return nil
2066 }, opts...)
2067 if e != nil {
2068 return nil, e
2069 }
2070 return resp, nil
2071 }
2072
2073 // RenameTable renames an existing table specified by the table ID.
2074 func (c *metastoreRESTClient) RenameTable(ctx context.Context, req *biglakepb.RenameTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
2075 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2076 jsonReq, err := m.Marshal(req)
2077 if err != nil {
2078 return nil, err
2079 }
2080
2081 baseUrl, err := url.Parse(c.endpoint)
2082 if err != nil {
2083 return nil, err
2084 }
2085 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v:rename", req.GetName())
2086
2087 params := url.Values{}
2088 params.Add("$alt", "json;enum-encoding=int")
2089
2090 baseUrl.RawQuery = params.Encode()
2091
2092 // Build HTTP headers from client and context metadata.
2093 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2094
2095 hds = append(c.xGoogHeaders, hds...)
2096 hds = append(hds, "Content-Type", "application/json")
2097 headers := gax.BuildHeaders(ctx, hds...)
2098 opts = append((*c.CallOptions).RenameTable[0:len((*c.CallOptions).RenameTable):len((*c.CallOptions).RenameTable)], opts...)
2099 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2100 resp := &biglakepb.Table{}
2101 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2102 if settings.Path != "" {
2103 baseUrl.Path = settings.Path
2104 }
2105 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2106 if err != nil {
2107 return err
2108 }
2109 httpReq = httpReq.WithContext(ctx)
2110 httpReq.Header = headers
2111
2112 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RenameTable")
2113 if err != nil {
2114 return err
2115 }
2116
2117 if err := unm.Unmarshal(buf, resp); err != nil {
2118 return err
2119 }
2120
2121 return nil
2122 }, opts...)
2123 if e != nil {
2124 return nil, e
2125 }
2126 return resp, nil
2127 }
2128
2129 // GetTable gets the table specified by the resource name.
2130 func (c *metastoreRESTClient) GetTable(ctx context.Context, req *biglakepb.GetTableRequest, opts ...gax.CallOption) (*biglakepb.Table, error) {
2131 baseUrl, err := url.Parse(c.endpoint)
2132 if err != nil {
2133 return nil, err
2134 }
2135 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetName())
2136
2137 params := url.Values{}
2138 params.Add("$alt", "json;enum-encoding=int")
2139
2140 baseUrl.RawQuery = params.Encode()
2141
2142 // Build HTTP headers from client and context metadata.
2143 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2144
2145 hds = append(c.xGoogHeaders, hds...)
2146 hds = append(hds, "Content-Type", "application/json")
2147 headers := gax.BuildHeaders(ctx, hds...)
2148 opts = append((*c.CallOptions).GetTable[0:len((*c.CallOptions).GetTable):len((*c.CallOptions).GetTable)], opts...)
2149 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2150 resp := &biglakepb.Table{}
2151 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2152 if settings.Path != "" {
2153 baseUrl.Path = settings.Path
2154 }
2155 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2156 if err != nil {
2157 return err
2158 }
2159 httpReq = httpReq.WithContext(ctx)
2160 httpReq.Header = headers
2161
2162 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetTable")
2163 if err != nil {
2164 return err
2165 }
2166
2167 if err := unm.Unmarshal(buf, resp); err != nil {
2168 return err
2169 }
2170
2171 return nil
2172 }, opts...)
2173 if e != nil {
2174 return nil, e
2175 }
2176 return resp, nil
2177 }
2178
2179 // ListTables list all tables in a specified database.
2180 func (c *metastoreRESTClient) ListTables(ctx context.Context, req *biglakepb.ListTablesRequest, opts ...gax.CallOption) *TableIterator {
2181 it := &TableIterator{}
2182 req = proto.Clone(req).(*biglakepb.ListTablesRequest)
2183 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2184 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Table, string, error) {
2185 resp := &biglakepb.ListTablesResponse{}
2186 if pageToken != "" {
2187 req.PageToken = pageToken
2188 }
2189 if pageSize > math.MaxInt32 {
2190 req.PageSize = math.MaxInt32
2191 } else if pageSize != 0 {
2192 req.PageSize = int32(pageSize)
2193 }
2194 baseUrl, err := url.Parse(c.endpoint)
2195 if err != nil {
2196 return nil, "", err
2197 }
2198 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v/tables", req.GetParent())
2199
2200 params := url.Values{}
2201 params.Add("$alt", "json;enum-encoding=int")
2202 if req.GetPageSize() != 0 {
2203 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2204 }
2205 if req.GetPageToken() != "" {
2206 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2207 }
2208 if req.GetView() != 0 {
2209 params.Add("view", fmt.Sprintf("%v", req.GetView()))
2210 }
2211
2212 baseUrl.RawQuery = params.Encode()
2213
2214 // Build HTTP headers from client and context metadata.
2215 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2216 headers := gax.BuildHeaders(ctx, hds...)
2217 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2218 if settings.Path != "" {
2219 baseUrl.Path = settings.Path
2220 }
2221 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2222 if err != nil {
2223 return err
2224 }
2225 httpReq.Header = headers
2226
2227 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListTables")
2228 if err != nil {
2229 return err
2230 }
2231 if err := unm.Unmarshal(buf, resp); err != nil {
2232 return err
2233 }
2234
2235 return nil
2236 }, opts...)
2237 if e != nil {
2238 return nil, "", e
2239 }
2240 it.Response = resp
2241 return resp.GetTables(), resp.GetNextPageToken(), nil
2242 }
2243
2244 fetch := func(pageSize int, pageToken string) (string, error) {
2245 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2246 if err != nil {
2247 return "", err
2248 }
2249 it.items = append(it.items, items...)
2250 return nextPageToken, nil
2251 }
2252
2253 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2254 it.pageInfo.MaxSize = int(req.GetPageSize())
2255 it.pageInfo.Token = req.GetPageToken()
2256
2257 return it
2258 }
2259
2260 // CreateLock creates a new lock.
2261 func (c *metastoreRESTClient) CreateLock(ctx context.Context, req *biglakepb.CreateLockRequest, opts ...gax.CallOption) (*biglakepb.Lock, error) {
2262 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2263 body := req.GetLock()
2264 jsonReq, err := m.Marshal(body)
2265 if err != nil {
2266 return nil, err
2267 }
2268
2269 baseUrl, err := url.Parse(c.endpoint)
2270 if err != nil {
2271 return nil, err
2272 }
2273 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v/locks", req.GetParent())
2274
2275 params := url.Values{}
2276 params.Add("$alt", "json;enum-encoding=int")
2277
2278 baseUrl.RawQuery = params.Encode()
2279
2280 // Build HTTP headers from client and context metadata.
2281 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2282
2283 hds = append(c.xGoogHeaders, hds...)
2284 hds = append(hds, "Content-Type", "application/json")
2285 headers := gax.BuildHeaders(ctx, hds...)
2286 opts = append((*c.CallOptions).CreateLock[0:len((*c.CallOptions).CreateLock):len((*c.CallOptions).CreateLock)], opts...)
2287 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2288 resp := &biglakepb.Lock{}
2289 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2290 if settings.Path != "" {
2291 baseUrl.Path = settings.Path
2292 }
2293 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2294 if err != nil {
2295 return err
2296 }
2297 httpReq = httpReq.WithContext(ctx)
2298 httpReq.Header = headers
2299
2300 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateLock")
2301 if err != nil {
2302 return err
2303 }
2304
2305 if err := unm.Unmarshal(buf, resp); err != nil {
2306 return err
2307 }
2308
2309 return nil
2310 }, opts...)
2311 if e != nil {
2312 return nil, e
2313 }
2314 return resp, nil
2315 }
2316
2317 // DeleteLock deletes an existing lock specified by the lock ID.
2318 func (c *metastoreRESTClient) DeleteLock(ctx context.Context, req *biglakepb.DeleteLockRequest, opts ...gax.CallOption) error {
2319 baseUrl, err := url.Parse(c.endpoint)
2320 if err != nil {
2321 return err
2322 }
2323 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v", req.GetName())
2324
2325 params := url.Values{}
2326 params.Add("$alt", "json;enum-encoding=int")
2327
2328 baseUrl.RawQuery = params.Encode()
2329
2330 // Build HTTP headers from client and context metadata.
2331 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2332
2333 hds = append(c.xGoogHeaders, hds...)
2334 hds = append(hds, "Content-Type", "application/json")
2335 headers := gax.BuildHeaders(ctx, hds...)
2336 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2337 if settings.Path != "" {
2338 baseUrl.Path = settings.Path
2339 }
2340 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2341 if err != nil {
2342 return err
2343 }
2344 httpReq = httpReq.WithContext(ctx)
2345 httpReq.Header = headers
2346
2347 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteLock")
2348 return err
2349 }, opts...)
2350 }
2351
2352 // CheckLock checks the state of a lock specified by the lock ID.
2353 func (c *metastoreRESTClient) CheckLock(ctx context.Context, req *biglakepb.CheckLockRequest, opts ...gax.CallOption) (*biglakepb.Lock, error) {
2354 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2355 jsonReq, err := m.Marshal(req)
2356 if err != nil {
2357 return nil, err
2358 }
2359
2360 baseUrl, err := url.Parse(c.endpoint)
2361 if err != nil {
2362 return nil, err
2363 }
2364 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v:check", req.GetName())
2365
2366 params := url.Values{}
2367 params.Add("$alt", "json;enum-encoding=int")
2368
2369 baseUrl.RawQuery = params.Encode()
2370
2371 // Build HTTP headers from client and context metadata.
2372 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2373
2374 hds = append(c.xGoogHeaders, hds...)
2375 hds = append(hds, "Content-Type", "application/json")
2376 headers := gax.BuildHeaders(ctx, hds...)
2377 opts = append((*c.CallOptions).CheckLock[0:len((*c.CallOptions).CheckLock):len((*c.CallOptions).CheckLock)], opts...)
2378 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2379 resp := &biglakepb.Lock{}
2380 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2381 if settings.Path != "" {
2382 baseUrl.Path = settings.Path
2383 }
2384 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2385 if err != nil {
2386 return err
2387 }
2388 httpReq = httpReq.WithContext(ctx)
2389 httpReq.Header = headers
2390
2391 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CheckLock")
2392 if err != nil {
2393 return err
2394 }
2395
2396 if err := unm.Unmarshal(buf, resp); err != nil {
2397 return err
2398 }
2399
2400 return nil
2401 }, opts...)
2402 if e != nil {
2403 return nil, e
2404 }
2405 return resp, nil
2406 }
2407
2408 // ListLocks list all locks in a specified database.
2409 func (c *metastoreRESTClient) ListLocks(ctx context.Context, req *biglakepb.ListLocksRequest, opts ...gax.CallOption) *LockIterator {
2410 it := &LockIterator{}
2411 req = proto.Clone(req).(*biglakepb.ListLocksRequest)
2412 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2413 it.InternalFetch = func(pageSize int, pageToken string) ([]*biglakepb.Lock, string, error) {
2414 resp := &biglakepb.ListLocksResponse{}
2415 if pageToken != "" {
2416 req.PageToken = pageToken
2417 }
2418 if pageSize > math.MaxInt32 {
2419 req.PageSize = math.MaxInt32
2420 } else if pageSize != 0 {
2421 req.PageSize = int32(pageSize)
2422 }
2423 baseUrl, err := url.Parse(c.endpoint)
2424 if err != nil {
2425 return nil, "", err
2426 }
2427 baseUrl.Path += fmt.Sprintf("/v1alpha1/%v/locks", req.GetParent())
2428
2429 params := url.Values{}
2430 params.Add("$alt", "json;enum-encoding=int")
2431 if req.GetPageSize() != 0 {
2432 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2433 }
2434 if req.GetPageToken() != "" {
2435 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2436 }
2437
2438 baseUrl.RawQuery = params.Encode()
2439
2440 // Build HTTP headers from client and context metadata.
2441 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2442 headers := gax.BuildHeaders(ctx, hds...)
2443 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2444 if settings.Path != "" {
2445 baseUrl.Path = settings.Path
2446 }
2447 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2448 if err != nil {
2449 return err
2450 }
2451 httpReq.Header = headers
2452
2453 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocks")
2454 if err != nil {
2455 return err
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 it.Response = resp
2467 return resp.GetLocks(), resp.GetNextPageToken(), nil
2468 }
2469
2470 fetch := func(pageSize int, pageToken string) (string, error) {
2471 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2472 if err != nil {
2473 return "", err
2474 }
2475 it.items = append(it.items, items...)
2476 return nextPageToken, nil
2477 }
2478
2479 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2480 it.pageInfo.MaxSize = int(req.GetPageSize())
2481 it.pageInfo.Token = req.GetPageToken()
2482
2483 return it
2484 }