Debian Codegraph @

metastore/apiv1beta/dataproc_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 metastore
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 iampb "cloud.google.com/go/iam/apiv1/iampb"
30 "cloud.google.com/go/longrunning"
31 lroauto "cloud.google.com/go/longrunning/autogen"
32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
33 metastorepb "cloud.google.com/go/metastore/apiv1beta/metastorepb"
34 gax "github.com/googleapis/gax-go/v2"
35 "google.golang.org/api/iterator"
36 "google.golang.org/api/option"
37 "google.golang.org/api/option/internaloption"
38 gtransport "google.golang.org/api/transport/grpc"
39 httptransport "google.golang.org/api/transport/http"
40 locationpb "google.golang.org/genproto/googleapis/cloud/location"
41 "google.golang.org/grpc"
42 "google.golang.org/grpc/codes"
43 "google.golang.org/protobuf/encoding/protojson"
44 "google.golang.org/protobuf/proto"
45 )
46
47 var newDataprocMetastoreClientHook clientHook
48
49 // DataprocMetastoreCallOptions contains the retry settings for each method of DataprocMetastoreClient.
50 type DataprocMetastoreCallOptions struct {
51 ListServices []gax.CallOption
52 GetService []gax.CallOption
53 CreateService []gax.CallOption
54 UpdateService []gax.CallOption
55 DeleteService []gax.CallOption
56 ListMetadataImports []gax.CallOption
57 GetMetadataImport []gax.CallOption
58 CreateMetadataImport []gax.CallOption
59 UpdateMetadataImport []gax.CallOption
60 ExportMetadata []gax.CallOption
61 RestoreService []gax.CallOption
62 ListBackups []gax.CallOption
63 GetBackup []gax.CallOption
64 CreateBackup []gax.CallOption
65 DeleteBackup []gax.CallOption
66 RemoveIamPolicy []gax.CallOption
67 QueryMetadata []gax.CallOption
68 MoveTableToDatabase []gax.CallOption
69 AlterMetadataResourceLocation []gax.CallOption
70 GetLocation []gax.CallOption
71 ListLocations []gax.CallOption
72 GetIamPolicy []gax.CallOption
73 SetIamPolicy []gax.CallOption
74 TestIamPermissions []gax.CallOption
75 CancelOperation []gax.CallOption
76 DeleteOperation []gax.CallOption
77 GetOperation []gax.CallOption
78 ListOperations []gax.CallOption
79 }
80
81 func defaultDataprocMetastoreGRPCClientOptions() []option.ClientOption {
82 return []option.ClientOption{
83 internaloption.WithDefaultEndpoint("metastore.googleapis.com:443"),
84 internaloption.WithDefaultEndpointTemplate("metastore.UNIVERSE_DOMAIN:443"),
85 internaloption.WithDefaultMTLSEndpoint("metastore.mtls.googleapis.com:443"),
86 internaloption.WithDefaultUniverseDomain("googleapis.com"),
87 internaloption.WithDefaultAudience("https://metastore.googleapis.com/"),
88 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
89 internaloption.EnableJwtWithScope(),
90 internaloption.EnableNewAuthLibrary(),
91 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
92 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
93 }
94 }
95
96 func defaultDataprocMetastoreCallOptions() *DataprocMetastoreCallOptions {
97 return &DataprocMetastoreCallOptions{
98 ListServices: []gax.CallOption{
99 gax.WithTimeout(60000 * time.Millisecond),
100 gax.WithRetry(func() gax.Retryer {
101 return gax.OnCodes([]codes.Code{
102 codes.Unavailable,
103 }, gax.Backoff{
104 Initial: 1000 * time.Millisecond,
105 Max: 10000 * time.Millisecond,
106 Multiplier: 1.30,
107 })
108 }),
109 },
110 GetService: []gax.CallOption{
111 gax.WithTimeout(60000 * time.Millisecond),
112 gax.WithRetry(func() gax.Retryer {
113 return gax.OnCodes([]codes.Code{
114 codes.Unavailable,
115 }, gax.Backoff{
116 Initial: 1000 * time.Millisecond,
117 Max: 10000 * time.Millisecond,
118 Multiplier: 1.30,
119 })
120 }),
121 },
122 CreateService: []gax.CallOption{
123 gax.WithTimeout(60000 * time.Millisecond),
124 },
125 UpdateService: []gax.CallOption{
126 gax.WithTimeout(60000 * time.Millisecond),
127 },
128 DeleteService: []gax.CallOption{
129 gax.WithTimeout(60000 * time.Millisecond),
130 },
131 ListMetadataImports: []gax.CallOption{
132 gax.WithTimeout(60000 * time.Millisecond),
133 gax.WithRetry(func() gax.Retryer {
134 return gax.OnCodes([]codes.Code{
135 codes.Unavailable,
136 }, gax.Backoff{
137 Initial: 1000 * time.Millisecond,
138 Max: 10000 * time.Millisecond,
139 Multiplier: 1.30,
140 })
141 }),
142 },
143 GetMetadataImport: []gax.CallOption{
144 gax.WithTimeout(60000 * time.Millisecond),
145 gax.WithRetry(func() gax.Retryer {
146 return gax.OnCodes([]codes.Code{
147 codes.Unavailable,
148 }, gax.Backoff{
149 Initial: 1000 * time.Millisecond,
150 Max: 10000 * time.Millisecond,
151 Multiplier: 1.30,
152 })
153 }),
154 },
155 CreateMetadataImport: []gax.CallOption{
156 gax.WithTimeout(60000 * time.Millisecond),
157 },
158 UpdateMetadataImport: []gax.CallOption{
159 gax.WithTimeout(60000 * time.Millisecond),
160 },
161 ExportMetadata: []gax.CallOption{
162 gax.WithTimeout(60000 * time.Millisecond),
163 },
164 RestoreService: []gax.CallOption{
165 gax.WithTimeout(60000 * time.Millisecond),
166 },
167 ListBackups: []gax.CallOption{
168 gax.WithTimeout(60000 * time.Millisecond),
169 gax.WithRetry(func() gax.Retryer {
170 return gax.OnCodes([]codes.Code{
171 codes.Unavailable,
172 }, gax.Backoff{
173 Initial: 1000 * time.Millisecond,
174 Max: 10000 * time.Millisecond,
175 Multiplier: 1.30,
176 })
177 }),
178 },
179 GetBackup: []gax.CallOption{
180 gax.WithTimeout(60000 * time.Millisecond),
181 gax.WithRetry(func() gax.Retryer {
182 return gax.OnCodes([]codes.Code{
183 codes.Unavailable,
184 }, gax.Backoff{
185 Initial: 1000 * time.Millisecond,
186 Max: 10000 * time.Millisecond,
187 Multiplier: 1.30,
188 })
189 }),
190 },
191 CreateBackup: []gax.CallOption{
192 gax.WithTimeout(60000 * time.Millisecond),
193 },
194 DeleteBackup: []gax.CallOption{
195 gax.WithTimeout(60000 * time.Millisecond),
196 },
197 RemoveIamPolicy: []gax.CallOption{
198 gax.WithTimeout(60000 * time.Millisecond),
199 gax.WithRetry(func() gax.Retryer {
200 return gax.OnCodes([]codes.Code{
201 codes.Unavailable,
202 }, gax.Backoff{
203 Initial: 1000 * time.Millisecond,
204 Max: 10000 * time.Millisecond,
205 Multiplier: 1.30,
206 })
207 }),
208 },
209 QueryMetadata: []gax.CallOption{
210 gax.WithTimeout(60000 * time.Millisecond),
211 gax.WithRetry(func() gax.Retryer {
212 return gax.OnCodes([]codes.Code{
213 codes.Unavailable,
214 }, gax.Backoff{
215 Initial: 1000 * time.Millisecond,
216 Max: 10000 * time.Millisecond,
217 Multiplier: 1.30,
218 })
219 }),
220 },
221 MoveTableToDatabase: []gax.CallOption{
222 gax.WithTimeout(60000 * time.Millisecond),
223 gax.WithRetry(func() gax.Retryer {
224 return gax.OnCodes([]codes.Code{
225 codes.Unavailable,
226 }, gax.Backoff{
227 Initial: 1000 * time.Millisecond,
228 Max: 10000 * time.Millisecond,
229 Multiplier: 1.30,
230 })
231 }),
232 },
233 AlterMetadataResourceLocation: []gax.CallOption{
234 gax.WithTimeout(60000 * time.Millisecond),
235 gax.WithRetry(func() gax.Retryer {
236 return gax.OnCodes([]codes.Code{
237 codes.Unavailable,
238 }, gax.Backoff{
239 Initial: 1000 * time.Millisecond,
240 Max: 10000 * time.Millisecond,
241 Multiplier: 1.30,
242 })
243 }),
244 },
245 GetLocation: []gax.CallOption{},
246 ListLocations: []gax.CallOption{},
247 GetIamPolicy: []gax.CallOption{},
248 SetIamPolicy: []gax.CallOption{},
249 TestIamPermissions: []gax.CallOption{},
250 CancelOperation: []gax.CallOption{},
251 DeleteOperation: []gax.CallOption{},
252 GetOperation: []gax.CallOption{},
253 ListOperations: []gax.CallOption{},
254 }
255 }
256
257 func defaultDataprocMetastoreRESTCallOptions() *DataprocMetastoreCallOptions {
258 return &DataprocMetastoreCallOptions{
259 ListServices: []gax.CallOption{
260 gax.WithTimeout(60000 * time.Millisecond),
261 gax.WithRetry(func() gax.Retryer {
262 return gax.OnHTTPCodes(gax.Backoff{
263 Initial: 1000 * time.Millisecond,
264 Max: 10000 * time.Millisecond,
265 Multiplier: 1.30,
266 },
267 http.StatusServiceUnavailable)
268 }),
269 },
270 GetService: []gax.CallOption{
271 gax.WithTimeout(60000 * time.Millisecond),
272 gax.WithRetry(func() gax.Retryer {
273 return gax.OnHTTPCodes(gax.Backoff{
274 Initial: 1000 * time.Millisecond,
275 Max: 10000 * time.Millisecond,
276 Multiplier: 1.30,
277 },
278 http.StatusServiceUnavailable)
279 }),
280 },
281 CreateService: []gax.CallOption{
282 gax.WithTimeout(60000 * time.Millisecond),
283 },
284 UpdateService: []gax.CallOption{
285 gax.WithTimeout(60000 * time.Millisecond),
286 },
287 DeleteService: []gax.CallOption{
288 gax.WithTimeout(60000 * time.Millisecond),
289 },
290 ListMetadataImports: []gax.CallOption{
291 gax.WithTimeout(60000 * time.Millisecond),
292 gax.WithRetry(func() gax.Retryer {
293 return gax.OnHTTPCodes(gax.Backoff{
294 Initial: 1000 * time.Millisecond,
295 Max: 10000 * time.Millisecond,
296 Multiplier: 1.30,
297 },
298 http.StatusServiceUnavailable)
299 }),
300 },
301 GetMetadataImport: []gax.CallOption{
302 gax.WithTimeout(60000 * time.Millisecond),
303 gax.WithRetry(func() gax.Retryer {
304 return gax.OnHTTPCodes(gax.Backoff{
305 Initial: 1000 * time.Millisecond,
306 Max: 10000 * time.Millisecond,
307 Multiplier: 1.30,
308 },
309 http.StatusServiceUnavailable)
310 }),
311 },
312 CreateMetadataImport: []gax.CallOption{
313 gax.WithTimeout(60000 * time.Millisecond),
314 },
315 UpdateMetadataImport: []gax.CallOption{
316 gax.WithTimeout(60000 * time.Millisecond),
317 },
318 ExportMetadata: []gax.CallOption{
319 gax.WithTimeout(60000 * time.Millisecond),
320 },
321 RestoreService: []gax.CallOption{
322 gax.WithTimeout(60000 * time.Millisecond),
323 },
324 ListBackups: []gax.CallOption{
325 gax.WithTimeout(60000 * time.Millisecond),
326 gax.WithRetry(func() gax.Retryer {
327 return gax.OnHTTPCodes(gax.Backoff{
328 Initial: 1000 * time.Millisecond,
329 Max: 10000 * time.Millisecond,
330 Multiplier: 1.30,
331 },
332 http.StatusServiceUnavailable)
333 }),
334 },
335 GetBackup: []gax.CallOption{
336 gax.WithTimeout(60000 * time.Millisecond),
337 gax.WithRetry(func() gax.Retryer {
338 return gax.OnHTTPCodes(gax.Backoff{
339 Initial: 1000 * time.Millisecond,
340 Max: 10000 * time.Millisecond,
341 Multiplier: 1.30,
342 },
343 http.StatusServiceUnavailable)
344 }),
345 },
346 CreateBackup: []gax.CallOption{
347 gax.WithTimeout(60000 * time.Millisecond),
348 },
349 DeleteBackup: []gax.CallOption{
350 gax.WithTimeout(60000 * time.Millisecond),
351 },
352 RemoveIamPolicy: []gax.CallOption{
353 gax.WithTimeout(60000 * time.Millisecond),
354 gax.WithRetry(func() gax.Retryer {
355 return gax.OnHTTPCodes(gax.Backoff{
356 Initial: 1000 * time.Millisecond,
357 Max: 10000 * time.Millisecond,
358 Multiplier: 1.30,
359 },
360 http.StatusServiceUnavailable)
361 }),
362 },
363 QueryMetadata: []gax.CallOption{
364 gax.WithTimeout(60000 * time.Millisecond),
365 gax.WithRetry(func() gax.Retryer {
366 return gax.OnHTTPCodes(gax.Backoff{
367 Initial: 1000 * time.Millisecond,
368 Max: 10000 * time.Millisecond,
369 Multiplier: 1.30,
370 },
371 http.StatusServiceUnavailable)
372 }),
373 },
374 MoveTableToDatabase: []gax.CallOption{
375 gax.WithTimeout(60000 * time.Millisecond),
376 gax.WithRetry(func() gax.Retryer {
377 return gax.OnHTTPCodes(gax.Backoff{
378 Initial: 1000 * time.Millisecond,
379 Max: 10000 * time.Millisecond,
380 Multiplier: 1.30,
381 },
382 http.StatusServiceUnavailable)
383 }),
384 },
385 AlterMetadataResourceLocation: []gax.CallOption{
386 gax.WithTimeout(60000 * time.Millisecond),
387 gax.WithRetry(func() gax.Retryer {
388 return gax.OnHTTPCodes(gax.Backoff{
389 Initial: 1000 * time.Millisecond,
390 Max: 10000 * time.Millisecond,
391 Multiplier: 1.30,
392 },
393 http.StatusServiceUnavailable)
394 }),
395 },
396 GetLocation: []gax.CallOption{},
397 ListLocations: []gax.CallOption{},
398 GetIamPolicy: []gax.CallOption{},
399 SetIamPolicy: []gax.CallOption{},
400 TestIamPermissions: []gax.CallOption{},
401 CancelOperation: []gax.CallOption{},
402 DeleteOperation: []gax.CallOption{},
403 GetOperation: []gax.CallOption{},
404 ListOperations: []gax.CallOption{},
405 }
406 }
407
408 // internalDataprocMetastoreClient is an interface that defines the methods available from Dataproc Metastore API.
409 type internalDataprocMetastoreClient interface {
410 Close() error
411 setGoogleClientInfo(...string)
412 Connection() *grpc.ClientConn
413 ListServices(context.Context, *metastorepb.ListServicesRequest, ...gax.CallOption) *ServiceIterator
414 GetService(context.Context, *metastorepb.GetServiceRequest, ...gax.CallOption) (*metastorepb.Service, error)
415 CreateService(context.Context, *metastorepb.CreateServiceRequest, ...gax.CallOption) (*CreateServiceOperation, error)
416 CreateServiceOperation(name string) *CreateServiceOperation
417 UpdateService(context.Context, *metastorepb.UpdateServiceRequest, ...gax.CallOption) (*UpdateServiceOperation, error)
418 UpdateServiceOperation(name string) *UpdateServiceOperation
419 DeleteService(context.Context, *metastorepb.DeleteServiceRequest, ...gax.CallOption) (*DeleteServiceOperation, error)
420 DeleteServiceOperation(name string) *DeleteServiceOperation
421 ListMetadataImports(context.Context, *metastorepb.ListMetadataImportsRequest, ...gax.CallOption) *MetadataImportIterator
422 GetMetadataImport(context.Context, *metastorepb.GetMetadataImportRequest, ...gax.CallOption) (*metastorepb.MetadataImport, error)
423 CreateMetadataImport(context.Context, *metastorepb.CreateMetadataImportRequest, ...gax.CallOption) (*CreateMetadataImportOperation, error)
424 CreateMetadataImportOperation(name string) *CreateMetadataImportOperation
425 UpdateMetadataImport(context.Context, *metastorepb.UpdateMetadataImportRequest, ...gax.CallOption) (*UpdateMetadataImportOperation, error)
426 UpdateMetadataImportOperation(name string) *UpdateMetadataImportOperation
427 ExportMetadata(context.Context, *metastorepb.ExportMetadataRequest, ...gax.CallOption) (*ExportMetadataOperation, error)
428 ExportMetadataOperation(name string) *ExportMetadataOperation
429 RestoreService(context.Context, *metastorepb.RestoreServiceRequest, ...gax.CallOption) (*RestoreServiceOperation, error)
430 RestoreServiceOperation(name string) *RestoreServiceOperation
431 ListBackups(context.Context, *metastorepb.ListBackupsRequest, ...gax.CallOption) *BackupIterator
432 GetBackup(context.Context, *metastorepb.GetBackupRequest, ...gax.CallOption) (*metastorepb.Backup, error)
433 CreateBackup(context.Context, *metastorepb.CreateBackupRequest, ...gax.CallOption) (*CreateBackupOperation, error)
434 CreateBackupOperation(name string) *CreateBackupOperation
435 DeleteBackup(context.Context, *metastorepb.DeleteBackupRequest, ...gax.CallOption) (*DeleteBackupOperation, error)
436 DeleteBackupOperation(name string) *DeleteBackupOperation
437 RemoveIamPolicy(context.Context, *metastorepb.RemoveIamPolicyRequest, ...gax.CallOption) (*metastorepb.RemoveIamPolicyResponse, error)
438 QueryMetadata(context.Context, *metastorepb.QueryMetadataRequest, ...gax.CallOption) (*QueryMetadataOperation, error)
439 QueryMetadataOperation(name string) *QueryMetadataOperation
440 MoveTableToDatabase(context.Context, *metastorepb.MoveTableToDatabaseRequest, ...gax.CallOption) (*MoveTableToDatabaseOperation, error)
441 MoveTableToDatabaseOperation(name string) *MoveTableToDatabaseOperation
442 AlterMetadataResourceLocation(context.Context, *metastorepb.AlterMetadataResourceLocationRequest, ...gax.CallOption) (*AlterMetadataResourceLocationOperation, error)
443 AlterMetadataResourceLocationOperation(name string) *AlterMetadataResourceLocationOperation
444 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
445 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
446 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
447 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
448 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
449 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
450 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
451 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
452 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
453 }
454
455 // DataprocMetastoreClient is a client for interacting with Dataproc Metastore API.
456 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
457 //
458 // Configures and manages metastore services.
459 // Metastore services are fully managed, highly available, autoscaled,
460 // autohealing, OSS-native deployments of technical metadata management
461 // software. Each metastore service exposes a network endpoint through which
462 // metadata queries are served. Metadata queries can originate from a variety
463 // of sources, including Apache Hive, Apache Presto, and Apache Spark.
464 //
465 // The Dataproc Metastore API defines the following resource model:
466 //
467 // The service works with a collection of Google Cloud projects, named:
468 // /projects/*
469 //
470 // Each project has a collection of available locations, named: /locations/*
471 // (a location must refer to a Google Cloud region)
472 //
473 // Each location has a collection of services, named: /services/*
474 //
475 // Dataproc Metastore services are resources with names of the form:
476 //
477 // /projects/{project_number}/locations/{location_id}/services/{service_id}.
478 type DataprocMetastoreClient struct {
479 // The internal transport-dependent client.
480 internalClient internalDataprocMetastoreClient
481
482 // The call options for this service.
483 CallOptions *DataprocMetastoreCallOptions
484
485 // LROClient is used internally to handle long-running operations.
486 // It is exposed so that its CallOptions can be modified if required.
487 // Users should not Close this client.
488 LROClient *lroauto.OperationsClient
489 }
490
491 // Wrapper methods routed to the internal client.
492
493 // Close closes the connection to the API service. The user should invoke this when
494 // the client is no longer required.
495 func (c *DataprocMetastoreClient) Close() error {
496 return c.internalClient.Close()
497 }
498
499 // setGoogleClientInfo sets the name and version of the application in
500 // the `x-goog-api-client` header passed on each request. Intended for
501 // use by Google-written clients.
502 func (c *DataprocMetastoreClient) setGoogleClientInfo(keyval ...string) {
503 c.internalClient.setGoogleClientInfo(keyval...)
504 }
505
506 // Connection returns a connection to the API service.
507 //
508 // Deprecated: Connections are now pooled so this method does not always
509 // return the same resource.
510 func (c *DataprocMetastoreClient) Connection() *grpc.ClientConn {
511 return c.internalClient.Connection()
512 }
513
514 // ListServices lists services in a project and location.
515 func (c *DataprocMetastoreClient) ListServices(ctx context.Context, req *metastorepb.ListServicesRequest, opts ...gax.CallOption) *ServiceIterator {
516 return c.internalClient.ListServices(ctx, req, opts...)
517 }
518
519 // GetService gets the details of a single service.
520 func (c *DataprocMetastoreClient) GetService(ctx context.Context, req *metastorepb.GetServiceRequest, opts ...gax.CallOption) (*metastorepb.Service, error) {
521 return c.internalClient.GetService(ctx, req, opts...)
522 }
523
524 // CreateService creates a metastore service in a project and location.
525 func (c *DataprocMetastoreClient) CreateService(ctx context.Context, req *metastorepb.CreateServiceRequest, opts ...gax.CallOption) (*CreateServiceOperation, error) {
526 return c.internalClient.CreateService(ctx, req, opts...)
527 }
528
529 // CreateServiceOperation returns a new CreateServiceOperation from a given name.
530 // The name must be that of a previously created CreateServiceOperation, possibly from a different process.
531 func (c *DataprocMetastoreClient) CreateServiceOperation(name string) *CreateServiceOperation {
532 return c.internalClient.CreateServiceOperation(name)
533 }
534
535 // UpdateService updates the parameters of a single service.
536 func (c *DataprocMetastoreClient) UpdateService(ctx context.Context, req *metastorepb.UpdateServiceRequest, opts ...gax.CallOption) (*UpdateServiceOperation, error) {
537 return c.internalClient.UpdateService(ctx, req, opts...)
538 }
539
540 // UpdateServiceOperation returns a new UpdateServiceOperation from a given name.
541 // The name must be that of a previously created UpdateServiceOperation, possibly from a different process.
542 func (c *DataprocMetastoreClient) UpdateServiceOperation(name string) *UpdateServiceOperation {
543 return c.internalClient.UpdateServiceOperation(name)
544 }
545
546 // DeleteService deletes a single service.
547 func (c *DataprocMetastoreClient) DeleteService(ctx context.Context, req *metastorepb.DeleteServiceRequest, opts ...gax.CallOption) (*DeleteServiceOperation, error) {
548 return c.internalClient.DeleteService(ctx, req, opts...)
549 }
550
551 // DeleteServiceOperation returns a new DeleteServiceOperation from a given name.
552 // The name must be that of a previously created DeleteServiceOperation, possibly from a different process.
553 func (c *DataprocMetastoreClient) DeleteServiceOperation(name string) *DeleteServiceOperation {
554 return c.internalClient.DeleteServiceOperation(name)
555 }
556
557 // ListMetadataImports lists imports in a service.
558 func (c *DataprocMetastoreClient) ListMetadataImports(ctx context.Context, req *metastorepb.ListMetadataImportsRequest, opts ...gax.CallOption) *MetadataImportIterator {
559 return c.internalClient.ListMetadataImports(ctx, req, opts...)
560 }
561
562 // GetMetadataImport gets details of a single import.
563 func (c *DataprocMetastoreClient) GetMetadataImport(ctx context.Context, req *metastorepb.GetMetadataImportRequest, opts ...gax.CallOption) (*metastorepb.MetadataImport, error) {
564 return c.internalClient.GetMetadataImport(ctx, req, opts...)
565 }
566
567 // CreateMetadataImport creates a new MetadataImport in a given project and location.
568 func (c *DataprocMetastoreClient) CreateMetadataImport(ctx context.Context, req *metastorepb.CreateMetadataImportRequest, opts ...gax.CallOption) (*CreateMetadataImportOperation, error) {
569 return c.internalClient.CreateMetadataImport(ctx, req, opts...)
570 }
571
572 // CreateMetadataImportOperation returns a new CreateMetadataImportOperation from a given name.
573 // The name must be that of a previously created CreateMetadataImportOperation, possibly from a different process.
574 func (c *DataprocMetastoreClient) CreateMetadataImportOperation(name string) *CreateMetadataImportOperation {
575 return c.internalClient.CreateMetadataImportOperation(name)
576 }
577
578 // UpdateMetadataImport updates a single import.
579 // Only the description field of MetadataImport is supported to be updated.
580 func (c *DataprocMetastoreClient) UpdateMetadataImport(ctx context.Context, req *metastorepb.UpdateMetadataImportRequest, opts ...gax.CallOption) (*UpdateMetadataImportOperation, error) {
581 return c.internalClient.UpdateMetadataImport(ctx, req, opts...)
582 }
583
584 // UpdateMetadataImportOperation returns a new UpdateMetadataImportOperation from a given name.
585 // The name must be that of a previously created UpdateMetadataImportOperation, possibly from a different process.
586 func (c *DataprocMetastoreClient) UpdateMetadataImportOperation(name string) *UpdateMetadataImportOperation {
587 return c.internalClient.UpdateMetadataImportOperation(name)
588 }
589
590 // ExportMetadata exports metadata from a service.
591 func (c *DataprocMetastoreClient) ExportMetadata(ctx context.Context, req *metastorepb.ExportMetadataRequest, opts ...gax.CallOption) (*ExportMetadataOperation, error) {
592 return c.internalClient.ExportMetadata(ctx, req, opts...)
593 }
594
595 // ExportMetadataOperation returns a new ExportMetadataOperation from a given name.
596 // The name must be that of a previously created ExportMetadataOperation, possibly from a different process.
597 func (c *DataprocMetastoreClient) ExportMetadataOperation(name string) *ExportMetadataOperation {
598 return c.internalClient.ExportMetadataOperation(name)
599 }
600
601 // RestoreService restores a service from a backup.
602 func (c *DataprocMetastoreClient) RestoreService(ctx context.Context, req *metastorepb.RestoreServiceRequest, opts ...gax.CallOption) (*RestoreServiceOperation, error) {
603 return c.internalClient.RestoreService(ctx, req, opts...)
604 }
605
606 // RestoreServiceOperation returns a new RestoreServiceOperation from a given name.
607 // The name must be that of a previously created RestoreServiceOperation, possibly from a different process.
608 func (c *DataprocMetastoreClient) RestoreServiceOperation(name string) *RestoreServiceOperation {
609 return c.internalClient.RestoreServiceOperation(name)
610 }
611
612 // ListBackups lists backups in a service.
613 func (c *DataprocMetastoreClient) ListBackups(ctx context.Context, req *metastorepb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
614 return c.internalClient.ListBackups(ctx, req, opts...)
615 }
616
617 // GetBackup gets details of a single backup.
618 func (c *DataprocMetastoreClient) GetBackup(ctx context.Context, req *metastorepb.GetBackupRequest, opts ...gax.CallOption) (*metastorepb.Backup, error) {
619 return c.internalClient.GetBackup(ctx, req, opts...)
620 }
621
622 // CreateBackup creates a new backup in a given project and location.
623 func (c *DataprocMetastoreClient) CreateBackup(ctx context.Context, req *metastorepb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
624 return c.internalClient.CreateBackup(ctx, req, opts...)
625 }
626
627 // CreateBackupOperation returns a new CreateBackupOperation from a given name.
628 // The name must be that of a previously created CreateBackupOperation, possibly from a different process.
629 func (c *DataprocMetastoreClient) CreateBackupOperation(name string) *CreateBackupOperation {
630 return c.internalClient.CreateBackupOperation(name)
631 }
632
633 // DeleteBackup deletes a single backup.
634 func (c *DataprocMetastoreClient) DeleteBackup(ctx context.Context, req *metastorepb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
635 return c.internalClient.DeleteBackup(ctx, req, opts...)
636 }
637
638 // DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
639 // The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
640 func (c *DataprocMetastoreClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
641 return c.internalClient.DeleteBackupOperation(name)
642 }
643
644 // RemoveIamPolicy removes the attached IAM policies for a resource
645 func (c *DataprocMetastoreClient) RemoveIamPolicy(ctx context.Context, req *metastorepb.RemoveIamPolicyRequest, opts ...gax.CallOption) (*metastorepb.RemoveIamPolicyResponse, error) {
646 return c.internalClient.RemoveIamPolicy(ctx, req, opts...)
647 }
648
649 // QueryMetadata query DPMS metadata.
650 func (c *DataprocMetastoreClient) QueryMetadata(ctx context.Context, req *metastorepb.QueryMetadataRequest, opts ...gax.CallOption) (*QueryMetadataOperation, error) {
651 return c.internalClient.QueryMetadata(ctx, req, opts...)
652 }
653
654 // QueryMetadataOperation returns a new QueryMetadataOperation from a given name.
655 // The name must be that of a previously created QueryMetadataOperation, possibly from a different process.
656 func (c *DataprocMetastoreClient) QueryMetadataOperation(name string) *QueryMetadataOperation {
657 return c.internalClient.QueryMetadataOperation(name)
658 }
659
660 // MoveTableToDatabase move a table to another database.
661 func (c *DataprocMetastoreClient) MoveTableToDatabase(ctx context.Context, req *metastorepb.MoveTableToDatabaseRequest, opts ...gax.CallOption) (*MoveTableToDatabaseOperation, error) {
662 return c.internalClient.MoveTableToDatabase(ctx, req, opts...)
663 }
664
665 // MoveTableToDatabaseOperation returns a new MoveTableToDatabaseOperation from a given name.
666 // The name must be that of a previously created MoveTableToDatabaseOperation, possibly from a different process.
667 func (c *DataprocMetastoreClient) MoveTableToDatabaseOperation(name string) *MoveTableToDatabaseOperation {
668 return c.internalClient.MoveTableToDatabaseOperation(name)
669 }
670
671 // AlterMetadataResourceLocation alter metadata resource location. The metadata resource can be a database,
672 // table, or partition. This functionality only updates the parent directory
673 // for the respective metadata resource and does not transfer any existing
674 // data to the new location.
675 func (c *DataprocMetastoreClient) AlterMetadataResourceLocation(ctx context.Context, req *metastorepb.AlterMetadataResourceLocationRequest, opts ...gax.CallOption) (*AlterMetadataResourceLocationOperation, error) {
676 return c.internalClient.AlterMetadataResourceLocation(ctx, req, opts...)
677 }
678
679 // AlterMetadataResourceLocationOperation returns a new AlterMetadataResourceLocationOperation from a given name.
680 // The name must be that of a previously created AlterMetadataResourceLocationOperation, possibly from a different process.
681 func (c *DataprocMetastoreClient) AlterMetadataResourceLocationOperation(name string) *AlterMetadataResourceLocationOperation {
682 return c.internalClient.AlterMetadataResourceLocationOperation(name)
683 }
684
685 // GetLocation gets information about a location.
686 func (c *DataprocMetastoreClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
687 return c.internalClient.GetLocation(ctx, req, opts...)
688 }
689
690 // ListLocations lists information about the supported locations for this service.
691 func (c *DataprocMetastoreClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
692 return c.internalClient.ListLocations(ctx, req, opts...)
693 }
694
695 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
696 // if the resource exists and does not have a policy set.
697 func (c *DataprocMetastoreClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
698 return c.internalClient.GetIamPolicy(ctx, req, opts...)
699 }
700
701 // SetIamPolicy sets the access control policy on the specified resource. Replaces
702 // any existing policy.
703 //
704 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
705 // errors.
706 func (c *DataprocMetastoreClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
707 return c.internalClient.SetIamPolicy(ctx, req, opts...)
708 }
709
710 // TestIamPermissions returns permissions that a caller has on the specified resource. If the
711 // resource does not exist, this will return an empty set of
712 // permissions, not a NOT_FOUND error.
713 //
714 // Note: This operation is designed to be used for building
715 // permission-aware UIs and command-line tools, not for authorization
716 // checking. This operation may “fail open” without warning.
717 func (c *DataprocMetastoreClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
718 return c.internalClient.TestIamPermissions(ctx, req, opts...)
719 }
720
721 // CancelOperation is a utility method from google.longrunning.Operations.
722 func (c *DataprocMetastoreClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
723 return c.internalClient.CancelOperation(ctx, req, opts...)
724 }
725
726 // DeleteOperation is a utility method from google.longrunning.Operations.
727 func (c *DataprocMetastoreClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
728 return c.internalClient.DeleteOperation(ctx, req, opts...)
729 }
730
731 // GetOperation is a utility method from google.longrunning.Operations.
732 func (c *DataprocMetastoreClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
733 return c.internalClient.GetOperation(ctx, req, opts...)
734 }
735
736 // ListOperations is a utility method from google.longrunning.Operations.
737 func (c *DataprocMetastoreClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
738 return c.internalClient.ListOperations(ctx, req, opts...)
739 }
740
741 // dataprocMetastoreGRPCClient is a client for interacting with Dataproc Metastore API over gRPC transport.
742 //
743 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
744 type dataprocMetastoreGRPCClient struct {
745 // Connection pool of gRPC connections to the service.
746 connPool gtransport.ConnPool
747
748 // Points back to the CallOptions field of the containing DataprocMetastoreClient
749 CallOptions **DataprocMetastoreCallOptions
750
751 // The gRPC API client.
752 dataprocMetastoreClient metastorepb.DataprocMetastoreClient
753
754 // LROClient is used internally to handle long-running operations.
755 // It is exposed so that its CallOptions can be modified if required.
756 // Users should not Close this client.
757 LROClient **lroauto.OperationsClient
758
759 operationsClient longrunningpb.OperationsClient
760
761 iamPolicyClient iampb.IAMPolicyClient
762
763 locationsClient locationpb.LocationsClient
764
765 // The x-goog-* metadata to be sent with each request.
766 xGoogHeaders []string
767
768 logger *slog.Logger
769 }
770
771 // NewDataprocMetastoreClient creates a new dataproc metastore client based on gRPC.
772 // The returned client must be Closed when it is done being used to clean up its underlying connections.
773 //
774 // Configures and manages metastore services.
775 // Metastore services are fully managed, highly available, autoscaled,
776 // autohealing, OSS-native deployments of technical metadata management
777 // software. Each metastore service exposes a network endpoint through which
778 // metadata queries are served. Metadata queries can originate from a variety
779 // of sources, including Apache Hive, Apache Presto, and Apache Spark.
780 //
781 // The Dataproc Metastore API defines the following resource model:
782 //
783 // The service works with a collection of Google Cloud projects, named:
784 // /projects/*
785 //
786 // Each project has a collection of available locations, named: /locations/*
787 // (a location must refer to a Google Cloud region)
788 //
789 // Each location has a collection of services, named: /services/*
790 //
791 // Dataproc Metastore services are resources with names of the form:
792 //
793 // /projects/{project_number}/locations/{location_id}/services/{service_id}.
794 func NewDataprocMetastoreClient(ctx context.Context, opts ...option.ClientOption) (*DataprocMetastoreClient, error) {
795 clientOpts := defaultDataprocMetastoreGRPCClientOptions()
796 if newDataprocMetastoreClientHook != nil {
797 hookOpts, err := newDataprocMetastoreClientHook(ctx, clientHookParams{})
798 if err != nil {
799 return nil, err
800 }
801 clientOpts = append(clientOpts, hookOpts...)
802 }
803
804 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
805 if err != nil {
806 return nil, err
807 }
808 client := DataprocMetastoreClient{CallOptions: defaultDataprocMetastoreCallOptions()}
809
810 c := &dataprocMetastoreGRPCClient{
811 connPool: connPool,
812 dataprocMetastoreClient: metastorepb.NewDataprocMetastoreClient(connPool),
813 CallOptions: &client.CallOptions,
814 logger: internaloption.GetLogger(opts),
815 operationsClient: longrunningpb.NewOperationsClient(connPool),
816 iamPolicyClient: iampb.NewIAMPolicyClient(connPool),
817 locationsClient: locationpb.NewLocationsClient(connPool),
818 }
819 c.setGoogleClientInfo()
820
821 client.internalClient = c
822
823 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
824 if err != nil {
825 // This error "should not happen", since we are just reusing old connection pool
826 // and never actually need to dial.
827 // If this does happen, we could leak connp. However, we cannot close conn:
828 // If the user invoked the constructor with option.WithGRPCConn,
829 // we would close a connection that's still in use.
830 // TODO: investigate error conditions.
831 return nil, err
832 }
833 c.LROClient = &client.LROClient
834 return &client, nil
835 }
836
837 // Connection returns a connection to the API service.
838 //
839 // Deprecated: Connections are now pooled so this method does not always
840 // return the same resource.
841 func (c *dataprocMetastoreGRPCClient) Connection() *grpc.ClientConn {
842 return c.connPool.Conn()
843 }
844
845 // setGoogleClientInfo sets the name and version of the application in
846 // the `x-goog-api-client` header passed on each request. Intended for
847 // use by Google-written clients.
848 func (c *dataprocMetastoreGRPCClient) setGoogleClientInfo(keyval ...string) {
849 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
850 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
851 c.xGoogHeaders = []string{
852 "x-goog-api-client", gax.XGoogHeader(kv...),
853 }
854 }
855
856 // Close closes the connection to the API service. The user should invoke this when
857 // the client is no longer required.
858 func (c *dataprocMetastoreGRPCClient) Close() error {
859 return c.connPool.Close()
860 }
861
862 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
863 type dataprocMetastoreRESTClient struct {
864 // The http endpoint to connect to.
865 endpoint string
866
867 // The http client.
868 httpClient *http.Client
869
870 // LROClient is used internally to handle long-running operations.
871 // It is exposed so that its CallOptions can be modified if required.
872 // Users should not Close this client.
873 LROClient **lroauto.OperationsClient
874
875 // The x-goog-* headers to be sent with each request.
876 xGoogHeaders []string
877
878 // Points back to the CallOptions field of the containing DataprocMetastoreClient
879 CallOptions **DataprocMetastoreCallOptions
880
881 logger *slog.Logger
882 }
883
884 // NewDataprocMetastoreRESTClient creates a new dataproc metastore rest client.
885 //
886 // Configures and manages metastore services.
887 // Metastore services are fully managed, highly available, autoscaled,
888 // autohealing, OSS-native deployments of technical metadata management
889 // software. Each metastore service exposes a network endpoint through which
890 // metadata queries are served. Metadata queries can originate from a variety
891 // of sources, including Apache Hive, Apache Presto, and Apache Spark.
892 //
893 // The Dataproc Metastore API defines the following resource model:
894 //
895 // The service works with a collection of Google Cloud projects, named:
896 // /projects/*
897 //
898 // Each project has a collection of available locations, named: /locations/*
899 // (a location must refer to a Google Cloud region)
900 //
901 // Each location has a collection of services, named: /services/*
902 //
903 // Dataproc Metastore services are resources with names of the form:
904 //
905 // /projects/{project_number}/locations/{location_id}/services/{service_id}.
906 func NewDataprocMetastoreRESTClient(ctx context.Context, opts ...option.ClientOption) (*DataprocMetastoreClient, error) {
907 clientOpts := append(defaultDataprocMetastoreRESTClientOptions(), opts...)
908 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
909 if err != nil {
910 return nil, err
911 }
912
913 callOpts := defaultDataprocMetastoreRESTCallOptions()
914 c := &dataprocMetastoreRESTClient{
915 endpoint: endpoint,
916 httpClient: httpClient,
917 CallOptions: &callOpts,
918 logger: internaloption.GetLogger(opts),
919 }
920 c.setGoogleClientInfo()
921
922 lroOpts := []option.ClientOption{
923 option.WithHTTPClient(httpClient),
924 option.WithEndpoint(endpoint),
925 }
926 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
927 if err != nil {
928 return nil, err
929 }
930 c.LROClient = &opClient
931
932 return &DataprocMetastoreClient{internalClient: c, CallOptions: callOpts}, nil
933 }
934
935 func defaultDataprocMetastoreRESTClientOptions() []option.ClientOption {
936 return []option.ClientOption{
937 internaloption.WithDefaultEndpoint("https://metastore.googleapis.com"),
938 internaloption.WithDefaultEndpointTemplate("https://metastore.UNIVERSE_DOMAIN"),
939 internaloption.WithDefaultMTLSEndpoint("https://metastore.mtls.googleapis.com"),
940 internaloption.WithDefaultUniverseDomain("googleapis.com"),
941 internaloption.WithDefaultAudience("https://metastore.googleapis.com/"),
942 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
943 internaloption.EnableNewAuthLibrary(),
944 }
945 }
946
947 // setGoogleClientInfo sets the name and version of the application in
948 // the `x-goog-api-client` header passed on each request. Intended for
949 // use by Google-written clients.
950 func (c *dataprocMetastoreRESTClient) setGoogleClientInfo(keyval ...string) {
951 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
952 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
953 c.xGoogHeaders = []string{
954 "x-goog-api-client", gax.XGoogHeader(kv...),
955 }
956 }
957
958 // Close closes the connection to the API service. The user should invoke this when
959 // the client is no longer required.
960 func (c *dataprocMetastoreRESTClient) Close() error {
961 // Replace httpClient with nil to force cleanup.
962 c.httpClient = nil
963 return nil
964 }
965
966 // Connection returns a connection to the API service.
967 //
968 // Deprecated: This method always returns nil.
969 func (c *dataprocMetastoreRESTClient) Connection() *grpc.ClientConn {
970 return nil
971 }
972 func (c *dataprocMetastoreGRPCClient) ListServices(ctx context.Context, req *metastorepb.ListServicesRequest, opts ...gax.CallOption) *ServiceIterator {
973 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
974
975 hds = append(c.xGoogHeaders, hds...)
976 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
977 opts = append((*c.CallOptions).ListServices[0:len((*c.CallOptions).ListServices):len((*c.CallOptions).ListServices)], opts...)
978 it := &ServiceIterator{}
979 req = proto.Clone(req).(*metastorepb.ListServicesRequest)
980 it.InternalFetch = func(pageSize int, pageToken string) ([]*metastorepb.Service, string, error) {
981 resp := &metastorepb.ListServicesResponse{}
982 if pageToken != "" {
983 req.PageToken = pageToken
984 }
985 if pageSize > math.MaxInt32 {
986 req.PageSize = math.MaxInt32
987 } else if pageSize != 0 {
988 req.PageSize = int32(pageSize)
989 }
990 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
991 var err error
992 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.ListServices, req, settings.GRPC, c.logger, "ListServices")
993 return err
994 }, opts...)
995 if err != nil {
996 return nil, "", err
997 }
998
999 it.Response = resp
1000 return resp.GetServices(), resp.GetNextPageToken(), nil
1001 }
1002 fetch := func(pageSize int, pageToken string) (string, error) {
1003 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1004 if err != nil {
1005 return "", err
1006 }
1007 it.items = append(it.items, items...)
1008 return nextPageToken, nil
1009 }
1010
1011 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1012 it.pageInfo.MaxSize = int(req.GetPageSize())
1013 it.pageInfo.Token = req.GetPageToken()
1014
1015 return it
1016 }
1017
1018 func (c *dataprocMetastoreGRPCClient) GetService(ctx context.Context, req *metastorepb.GetServiceRequest, opts ...gax.CallOption) (*metastorepb.Service, error) {
1019 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1020
1021 hds = append(c.xGoogHeaders, hds...)
1022 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1023 opts = append((*c.CallOptions).GetService[0:len((*c.CallOptions).GetService):len((*c.CallOptions).GetService)], opts...)
1024 var resp *metastorepb.Service
1025 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1026 var err error
1027 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.GetService, req, settings.GRPC, c.logger, "GetService")
1028 return err
1029 }, opts...)
1030 if err != nil {
1031 return nil, err
1032 }
1033 return resp, nil
1034 }
1035
1036 func (c *dataprocMetastoreGRPCClient) CreateService(ctx context.Context, req *metastorepb.CreateServiceRequest, opts ...gax.CallOption) (*CreateServiceOperation, error) {
1037 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1038
1039 hds = append(c.xGoogHeaders, hds...)
1040 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1041 opts = append((*c.CallOptions).CreateService[0:len((*c.CallOptions).CreateService):len((*c.CallOptions).CreateService)], opts...)
1042 var resp *longrunningpb.Operation
1043 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1044 var err error
1045 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.CreateService, req, settings.GRPC, c.logger, "CreateService")
1046 return err
1047 }, opts...)
1048 if err != nil {
1049 return nil, err
1050 }
1051 return &CreateServiceOperation{
1052 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1053 }, nil
1054 }
1055
1056 func (c *dataprocMetastoreGRPCClient) UpdateService(ctx context.Context, req *metastorepb.UpdateServiceRequest, opts ...gax.CallOption) (*UpdateServiceOperation, error) {
1057 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service.name", url.QueryEscape(req.GetService().GetName()))}
1058
1059 hds = append(c.xGoogHeaders, hds...)
1060 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1061 opts = append((*c.CallOptions).UpdateService[0:len((*c.CallOptions).UpdateService):len((*c.CallOptions).UpdateService)], opts...)
1062 var resp *longrunningpb.Operation
1063 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1064 var err error
1065 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.UpdateService, req, settings.GRPC, c.logger, "UpdateService")
1066 return err
1067 }, opts...)
1068 if err != nil {
1069 return nil, err
1070 }
1071 return &UpdateServiceOperation{
1072 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1073 }, nil
1074 }
1075
1076 func (c *dataprocMetastoreGRPCClient) DeleteService(ctx context.Context, req *metastorepb.DeleteServiceRequest, opts ...gax.CallOption) (*DeleteServiceOperation, error) {
1077 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1078
1079 hds = append(c.xGoogHeaders, hds...)
1080 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1081 opts = append((*c.CallOptions).DeleteService[0:len((*c.CallOptions).DeleteService):len((*c.CallOptions).DeleteService)], opts...)
1082 var resp *longrunningpb.Operation
1083 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1084 var err error
1085 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.DeleteService, req, settings.GRPC, c.logger, "DeleteService")
1086 return err
1087 }, opts...)
1088 if err != nil {
1089 return nil, err
1090 }
1091 return &DeleteServiceOperation{
1092 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1093 }, nil
1094 }
1095
1096 func (c *dataprocMetastoreGRPCClient) ListMetadataImports(ctx context.Context, req *metastorepb.ListMetadataImportsRequest, opts ...gax.CallOption) *MetadataImportIterator {
1097 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1098
1099 hds = append(c.xGoogHeaders, hds...)
1100 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1101 opts = append((*c.CallOptions).ListMetadataImports[0:len((*c.CallOptions).ListMetadataImports):len((*c.CallOptions).ListMetadataImports)], opts...)
1102 it := &MetadataImportIterator{}
1103 req = proto.Clone(req).(*metastorepb.ListMetadataImportsRequest)
1104 it.InternalFetch = func(pageSize int, pageToken string) ([]*metastorepb.MetadataImport, string, error) {
1105 resp := &metastorepb.ListMetadataImportsResponse{}
1106 if pageToken != "" {
1107 req.PageToken = pageToken
1108 }
1109 if pageSize > math.MaxInt32 {
1110 req.PageSize = math.MaxInt32
1111 } else if pageSize != 0 {
1112 req.PageSize = int32(pageSize)
1113 }
1114 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1115 var err error
1116 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.ListMetadataImports, req, settings.GRPC, c.logger, "ListMetadataImports")
1117 return err
1118 }, opts...)
1119 if err != nil {
1120 return nil, "", err
1121 }
1122
1123 it.Response = resp
1124 return resp.GetMetadataImports(), resp.GetNextPageToken(), nil
1125 }
1126 fetch := func(pageSize int, pageToken string) (string, error) {
1127 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1128 if err != nil {
1129 return "", err
1130 }
1131 it.items = append(it.items, items...)
1132 return nextPageToken, nil
1133 }
1134
1135 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1136 it.pageInfo.MaxSize = int(req.GetPageSize())
1137 it.pageInfo.Token = req.GetPageToken()
1138
1139 return it
1140 }
1141
1142 func (c *dataprocMetastoreGRPCClient) GetMetadataImport(ctx context.Context, req *metastorepb.GetMetadataImportRequest, opts ...gax.CallOption) (*metastorepb.MetadataImport, error) {
1143 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1144
1145 hds = append(c.xGoogHeaders, hds...)
1146 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1147 opts = append((*c.CallOptions).GetMetadataImport[0:len((*c.CallOptions).GetMetadataImport):len((*c.CallOptions).GetMetadataImport)], opts...)
1148 var resp *metastorepb.MetadataImport
1149 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1150 var err error
1151 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.GetMetadataImport, req, settings.GRPC, c.logger, "GetMetadataImport")
1152 return err
1153 }, opts...)
1154 if err != nil {
1155 return nil, err
1156 }
1157 return resp, nil
1158 }
1159
1160 func (c *dataprocMetastoreGRPCClient) CreateMetadataImport(ctx context.Context, req *metastorepb.CreateMetadataImportRequest, opts ...gax.CallOption) (*CreateMetadataImportOperation, error) {
1161 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1162
1163 hds = append(c.xGoogHeaders, hds...)
1164 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1165 opts = append((*c.CallOptions).CreateMetadataImport[0:len((*c.CallOptions).CreateMetadataImport):len((*c.CallOptions).CreateMetadataImport)], opts...)
1166 var resp *longrunningpb.Operation
1167 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1168 var err error
1169 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.CreateMetadataImport, req, settings.GRPC, c.logger, "CreateMetadataImport")
1170 return err
1171 }, opts...)
1172 if err != nil {
1173 return nil, err
1174 }
1175 return &CreateMetadataImportOperation{
1176 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1177 }, nil
1178 }
1179
1180 func (c *dataprocMetastoreGRPCClient) UpdateMetadataImport(ctx context.Context, req *metastorepb.UpdateMetadataImportRequest, opts ...gax.CallOption) (*UpdateMetadataImportOperation, error) {
1181 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "metadata_import.name", url.QueryEscape(req.GetMetadataImport().GetName()))}
1182
1183 hds = append(c.xGoogHeaders, hds...)
1184 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1185 opts = append((*c.CallOptions).UpdateMetadataImport[0:len((*c.CallOptions).UpdateMetadataImport):len((*c.CallOptions).UpdateMetadataImport)], opts...)
1186 var resp *longrunningpb.Operation
1187 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1188 var err error
1189 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.UpdateMetadataImport, req, settings.GRPC, c.logger, "UpdateMetadataImport")
1190 return err
1191 }, opts...)
1192 if err != nil {
1193 return nil, err
1194 }
1195 return &UpdateMetadataImportOperation{
1196 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1197 }, nil
1198 }
1199
1200 func (c *dataprocMetastoreGRPCClient) ExportMetadata(ctx context.Context, req *metastorepb.ExportMetadataRequest, opts ...gax.CallOption) (*ExportMetadataOperation, error) {
1201 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
1202
1203 hds = append(c.xGoogHeaders, hds...)
1204 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1205 opts = append((*c.CallOptions).ExportMetadata[0:len((*c.CallOptions).ExportMetadata):len((*c.CallOptions).ExportMetadata)], opts...)
1206 var resp *longrunningpb.Operation
1207 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1208 var err error
1209 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.ExportMetadata, req, settings.GRPC, c.logger, "ExportMetadata")
1210 return err
1211 }, opts...)
1212 if err != nil {
1213 return nil, err
1214 }
1215 return &ExportMetadataOperation{
1216 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1217 }, nil
1218 }
1219
1220 func (c *dataprocMetastoreGRPCClient) RestoreService(ctx context.Context, req *metastorepb.RestoreServiceRequest, opts ...gax.CallOption) (*RestoreServiceOperation, error) {
1221 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
1222
1223 hds = append(c.xGoogHeaders, hds...)
1224 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1225 opts = append((*c.CallOptions).RestoreService[0:len((*c.CallOptions).RestoreService):len((*c.CallOptions).RestoreService)], opts...)
1226 var resp *longrunningpb.Operation
1227 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1228 var err error
1229 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.RestoreService, req, settings.GRPC, c.logger, "RestoreService")
1230 return err
1231 }, opts...)
1232 if err != nil {
1233 return nil, err
1234 }
1235 return &RestoreServiceOperation{
1236 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1237 }, nil
1238 }
1239
1240 func (c *dataprocMetastoreGRPCClient) ListBackups(ctx context.Context, req *metastorepb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
1241 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1242
1243 hds = append(c.xGoogHeaders, hds...)
1244 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1245 opts = append((*c.CallOptions).ListBackups[0:len((*c.CallOptions).ListBackups):len((*c.CallOptions).ListBackups)], opts...)
1246 it := &BackupIterator{}
1247 req = proto.Clone(req).(*metastorepb.ListBackupsRequest)
1248 it.InternalFetch = func(pageSize int, pageToken string) ([]*metastorepb.Backup, string, error) {
1249 resp := &metastorepb.ListBackupsResponse{}
1250 if pageToken != "" {
1251 req.PageToken = pageToken
1252 }
1253 if pageSize > math.MaxInt32 {
1254 req.PageSize = math.MaxInt32
1255 } else if pageSize != 0 {
1256 req.PageSize = int32(pageSize)
1257 }
1258 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1259 var err error
1260 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.ListBackups, req, settings.GRPC, c.logger, "ListBackups")
1261 return err
1262 }, opts...)
1263 if err != nil {
1264 return nil, "", err
1265 }
1266
1267 it.Response = resp
1268 return resp.GetBackups(), resp.GetNextPageToken(), nil
1269 }
1270 fetch := func(pageSize int, pageToken string) (string, error) {
1271 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1272 if err != nil {
1273 return "", err
1274 }
1275 it.items = append(it.items, items...)
1276 return nextPageToken, nil
1277 }
1278
1279 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1280 it.pageInfo.MaxSize = int(req.GetPageSize())
1281 it.pageInfo.Token = req.GetPageToken()
1282
1283 return it
1284 }
1285
1286 func (c *dataprocMetastoreGRPCClient) GetBackup(ctx context.Context, req *metastorepb.GetBackupRequest, opts ...gax.CallOption) (*metastorepb.Backup, error) {
1287 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1288
1289 hds = append(c.xGoogHeaders, hds...)
1290 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1291 opts = append((*c.CallOptions).GetBackup[0:len((*c.CallOptions).GetBackup):len((*c.CallOptions).GetBackup)], opts...)
1292 var resp *metastorepb.Backup
1293 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1294 var err error
1295 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.GetBackup, req, settings.GRPC, c.logger, "GetBackup")
1296 return err
1297 }, opts...)
1298 if err != nil {
1299 return nil, err
1300 }
1301 return resp, nil
1302 }
1303
1304 func (c *dataprocMetastoreGRPCClient) CreateBackup(ctx context.Context, req *metastorepb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
1305 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1306
1307 hds = append(c.xGoogHeaders, hds...)
1308 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1309 opts = append((*c.CallOptions).CreateBackup[0:len((*c.CallOptions).CreateBackup):len((*c.CallOptions).CreateBackup)], opts...)
1310 var resp *longrunningpb.Operation
1311 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1312 var err error
1313 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.CreateBackup, req, settings.GRPC, c.logger, "CreateBackup")
1314 return err
1315 }, opts...)
1316 if err != nil {
1317 return nil, err
1318 }
1319 return &CreateBackupOperation{
1320 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1321 }, nil
1322 }
1323
1324 func (c *dataprocMetastoreGRPCClient) DeleteBackup(ctx context.Context, req *metastorepb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
1325 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1326
1327 hds = append(c.xGoogHeaders, hds...)
1328 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1329 opts = append((*c.CallOptions).DeleteBackup[0:len((*c.CallOptions).DeleteBackup):len((*c.CallOptions).DeleteBackup)], opts...)
1330 var resp *longrunningpb.Operation
1331 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1332 var err error
1333 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.DeleteBackup, req, settings.GRPC, c.logger, "DeleteBackup")
1334 return err
1335 }, opts...)
1336 if err != nil {
1337 return nil, err
1338 }
1339 return &DeleteBackupOperation{
1340 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1341 }, nil
1342 }
1343
1344 func (c *dataprocMetastoreGRPCClient) RemoveIamPolicy(ctx context.Context, req *metastorepb.RemoveIamPolicyRequest, opts ...gax.CallOption) (*metastorepb.RemoveIamPolicyResponse, error) {
1345 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1346
1347 hds = append(c.xGoogHeaders, hds...)
1348 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1349 opts = append((*c.CallOptions).RemoveIamPolicy[0:len((*c.CallOptions).RemoveIamPolicy):len((*c.CallOptions).RemoveIamPolicy)], opts...)
1350 var resp *metastorepb.RemoveIamPolicyResponse
1351 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1352 var err error
1353 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.RemoveIamPolicy, req, settings.GRPC, c.logger, "RemoveIamPolicy")
1354 return err
1355 }, opts...)
1356 if err != nil {
1357 return nil, err
1358 }
1359 return resp, nil
1360 }
1361
1362 func (c *dataprocMetastoreGRPCClient) QueryMetadata(ctx context.Context, req *metastorepb.QueryMetadataRequest, opts ...gax.CallOption) (*QueryMetadataOperation, error) {
1363 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
1364
1365 hds = append(c.xGoogHeaders, hds...)
1366 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1367 opts = append((*c.CallOptions).QueryMetadata[0:len((*c.CallOptions).QueryMetadata):len((*c.CallOptions).QueryMetadata)], opts...)
1368 var resp *longrunningpb.Operation
1369 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1370 var err error
1371 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.QueryMetadata, req, settings.GRPC, c.logger, "QueryMetadata")
1372 return err
1373 }, opts...)
1374 if err != nil {
1375 return nil, err
1376 }
1377 return &QueryMetadataOperation{
1378 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1379 }, nil
1380 }
1381
1382 func (c *dataprocMetastoreGRPCClient) MoveTableToDatabase(ctx context.Context, req *metastorepb.MoveTableToDatabaseRequest, opts ...gax.CallOption) (*MoveTableToDatabaseOperation, error) {
1383 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
1384
1385 hds = append(c.xGoogHeaders, hds...)
1386 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1387 opts = append((*c.CallOptions).MoveTableToDatabase[0:len((*c.CallOptions).MoveTableToDatabase):len((*c.CallOptions).MoveTableToDatabase)], opts...)
1388 var resp *longrunningpb.Operation
1389 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1390 var err error
1391 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.MoveTableToDatabase, req, settings.GRPC, c.logger, "MoveTableToDatabase")
1392 return err
1393 }, opts...)
1394 if err != nil {
1395 return nil, err
1396 }
1397 return &MoveTableToDatabaseOperation{
1398 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1399 }, nil
1400 }
1401
1402 func (c *dataprocMetastoreGRPCClient) AlterMetadataResourceLocation(ctx context.Context, req *metastorepb.AlterMetadataResourceLocationRequest, opts ...gax.CallOption) (*AlterMetadataResourceLocationOperation, error) {
1403 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
1404
1405 hds = append(c.xGoogHeaders, hds...)
1406 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1407 opts = append((*c.CallOptions).AlterMetadataResourceLocation[0:len((*c.CallOptions).AlterMetadataResourceLocation):len((*c.CallOptions).AlterMetadataResourceLocation)], opts...)
1408 var resp *longrunningpb.Operation
1409 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1410 var err error
1411 resp, err = executeRPC(ctx, c.dataprocMetastoreClient.AlterMetadataResourceLocation, req, settings.GRPC, c.logger, "AlterMetadataResourceLocation")
1412 return err
1413 }, opts...)
1414 if err != nil {
1415 return nil, err
1416 }
1417 return &AlterMetadataResourceLocationOperation{
1418 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1419 }, nil
1420 }
1421
1422 func (c *dataprocMetastoreGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1423 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1424
1425 hds = append(c.xGoogHeaders, hds...)
1426 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1427 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1428 var resp *locationpb.Location
1429 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1430 var err error
1431 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
1432 return err
1433 }, opts...)
1434 if err != nil {
1435 return nil, err
1436 }
1437 return resp, nil
1438 }
1439
1440 func (c *dataprocMetastoreGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1441 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1442
1443 hds = append(c.xGoogHeaders, hds...)
1444 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1445 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
1446 it := &LocationIterator{}
1447 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1448 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1449 resp := &locationpb.ListLocationsResponse{}
1450 if pageToken != "" {
1451 req.PageToken = pageToken
1452 }
1453 if pageSize > math.MaxInt32 {
1454 req.PageSize = math.MaxInt32
1455 } else if pageSize != 0 {
1456 req.PageSize = int32(pageSize)
1457 }
1458 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1459 var err error
1460 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
1461 return err
1462 }, opts...)
1463 if err != nil {
1464 return nil, "", err
1465 }
1466
1467 it.Response = resp
1468 return resp.GetLocations(), resp.GetNextPageToken(), nil
1469 }
1470 fetch := func(pageSize int, pageToken string) (string, error) {
1471 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1472 if err != nil {
1473 return "", err
1474 }
1475 it.items = append(it.items, items...)
1476 return nextPageToken, nil
1477 }
1478
1479 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1480 it.pageInfo.MaxSize = int(req.GetPageSize())
1481 it.pageInfo.Token = req.GetPageToken()
1482
1483 return it
1484 }
1485
1486 func (c *dataprocMetastoreGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1487 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1488
1489 hds = append(c.xGoogHeaders, hds...)
1490 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1491 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
1492 var resp *iampb.Policy
1493 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1494 var err error
1495 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
1496 return err
1497 }, opts...)
1498 if err != nil {
1499 return nil, err
1500 }
1501 return resp, nil
1502 }
1503
1504 func (c *dataprocMetastoreGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1505 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1506
1507 hds = append(c.xGoogHeaders, hds...)
1508 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1509 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
1510 var resp *iampb.Policy
1511 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1512 var err error
1513 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
1514 return err
1515 }, opts...)
1516 if err != nil {
1517 return nil, err
1518 }
1519 return resp, nil
1520 }
1521
1522 func (c *dataprocMetastoreGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
1523 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1524
1525 hds = append(c.xGoogHeaders, hds...)
1526 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1527 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
1528 var resp *iampb.TestIamPermissionsResponse
1529 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1530 var err error
1531 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
1532 return err
1533 }, opts...)
1534 if err != nil {
1535 return nil, err
1536 }
1537 return resp, nil
1538 }
1539
1540 func (c *dataprocMetastoreGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1541 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1542
1543 hds = append(c.xGoogHeaders, hds...)
1544 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1545 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
1546 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1547 var err error
1548 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
1549 return err
1550 }, opts...)
1551 return err
1552 }
1553
1554 func (c *dataprocMetastoreGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
1555 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1556
1557 hds = append(c.xGoogHeaders, hds...)
1558 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1559 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
1560 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1561 var err error
1562 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
1563 return err
1564 }, opts...)
1565 return err
1566 }
1567
1568 func (c *dataprocMetastoreGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1569 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1570
1571 hds = append(c.xGoogHeaders, hds...)
1572 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1573 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1574 var resp *longrunningpb.Operation
1575 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1576 var err error
1577 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
1578 return err
1579 }, opts...)
1580 if err != nil {
1581 return nil, err
1582 }
1583 return resp, nil
1584 }
1585
1586 func (c *dataprocMetastoreGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1587 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1588
1589 hds = append(c.xGoogHeaders, hds...)
1590 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1591 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
1592 it := &OperationIterator{}
1593 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
1594 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
1595 resp := &longrunningpb.ListOperationsResponse{}
1596 if pageToken != "" {
1597 req.PageToken = pageToken
1598 }
1599 if pageSize > math.MaxInt32 {
1600 req.PageSize = math.MaxInt32
1601 } else if pageSize != 0 {
1602 req.PageSize = int32(pageSize)
1603 }
1604 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1605 var err error
1606 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
1607 return err
1608 }, opts...)
1609 if err != nil {
1610 return nil, "", err
1611 }
1612
1613 it.Response = resp
1614 return resp.GetOperations(), resp.GetNextPageToken(), nil
1615 }
1616 fetch := func(pageSize int, pageToken string) (string, error) {
1617 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1618 if err != nil {
1619 return "", err
1620 }
1621 it.items = append(it.items, items...)
1622 return nextPageToken, nil
1623 }
1624
1625 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1626 it.pageInfo.MaxSize = int(req.GetPageSize())
1627 it.pageInfo.Token = req.GetPageToken()
1628
1629 return it
1630 }
1631
1632 // ListServices lists services in a project and location.
1633 func (c *dataprocMetastoreRESTClient) ListServices(ctx context.Context, req *metastorepb.ListServicesRequest, opts ...gax.CallOption) *ServiceIterator {
1634 it := &ServiceIterator{}
1635 req = proto.Clone(req).(*metastorepb.ListServicesRequest)
1636 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1637 it.InternalFetch = func(pageSize int, pageToken string) ([]*metastorepb.Service, string, error) {
1638 resp := &metastorepb.ListServicesResponse{}
1639 if pageToken != "" {
1640 req.PageToken = pageToken
1641 }
1642 if pageSize > math.MaxInt32 {
1643 req.PageSize = math.MaxInt32
1644 } else if pageSize != 0 {
1645 req.PageSize = int32(pageSize)
1646 }
1647 baseUrl, err := url.Parse(c.endpoint)
1648 if err != nil {
1649 return nil, "", err
1650 }
1651 baseUrl.Path += fmt.Sprintf("/v1beta/%v/services", req.GetParent())
1652
1653 params := url.Values{}
1654 params.Add("$alt", "json;enum-encoding=int")
1655 if req.GetFilter() != "" {
1656 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1657 }
1658 if req.GetOrderBy() != "" {
1659 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
1660 }
1661 if req.GetPageSize() != 0 {
1662 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1663 }
1664 if req.GetPageToken() != "" {
1665 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1666 }
1667
1668 baseUrl.RawQuery = params.Encode()
1669
1670 // Build HTTP headers from client and context metadata.
1671 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1672 headers := gax.BuildHeaders(ctx, hds...)
1673 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1674 if settings.Path != "" {
1675 baseUrl.Path = settings.Path
1676 }
1677 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1678 if err != nil {
1679 return err
1680 }
1681 httpReq.Header = headers
1682
1683 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListServices")
1684 if err != nil {
1685 return err
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 it.Response = resp
1697 return resp.GetServices(), resp.GetNextPageToken(), nil
1698 }
1699
1700 fetch := func(pageSize int, pageToken string) (string, error) {
1701 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1702 if err != nil {
1703 return "", err
1704 }
1705 it.items = append(it.items, items...)
1706 return nextPageToken, nil
1707 }
1708
1709 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1710 it.pageInfo.MaxSize = int(req.GetPageSize())
1711 it.pageInfo.Token = req.GetPageToken()
1712
1713 return it
1714 }
1715
1716 // GetService gets the details of a single service.
1717 func (c *dataprocMetastoreRESTClient) GetService(ctx context.Context, req *metastorepb.GetServiceRequest, opts ...gax.CallOption) (*metastorepb.Service, error) {
1718 baseUrl, err := url.Parse(c.endpoint)
1719 if err != nil {
1720 return nil, err
1721 }
1722 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
1723
1724 params := url.Values{}
1725 params.Add("$alt", "json;enum-encoding=int")
1726
1727 baseUrl.RawQuery = params.Encode()
1728
1729 // Build HTTP headers from client and context metadata.
1730 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1731
1732 hds = append(c.xGoogHeaders, hds...)
1733 hds = append(hds, "Content-Type", "application/json")
1734 headers := gax.BuildHeaders(ctx, hds...)
1735 opts = append((*c.CallOptions).GetService[0:len((*c.CallOptions).GetService):len((*c.CallOptions).GetService)], opts...)
1736 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1737 resp := &metastorepb.Service{}
1738 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1739 if settings.Path != "" {
1740 baseUrl.Path = settings.Path
1741 }
1742 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1743 if err != nil {
1744 return err
1745 }
1746 httpReq = httpReq.WithContext(ctx)
1747 httpReq.Header = headers
1748
1749 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetService")
1750 if err != nil {
1751 return err
1752 }
1753
1754 if err := unm.Unmarshal(buf, resp); err != nil {
1755 return err
1756 }
1757
1758 return nil
1759 }, opts...)
1760 if e != nil {
1761 return nil, e
1762 }
1763 return resp, nil
1764 }
1765
1766 // CreateService creates a metastore service in a project and location.
1767 func (c *dataprocMetastoreRESTClient) CreateService(ctx context.Context, req *metastorepb.CreateServiceRequest, opts ...gax.CallOption) (*CreateServiceOperation, error) {
1768 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1769 body := req.GetService()
1770 jsonReq, err := m.Marshal(body)
1771 if err != nil {
1772 return nil, err
1773 }
1774
1775 baseUrl, err := url.Parse(c.endpoint)
1776 if err != nil {
1777 return nil, err
1778 }
1779 baseUrl.Path += fmt.Sprintf("/v1beta/%v/services", req.GetParent())
1780
1781 params := url.Values{}
1782 params.Add("$alt", "json;enum-encoding=int")
1783 if req.GetRequestId() != "" {
1784 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1785 }
1786 params.Add("serviceId", fmt.Sprintf("%v", req.GetServiceId()))
1787
1788 baseUrl.RawQuery = params.Encode()
1789
1790 // Build HTTP headers from client and context metadata.
1791 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1792
1793 hds = append(c.xGoogHeaders, hds...)
1794 hds = append(hds, "Content-Type", "application/json")
1795 headers := gax.BuildHeaders(ctx, hds...)
1796 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1797 resp := &longrunningpb.Operation{}
1798 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1799 if settings.Path != "" {
1800 baseUrl.Path = settings.Path
1801 }
1802 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1803 if err != nil {
1804 return err
1805 }
1806 httpReq = httpReq.WithContext(ctx)
1807 httpReq.Header = headers
1808
1809 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateService")
1810 if err != nil {
1811 return err
1812 }
1813 if err := unm.Unmarshal(buf, resp); err != nil {
1814 return err
1815 }
1816
1817 return nil
1818 }, opts...)
1819 if e != nil {
1820 return nil, e
1821 }
1822
1823 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
1824 return &CreateServiceOperation{
1825 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1826 pollPath: override,
1827 }, nil
1828 }
1829
1830 // UpdateService updates the parameters of a single service.
1831 func (c *dataprocMetastoreRESTClient) UpdateService(ctx context.Context, req *metastorepb.UpdateServiceRequest, opts ...gax.CallOption) (*UpdateServiceOperation, error) {
1832 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1833 body := req.GetService()
1834 jsonReq, err := m.Marshal(body)
1835 if err != nil {
1836 return nil, err
1837 }
1838
1839 baseUrl, err := url.Parse(c.endpoint)
1840 if err != nil {
1841 return nil, err
1842 }
1843 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetService().GetName())
1844
1845 params := url.Values{}
1846 params.Add("$alt", "json;enum-encoding=int")
1847 if req.GetRequestId() != "" {
1848 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1849 }
1850 if req.GetUpdateMask() != nil {
1851 field, err := protojson.Marshal(req.GetUpdateMask())
1852 if err != nil {
1853 return nil, err
1854 }
1855 params.Add("updateMask", string(field[1:len(field)-1]))
1856 }
1857
1858 baseUrl.RawQuery = params.Encode()
1859
1860 // Build HTTP headers from client and context metadata.
1861 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service.name", url.QueryEscape(req.GetService().GetName()))}
1862
1863 hds = append(c.xGoogHeaders, hds...)
1864 hds = append(hds, "Content-Type", "application/json")
1865 headers := gax.BuildHeaders(ctx, hds...)
1866 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1867 resp := &longrunningpb.Operation{}
1868 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1869 if settings.Path != "" {
1870 baseUrl.Path = settings.Path
1871 }
1872 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1873 if err != nil {
1874 return err
1875 }
1876 httpReq = httpReq.WithContext(ctx)
1877 httpReq.Header = headers
1878
1879 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateService")
1880 if err != nil {
1881 return err
1882 }
1883 if err := unm.Unmarshal(buf, resp); err != nil {
1884 return err
1885 }
1886
1887 return nil
1888 }, opts...)
1889 if e != nil {
1890 return nil, e
1891 }
1892
1893 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
1894 return &UpdateServiceOperation{
1895 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1896 pollPath: override,
1897 }, nil
1898 }
1899
1900 // DeleteService deletes a single service.
1901 func (c *dataprocMetastoreRESTClient) DeleteService(ctx context.Context, req *metastorepb.DeleteServiceRequest, opts ...gax.CallOption) (*DeleteServiceOperation, error) {
1902 baseUrl, err := url.Parse(c.endpoint)
1903 if err != nil {
1904 return nil, err
1905 }
1906 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
1907
1908 params := url.Values{}
1909 params.Add("$alt", "json;enum-encoding=int")
1910 if req.GetRequestId() != "" {
1911 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1912 }
1913
1914 baseUrl.RawQuery = params.Encode()
1915
1916 // Build HTTP headers from client and context metadata.
1917 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1918
1919 hds = append(c.xGoogHeaders, hds...)
1920 hds = append(hds, "Content-Type", "application/json")
1921 headers := gax.BuildHeaders(ctx, hds...)
1922 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1923 resp := &longrunningpb.Operation{}
1924 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1925 if settings.Path != "" {
1926 baseUrl.Path = settings.Path
1927 }
1928 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1929 if err != nil {
1930 return err
1931 }
1932 httpReq = httpReq.WithContext(ctx)
1933 httpReq.Header = headers
1934
1935 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteService")
1936 if err != nil {
1937 return err
1938 }
1939 if err := unm.Unmarshal(buf, resp); err != nil {
1940 return err
1941 }
1942
1943 return nil
1944 }, opts...)
1945 if e != nil {
1946 return nil, e
1947 }
1948
1949 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
1950 return &DeleteServiceOperation{
1951 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1952 pollPath: override,
1953 }, nil
1954 }
1955
1956 // ListMetadataImports lists imports in a service.
1957 func (c *dataprocMetastoreRESTClient) ListMetadataImports(ctx context.Context, req *metastorepb.ListMetadataImportsRequest, opts ...gax.CallOption) *MetadataImportIterator {
1958 it := &MetadataImportIterator{}
1959 req = proto.Clone(req).(*metastorepb.ListMetadataImportsRequest)
1960 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1961 it.InternalFetch = func(pageSize int, pageToken string) ([]*metastorepb.MetadataImport, string, error) {
1962 resp := &metastorepb.ListMetadataImportsResponse{}
1963 if pageToken != "" {
1964 req.PageToken = pageToken
1965 }
1966 if pageSize > math.MaxInt32 {
1967 req.PageSize = math.MaxInt32
1968 } else if pageSize != 0 {
1969 req.PageSize = int32(pageSize)
1970 }
1971 baseUrl, err := url.Parse(c.endpoint)
1972 if err != nil {
1973 return nil, "", err
1974 }
1975 baseUrl.Path += fmt.Sprintf("/v1beta/%v/metadataImports", req.GetParent())
1976
1977 params := url.Values{}
1978 params.Add("$alt", "json;enum-encoding=int")
1979 if req.GetFilter() != "" {
1980 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1981 }
1982 if req.GetOrderBy() != "" {
1983 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
1984 }
1985 if req.GetPageSize() != 0 {
1986 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1987 }
1988 if req.GetPageToken() != "" {
1989 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1990 }
1991
1992 baseUrl.RawQuery = params.Encode()
1993
1994 // Build HTTP headers from client and context metadata.
1995 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1996 headers := gax.BuildHeaders(ctx, hds...)
1997 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1998 if settings.Path != "" {
1999 baseUrl.Path = settings.Path
2000 }
2001 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2002 if err != nil {
2003 return err
2004 }
2005 httpReq.Header = headers
2006
2007 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListMetadataImports")
2008 if err != nil {
2009 return err
2010 }
2011 if err := unm.Unmarshal(buf, resp); err != nil {
2012 return err
2013 }
2014
2015 return nil
2016 }, opts...)
2017 if e != nil {
2018 return nil, "", e
2019 }
2020 it.Response = resp
2021 return resp.GetMetadataImports(), resp.GetNextPageToken(), nil
2022 }
2023
2024 fetch := func(pageSize int, pageToken string) (string, error) {
2025 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2026 if err != nil {
2027 return "", err
2028 }
2029 it.items = append(it.items, items...)
2030 return nextPageToken, nil
2031 }
2032
2033 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2034 it.pageInfo.MaxSize = int(req.GetPageSize())
2035 it.pageInfo.Token = req.GetPageToken()
2036
2037 return it
2038 }
2039
2040 // GetMetadataImport gets details of a single import.
2041 func (c *dataprocMetastoreRESTClient) GetMetadataImport(ctx context.Context, req *metastorepb.GetMetadataImportRequest, opts ...gax.CallOption) (*metastorepb.MetadataImport, error) {
2042 baseUrl, err := url.Parse(c.endpoint)
2043 if err != nil {
2044 return nil, err
2045 }
2046 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
2047
2048 params := url.Values{}
2049 params.Add("$alt", "json;enum-encoding=int")
2050
2051 baseUrl.RawQuery = params.Encode()
2052
2053 // Build HTTP headers from client and context metadata.
2054 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2055
2056 hds = append(c.xGoogHeaders, hds...)
2057 hds = append(hds, "Content-Type", "application/json")
2058 headers := gax.BuildHeaders(ctx, hds...)
2059 opts = append((*c.CallOptions).GetMetadataImport[0:len((*c.CallOptions).GetMetadataImport):len((*c.CallOptions).GetMetadataImport)], opts...)
2060 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2061 resp := &metastorepb.MetadataImport{}
2062 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2063 if settings.Path != "" {
2064 baseUrl.Path = settings.Path
2065 }
2066 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2067 if err != nil {
2068 return err
2069 }
2070 httpReq = httpReq.WithContext(ctx)
2071 httpReq.Header = headers
2072
2073 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetMetadataImport")
2074 if err != nil {
2075 return err
2076 }
2077
2078 if err := unm.Unmarshal(buf, resp); err != nil {
2079 return err
2080 }
2081
2082 return nil
2083 }, opts...)
2084 if e != nil {
2085 return nil, e
2086 }
2087 return resp, nil
2088 }
2089
2090 // CreateMetadataImport creates a new MetadataImport in a given project and location.
2091 func (c *dataprocMetastoreRESTClient) CreateMetadataImport(ctx context.Context, req *metastorepb.CreateMetadataImportRequest, opts ...gax.CallOption) (*CreateMetadataImportOperation, error) {
2092 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2093 body := req.GetMetadataImport()
2094 jsonReq, err := m.Marshal(body)
2095 if err != nil {
2096 return nil, err
2097 }
2098
2099 baseUrl, err := url.Parse(c.endpoint)
2100 if err != nil {
2101 return nil, err
2102 }
2103 baseUrl.Path += fmt.Sprintf("/v1beta/%v/metadataImports", req.GetParent())
2104
2105 params := url.Values{}
2106 params.Add("$alt", "json;enum-encoding=int")
2107 params.Add("metadataImportId", fmt.Sprintf("%v", req.GetMetadataImportId()))
2108 if req.GetRequestId() != "" {
2109 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2110 }
2111
2112 baseUrl.RawQuery = params.Encode()
2113
2114 // Build HTTP headers from client and context metadata.
2115 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2116
2117 hds = append(c.xGoogHeaders, hds...)
2118 hds = append(hds, "Content-Type", "application/json")
2119 headers := gax.BuildHeaders(ctx, hds...)
2120 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2121 resp := &longrunningpb.Operation{}
2122 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2123 if settings.Path != "" {
2124 baseUrl.Path = settings.Path
2125 }
2126 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2127 if err != nil {
2128 return err
2129 }
2130 httpReq = httpReq.WithContext(ctx)
2131 httpReq.Header = headers
2132
2133 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateMetadataImport")
2134 if err != nil {
2135 return err
2136 }
2137 if err := unm.Unmarshal(buf, resp); err != nil {
2138 return err
2139 }
2140
2141 return nil
2142 }, opts...)
2143 if e != nil {
2144 return nil, e
2145 }
2146
2147 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2148 return &CreateMetadataImportOperation{
2149 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2150 pollPath: override,
2151 }, nil
2152 }
2153
2154 // UpdateMetadataImport updates a single import.
2155 // Only the description field of MetadataImport is supported to be updated.
2156 func (c *dataprocMetastoreRESTClient) UpdateMetadataImport(ctx context.Context, req *metastorepb.UpdateMetadataImportRequest, opts ...gax.CallOption) (*UpdateMetadataImportOperation, error) {
2157 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2158 body := req.GetMetadataImport()
2159 jsonReq, err := m.Marshal(body)
2160 if err != nil {
2161 return nil, err
2162 }
2163
2164 baseUrl, err := url.Parse(c.endpoint)
2165 if err != nil {
2166 return nil, err
2167 }
2168 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetMetadataImport().GetName())
2169
2170 params := url.Values{}
2171 params.Add("$alt", "json;enum-encoding=int")
2172 if req.GetRequestId() != "" {
2173 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2174 }
2175 if req.GetUpdateMask() != nil {
2176 field, err := protojson.Marshal(req.GetUpdateMask())
2177 if err != nil {
2178 return nil, err
2179 }
2180 params.Add("updateMask", string(field[1:len(field)-1]))
2181 }
2182
2183 baseUrl.RawQuery = params.Encode()
2184
2185 // Build HTTP headers from client and context metadata.
2186 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "metadata_import.name", url.QueryEscape(req.GetMetadataImport().GetName()))}
2187
2188 hds = append(c.xGoogHeaders, hds...)
2189 hds = append(hds, "Content-Type", "application/json")
2190 headers := gax.BuildHeaders(ctx, hds...)
2191 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2192 resp := &longrunningpb.Operation{}
2193 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2194 if settings.Path != "" {
2195 baseUrl.Path = settings.Path
2196 }
2197 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2198 if err != nil {
2199 return err
2200 }
2201 httpReq = httpReq.WithContext(ctx)
2202 httpReq.Header = headers
2203
2204 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateMetadataImport")
2205 if err != nil {
2206 return err
2207 }
2208 if err := unm.Unmarshal(buf, resp); err != nil {
2209 return err
2210 }
2211
2212 return nil
2213 }, opts...)
2214 if e != nil {
2215 return nil, e
2216 }
2217
2218 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2219 return &UpdateMetadataImportOperation{
2220 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2221 pollPath: override,
2222 }, nil
2223 }
2224
2225 // ExportMetadata exports metadata from a service.
2226 func (c *dataprocMetastoreRESTClient) ExportMetadata(ctx context.Context, req *metastorepb.ExportMetadataRequest, opts ...gax.CallOption) (*ExportMetadataOperation, error) {
2227 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2228 jsonReq, err := m.Marshal(req)
2229 if err != nil {
2230 return nil, err
2231 }
2232
2233 baseUrl, err := url.Parse(c.endpoint)
2234 if err != nil {
2235 return nil, err
2236 }
2237 baseUrl.Path += fmt.Sprintf("/v1beta/%v:exportMetadata", req.GetService())
2238
2239 params := url.Values{}
2240 params.Add("$alt", "json;enum-encoding=int")
2241
2242 baseUrl.RawQuery = params.Encode()
2243
2244 // Build HTTP headers from client and context metadata.
2245 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
2246
2247 hds = append(c.xGoogHeaders, hds...)
2248 hds = append(hds, "Content-Type", "application/json")
2249 headers := gax.BuildHeaders(ctx, hds...)
2250 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2251 resp := &longrunningpb.Operation{}
2252 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2253 if settings.Path != "" {
2254 baseUrl.Path = settings.Path
2255 }
2256 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2257 if err != nil {
2258 return err
2259 }
2260 httpReq = httpReq.WithContext(ctx)
2261 httpReq.Header = headers
2262
2263 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportMetadata")
2264 if err != nil {
2265 return err
2266 }
2267 if err := unm.Unmarshal(buf, resp); err != nil {
2268 return err
2269 }
2270
2271 return nil
2272 }, opts...)
2273 if e != nil {
2274 return nil, e
2275 }
2276
2277 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2278 return &ExportMetadataOperation{
2279 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2280 pollPath: override,
2281 }, nil
2282 }
2283
2284 // RestoreService restores a service from a backup.
2285 func (c *dataprocMetastoreRESTClient) RestoreService(ctx context.Context, req *metastorepb.RestoreServiceRequest, opts ...gax.CallOption) (*RestoreServiceOperation, error) {
2286 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2287 jsonReq, err := m.Marshal(req)
2288 if err != nil {
2289 return nil, err
2290 }
2291
2292 baseUrl, err := url.Parse(c.endpoint)
2293 if err != nil {
2294 return nil, err
2295 }
2296 baseUrl.Path += fmt.Sprintf("/v1beta/%v:restore", req.GetService())
2297
2298 params := url.Values{}
2299 params.Add("$alt", "json;enum-encoding=int")
2300
2301 baseUrl.RawQuery = params.Encode()
2302
2303 // Build HTTP headers from client and context metadata.
2304 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
2305
2306 hds = append(c.xGoogHeaders, hds...)
2307 hds = append(hds, "Content-Type", "application/json")
2308 headers := gax.BuildHeaders(ctx, hds...)
2309 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2310 resp := &longrunningpb.Operation{}
2311 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2312 if settings.Path != "" {
2313 baseUrl.Path = settings.Path
2314 }
2315 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2316 if err != nil {
2317 return err
2318 }
2319 httpReq = httpReq.WithContext(ctx)
2320 httpReq.Header = headers
2321
2322 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RestoreService")
2323 if err != nil {
2324 return err
2325 }
2326 if err := unm.Unmarshal(buf, resp); err != nil {
2327 return err
2328 }
2329
2330 return nil
2331 }, opts...)
2332 if e != nil {
2333 return nil, e
2334 }
2335
2336 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2337 return &RestoreServiceOperation{
2338 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2339 pollPath: override,
2340 }, nil
2341 }
2342
2343 // ListBackups lists backups in a service.
2344 func (c *dataprocMetastoreRESTClient) ListBackups(ctx context.Context, req *metastorepb.ListBackupsRequest, opts ...gax.CallOption) *BackupIterator {
2345 it := &BackupIterator{}
2346 req = proto.Clone(req).(*metastorepb.ListBackupsRequest)
2347 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2348 it.InternalFetch = func(pageSize int, pageToken string) ([]*metastorepb.Backup, string, error) {
2349 resp := &metastorepb.ListBackupsResponse{}
2350 if pageToken != "" {
2351 req.PageToken = pageToken
2352 }
2353 if pageSize > math.MaxInt32 {
2354 req.PageSize = math.MaxInt32
2355 } else if pageSize != 0 {
2356 req.PageSize = int32(pageSize)
2357 }
2358 baseUrl, err := url.Parse(c.endpoint)
2359 if err != nil {
2360 return nil, "", err
2361 }
2362 baseUrl.Path += fmt.Sprintf("/v1beta/%v/backups", req.GetParent())
2363
2364 params := url.Values{}
2365 params.Add("$alt", "json;enum-encoding=int")
2366 if req.GetFilter() != "" {
2367 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2368 }
2369 if req.GetOrderBy() != "" {
2370 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2371 }
2372 if req.GetPageSize() != 0 {
2373 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2374 }
2375 if req.GetPageToken() != "" {
2376 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2377 }
2378
2379 baseUrl.RawQuery = params.Encode()
2380
2381 // Build HTTP headers from client and context metadata.
2382 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2383 headers := gax.BuildHeaders(ctx, hds...)
2384 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2385 if settings.Path != "" {
2386 baseUrl.Path = settings.Path
2387 }
2388 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2389 if err != nil {
2390 return err
2391 }
2392 httpReq.Header = headers
2393
2394 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListBackups")
2395 if err != nil {
2396 return err
2397 }
2398 if err := unm.Unmarshal(buf, resp); err != nil {
2399 return err
2400 }
2401
2402 return nil
2403 }, opts...)
2404 if e != nil {
2405 return nil, "", e
2406 }
2407 it.Response = resp
2408 return resp.GetBackups(), resp.GetNextPageToken(), nil
2409 }
2410
2411 fetch := func(pageSize int, pageToken string) (string, error) {
2412 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2413 if err != nil {
2414 return "", err
2415 }
2416 it.items = append(it.items, items...)
2417 return nextPageToken, nil
2418 }
2419
2420 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2421 it.pageInfo.MaxSize = int(req.GetPageSize())
2422 it.pageInfo.Token = req.GetPageToken()
2423
2424 return it
2425 }
2426
2427 // GetBackup gets details of a single backup.
2428 func (c *dataprocMetastoreRESTClient) GetBackup(ctx context.Context, req *metastorepb.GetBackupRequest, opts ...gax.CallOption) (*metastorepb.Backup, error) {
2429 baseUrl, err := url.Parse(c.endpoint)
2430 if err != nil {
2431 return nil, err
2432 }
2433 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
2434
2435 params := url.Values{}
2436 params.Add("$alt", "json;enum-encoding=int")
2437
2438 baseUrl.RawQuery = params.Encode()
2439
2440 // Build HTTP headers from client and context metadata.
2441 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2442
2443 hds = append(c.xGoogHeaders, hds...)
2444 hds = append(hds, "Content-Type", "application/json")
2445 headers := gax.BuildHeaders(ctx, hds...)
2446 opts = append((*c.CallOptions).GetBackup[0:len((*c.CallOptions).GetBackup):len((*c.CallOptions).GetBackup)], opts...)
2447 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2448 resp := &metastorepb.Backup{}
2449 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2450 if settings.Path != "" {
2451 baseUrl.Path = settings.Path
2452 }
2453 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2454 if err != nil {
2455 return err
2456 }
2457 httpReq = httpReq.WithContext(ctx)
2458 httpReq.Header = headers
2459
2460 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetBackup")
2461 if err != nil {
2462 return err
2463 }
2464
2465 if err := unm.Unmarshal(buf, resp); err != nil {
2466 return err
2467 }
2468
2469 return nil
2470 }, opts...)
2471 if e != nil {
2472 return nil, e
2473 }
2474 return resp, nil
2475 }
2476
2477 // CreateBackup creates a new backup in a given project and location.
2478 func (c *dataprocMetastoreRESTClient) CreateBackup(ctx context.Context, req *metastorepb.CreateBackupRequest, opts ...gax.CallOption) (*CreateBackupOperation, error) {
2479 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2480 body := req.GetBackup()
2481 jsonReq, err := m.Marshal(body)
2482 if err != nil {
2483 return nil, err
2484 }
2485
2486 baseUrl, err := url.Parse(c.endpoint)
2487 if err != nil {
2488 return nil, err
2489 }
2490 baseUrl.Path += fmt.Sprintf("/v1beta/%v/backups", req.GetParent())
2491
2492 params := url.Values{}
2493 params.Add("$alt", "json;enum-encoding=int")
2494 params.Add("backupId", fmt.Sprintf("%v", req.GetBackupId()))
2495 if req.GetRequestId() != "" {
2496 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2497 }
2498
2499 baseUrl.RawQuery = params.Encode()
2500
2501 // Build HTTP headers from client and context metadata.
2502 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2503
2504 hds = append(c.xGoogHeaders, hds...)
2505 hds = append(hds, "Content-Type", "application/json")
2506 headers := gax.BuildHeaders(ctx, hds...)
2507 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2508 resp := &longrunningpb.Operation{}
2509 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2510 if settings.Path != "" {
2511 baseUrl.Path = settings.Path
2512 }
2513 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2514 if err != nil {
2515 return err
2516 }
2517 httpReq = httpReq.WithContext(ctx)
2518 httpReq.Header = headers
2519
2520 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateBackup")
2521 if err != nil {
2522 return err
2523 }
2524 if err := unm.Unmarshal(buf, resp); err != nil {
2525 return err
2526 }
2527
2528 return nil
2529 }, opts...)
2530 if e != nil {
2531 return nil, e
2532 }
2533
2534 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2535 return &CreateBackupOperation{
2536 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2537 pollPath: override,
2538 }, nil
2539 }
2540
2541 // DeleteBackup deletes a single backup.
2542 func (c *dataprocMetastoreRESTClient) DeleteBackup(ctx context.Context, req *metastorepb.DeleteBackupRequest, opts ...gax.CallOption) (*DeleteBackupOperation, error) {
2543 baseUrl, err := url.Parse(c.endpoint)
2544 if err != nil {
2545 return nil, err
2546 }
2547 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
2548
2549 params := url.Values{}
2550 params.Add("$alt", "json;enum-encoding=int")
2551 if req.GetRequestId() != "" {
2552 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
2553 }
2554
2555 baseUrl.RawQuery = params.Encode()
2556
2557 // Build HTTP headers from client and context metadata.
2558 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2559
2560 hds = append(c.xGoogHeaders, hds...)
2561 hds = append(hds, "Content-Type", "application/json")
2562 headers := gax.BuildHeaders(ctx, hds...)
2563 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2564 resp := &longrunningpb.Operation{}
2565 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2566 if settings.Path != "" {
2567 baseUrl.Path = settings.Path
2568 }
2569 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2570 if err != nil {
2571 return err
2572 }
2573 httpReq = httpReq.WithContext(ctx)
2574 httpReq.Header = headers
2575
2576 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteBackup")
2577 if err != nil {
2578 return err
2579 }
2580 if err := unm.Unmarshal(buf, resp); err != nil {
2581 return err
2582 }
2583
2584 return nil
2585 }, opts...)
2586 if e != nil {
2587 return nil, e
2588 }
2589
2590 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2591 return &DeleteBackupOperation{
2592 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2593 pollPath: override,
2594 }, nil
2595 }
2596
2597 // RemoveIamPolicy removes the attached IAM policies for a resource
2598 func (c *dataprocMetastoreRESTClient) RemoveIamPolicy(ctx context.Context, req *metastorepb.RemoveIamPolicyRequest, opts ...gax.CallOption) (*metastorepb.RemoveIamPolicyResponse, error) {
2599 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2600 jsonReq, err := m.Marshal(req)
2601 if err != nil {
2602 return nil, err
2603 }
2604
2605 baseUrl, err := url.Parse(c.endpoint)
2606 if err != nil {
2607 return nil, err
2608 }
2609 baseUrl.Path += fmt.Sprintf("/v1beta/%v:removeIamPolicy", req.GetResource())
2610
2611 params := url.Values{}
2612 params.Add("$alt", "json;enum-encoding=int")
2613
2614 baseUrl.RawQuery = params.Encode()
2615
2616 // Build HTTP headers from client and context metadata.
2617 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2618
2619 hds = append(c.xGoogHeaders, hds...)
2620 hds = append(hds, "Content-Type", "application/json")
2621 headers := gax.BuildHeaders(ctx, hds...)
2622 opts = append((*c.CallOptions).RemoveIamPolicy[0:len((*c.CallOptions).RemoveIamPolicy):len((*c.CallOptions).RemoveIamPolicy)], opts...)
2623 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2624 resp := &metastorepb.RemoveIamPolicyResponse{}
2625 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2626 if settings.Path != "" {
2627 baseUrl.Path = settings.Path
2628 }
2629 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2630 if err != nil {
2631 return err
2632 }
2633 httpReq = httpReq.WithContext(ctx)
2634 httpReq.Header = headers
2635
2636 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RemoveIamPolicy")
2637 if err != nil {
2638 return err
2639 }
2640
2641 if err := unm.Unmarshal(buf, resp); err != nil {
2642 return err
2643 }
2644
2645 return nil
2646 }, opts...)
2647 if e != nil {
2648 return nil, e
2649 }
2650 return resp, nil
2651 }
2652
2653 // QueryMetadata query DPMS metadata.
2654 func (c *dataprocMetastoreRESTClient) QueryMetadata(ctx context.Context, req *metastorepb.QueryMetadataRequest, opts ...gax.CallOption) (*QueryMetadataOperation, error) {
2655 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2656 jsonReq, err := m.Marshal(req)
2657 if err != nil {
2658 return nil, err
2659 }
2660
2661 baseUrl, err := url.Parse(c.endpoint)
2662 if err != nil {
2663 return nil, err
2664 }
2665 baseUrl.Path += fmt.Sprintf("/v1beta/%v:queryMetadata", req.GetService())
2666
2667 params := url.Values{}
2668 params.Add("$alt", "json;enum-encoding=int")
2669
2670 baseUrl.RawQuery = params.Encode()
2671
2672 // Build HTTP headers from client and context metadata.
2673 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
2674
2675 hds = append(c.xGoogHeaders, hds...)
2676 hds = append(hds, "Content-Type", "application/json")
2677 headers := gax.BuildHeaders(ctx, hds...)
2678 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2679 resp := &longrunningpb.Operation{}
2680 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2681 if settings.Path != "" {
2682 baseUrl.Path = settings.Path
2683 }
2684 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2685 if err != nil {
2686 return err
2687 }
2688 httpReq = httpReq.WithContext(ctx)
2689 httpReq.Header = headers
2690
2691 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "QueryMetadata")
2692 if err != nil {
2693 return err
2694 }
2695 if err := unm.Unmarshal(buf, resp); err != nil {
2696 return err
2697 }
2698
2699 return nil
2700 }, opts...)
2701 if e != nil {
2702 return nil, e
2703 }
2704
2705 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2706 return &QueryMetadataOperation{
2707 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2708 pollPath: override,
2709 }, nil
2710 }
2711
2712 // MoveTableToDatabase move a table to another database.
2713 func (c *dataprocMetastoreRESTClient) MoveTableToDatabase(ctx context.Context, req *metastorepb.MoveTableToDatabaseRequest, opts ...gax.CallOption) (*MoveTableToDatabaseOperation, error) {
2714 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2715 jsonReq, err := m.Marshal(req)
2716 if err != nil {
2717 return nil, err
2718 }
2719
2720 baseUrl, err := url.Parse(c.endpoint)
2721 if err != nil {
2722 return nil, err
2723 }
2724 baseUrl.Path += fmt.Sprintf("/v1beta/%v:moveTableToDatabase", req.GetService())
2725
2726 params := url.Values{}
2727 params.Add("$alt", "json;enum-encoding=int")
2728
2729 baseUrl.RawQuery = params.Encode()
2730
2731 // Build HTTP headers from client and context metadata.
2732 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
2733
2734 hds = append(c.xGoogHeaders, hds...)
2735 hds = append(hds, "Content-Type", "application/json")
2736 headers := gax.BuildHeaders(ctx, hds...)
2737 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2738 resp := &longrunningpb.Operation{}
2739 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2740 if settings.Path != "" {
2741 baseUrl.Path = settings.Path
2742 }
2743 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2744 if err != nil {
2745 return err
2746 }
2747 httpReq = httpReq.WithContext(ctx)
2748 httpReq.Header = headers
2749
2750 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "MoveTableToDatabase")
2751 if err != nil {
2752 return err
2753 }
2754 if err := unm.Unmarshal(buf, resp); err != nil {
2755 return err
2756 }
2757
2758 return nil
2759 }, opts...)
2760 if e != nil {
2761 return nil, e
2762 }
2763
2764 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2765 return &MoveTableToDatabaseOperation{
2766 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2767 pollPath: override,
2768 }, nil
2769 }
2770
2771 // AlterMetadataResourceLocation alter metadata resource location. The metadata resource can be a database,
2772 // table, or partition. This functionality only updates the parent directory
2773 // for the respective metadata resource and does not transfer any existing
2774 // data to the new location.
2775 func (c *dataprocMetastoreRESTClient) AlterMetadataResourceLocation(ctx context.Context, req *metastorepb.AlterMetadataResourceLocationRequest, opts ...gax.CallOption) (*AlterMetadataResourceLocationOperation, error) {
2776 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2777 jsonReq, err := m.Marshal(req)
2778 if err != nil {
2779 return nil, err
2780 }
2781
2782 baseUrl, err := url.Parse(c.endpoint)
2783 if err != nil {
2784 return nil, err
2785 }
2786 baseUrl.Path += fmt.Sprintf("/v1beta/%v:alterLocation", req.GetService())
2787
2788 params := url.Values{}
2789 params.Add("$alt", "json;enum-encoding=int")
2790
2791 baseUrl.RawQuery = params.Encode()
2792
2793 // Build HTTP headers from client and context metadata.
2794 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "service", url.QueryEscape(req.GetService()))}
2795
2796 hds = append(c.xGoogHeaders, hds...)
2797 hds = append(hds, "Content-Type", "application/json")
2798 headers := gax.BuildHeaders(ctx, hds...)
2799 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2800 resp := &longrunningpb.Operation{}
2801 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2802 if settings.Path != "" {
2803 baseUrl.Path = settings.Path
2804 }
2805 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2806 if err != nil {
2807 return err
2808 }
2809 httpReq = httpReq.WithContext(ctx)
2810 httpReq.Header = headers
2811
2812 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AlterMetadataResourceLocation")
2813 if err != nil {
2814 return err
2815 }
2816 if err := unm.Unmarshal(buf, resp); err != nil {
2817 return err
2818 }
2819
2820 return nil
2821 }, opts...)
2822 if e != nil {
2823 return nil, e
2824 }
2825
2826 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
2827 return &AlterMetadataResourceLocationOperation{
2828 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2829 pollPath: override,
2830 }, nil
2831 }
2832
2833 // GetLocation gets information about a location.
2834 func (c *dataprocMetastoreRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
2835 baseUrl, err := url.Parse(c.endpoint)
2836 if err != nil {
2837 return nil, err
2838 }
2839 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
2840
2841 params := url.Values{}
2842 params.Add("$alt", "json;enum-encoding=int")
2843
2844 baseUrl.RawQuery = params.Encode()
2845
2846 // Build HTTP headers from client and context metadata.
2847 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2848
2849 hds = append(c.xGoogHeaders, hds...)
2850 hds = append(hds, "Content-Type", "application/json")
2851 headers := gax.BuildHeaders(ctx, hds...)
2852 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
2853 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2854 resp := &locationpb.Location{}
2855 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2856 if settings.Path != "" {
2857 baseUrl.Path = settings.Path
2858 }
2859 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2860 if err != nil {
2861 return err
2862 }
2863 httpReq = httpReq.WithContext(ctx)
2864 httpReq.Header = headers
2865
2866 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
2867 if err != nil {
2868 return err
2869 }
2870
2871 if err := unm.Unmarshal(buf, resp); err != nil {
2872 return err
2873 }
2874
2875 return nil
2876 }, opts...)
2877 if e != nil {
2878 return nil, e
2879 }
2880 return resp, nil
2881 }
2882
2883 // ListLocations lists information about the supported locations for this service.
2884 func (c *dataprocMetastoreRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
2885 it := &LocationIterator{}
2886 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
2887 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2888 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
2889 resp := &locationpb.ListLocationsResponse{}
2890 if pageToken != "" {
2891 req.PageToken = pageToken
2892 }
2893 if pageSize > math.MaxInt32 {
2894 req.PageSize = math.MaxInt32
2895 } else if pageSize != 0 {
2896 req.PageSize = int32(pageSize)
2897 }
2898 baseUrl, err := url.Parse(c.endpoint)
2899 if err != nil {
2900 return nil, "", err
2901 }
2902 baseUrl.Path += fmt.Sprintf("/v1beta/%v/locations", req.GetName())
2903
2904 params := url.Values{}
2905 params.Add("$alt", "json;enum-encoding=int")
2906 if req.GetFilter() != "" {
2907 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2908 }
2909 if req.GetPageSize() != 0 {
2910 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2911 }
2912 if req.GetPageToken() != "" {
2913 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2914 }
2915
2916 baseUrl.RawQuery = params.Encode()
2917
2918 // Build HTTP headers from client and context metadata.
2919 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2920 headers := gax.BuildHeaders(ctx, hds...)
2921 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2922 if settings.Path != "" {
2923 baseUrl.Path = settings.Path
2924 }
2925 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2926 if err != nil {
2927 return err
2928 }
2929 httpReq.Header = headers
2930
2931 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
2932 if err != nil {
2933 return err
2934 }
2935 if err := unm.Unmarshal(buf, resp); err != nil {
2936 return err
2937 }
2938
2939 return nil
2940 }, opts...)
2941 if e != nil {
2942 return nil, "", e
2943 }
2944 it.Response = resp
2945 return resp.GetLocations(), resp.GetNextPageToken(), nil
2946 }
2947
2948 fetch := func(pageSize int, pageToken string) (string, error) {
2949 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2950 if err != nil {
2951 return "", err
2952 }
2953 it.items = append(it.items, items...)
2954 return nextPageToken, nil
2955 }
2956
2957 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2958 it.pageInfo.MaxSize = int(req.GetPageSize())
2959 it.pageInfo.Token = req.GetPageToken()
2960
2961 return it
2962 }
2963
2964 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
2965 // if the resource exists and does not have a policy set.
2966 func (c *dataprocMetastoreRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
2967 baseUrl, err := url.Parse(c.endpoint)
2968 if err != nil {
2969 return nil, err
2970 }
2971 baseUrl.Path += fmt.Sprintf("/v1beta/%v:getIamPolicy", req.GetResource())
2972
2973 params := url.Values{}
2974 params.Add("$alt", "json;enum-encoding=int")
2975 if req.GetOptions().GetRequestedPolicyVersion() != 0 {
2976 params.Add("options.requestedPolicyVersion", fmt.Sprintf("%v", req.GetOptions().GetRequestedPolicyVersion()))
2977 }
2978
2979 baseUrl.RawQuery = params.Encode()
2980
2981 // Build HTTP headers from client and context metadata.
2982 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2983
2984 hds = append(c.xGoogHeaders, hds...)
2985 hds = append(hds, "Content-Type", "application/json")
2986 headers := gax.BuildHeaders(ctx, hds...)
2987 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
2988 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2989 resp := &iampb.Policy{}
2990 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2991 if settings.Path != "" {
2992 baseUrl.Path = settings.Path
2993 }
2994 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2995 if err != nil {
2996 return err
2997 }
2998 httpReq = httpReq.WithContext(ctx)
2999 httpReq.Header = headers
3000
3001 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIamPolicy")
3002 if err != nil {
3003 return err
3004 }
3005
3006 if err := unm.Unmarshal(buf, resp); err != nil {
3007 return err
3008 }
3009
3010 return nil
3011 }, opts...)
3012 if e != nil {
3013 return nil, e
3014 }
3015 return resp, nil
3016 }
3017
3018 // SetIamPolicy sets the access control policy on the specified resource. Replaces
3019 // any existing policy.
3020 //
3021 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
3022 // errors.
3023 func (c *dataprocMetastoreRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
3024 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3025 jsonReq, err := m.Marshal(req)
3026 if err != nil {
3027 return nil, err
3028 }
3029
3030 baseUrl, err := url.Parse(c.endpoint)
3031 if err != nil {
3032 return nil, err
3033 }
3034 baseUrl.Path += fmt.Sprintf("/v1beta/%v:setIamPolicy", req.GetResource())
3035
3036 params := url.Values{}
3037 params.Add("$alt", "json;enum-encoding=int")
3038
3039 baseUrl.RawQuery = params.Encode()
3040
3041 // Build HTTP headers from client and context metadata.
3042 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
3043
3044 hds = append(c.xGoogHeaders, hds...)
3045 hds = append(hds, "Content-Type", "application/json")
3046 headers := gax.BuildHeaders(ctx, hds...)
3047 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
3048 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3049 resp := &iampb.Policy{}
3050 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3051 if settings.Path != "" {
3052 baseUrl.Path = settings.Path
3053 }
3054 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3055 if err != nil {
3056 return err
3057 }
3058 httpReq = httpReq.WithContext(ctx)
3059 httpReq.Header = headers
3060
3061 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
3062 if err != nil {
3063 return err
3064 }
3065
3066 if err := unm.Unmarshal(buf, resp); err != nil {
3067 return err
3068 }
3069
3070 return nil
3071 }, opts...)
3072 if e != nil {
3073 return nil, e
3074 }
3075 return resp, nil
3076 }
3077
3078 // TestIamPermissions returns permissions that a caller has on the specified resource. If the
3079 // resource does not exist, this will return an empty set of
3080 // permissions, not a NOT_FOUND error.
3081 //
3082 // Note: This operation is designed to be used for building
3083 // permission-aware UIs and command-line tools, not for authorization
3084 // checking. This operation may “fail open” without warning.
3085 func (c *dataprocMetastoreRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
3086 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3087 jsonReq, err := m.Marshal(req)
3088 if err != nil {
3089 return nil, err
3090 }
3091
3092 baseUrl, err := url.Parse(c.endpoint)
3093 if err != nil {
3094 return nil, err
3095 }
3096 baseUrl.Path += fmt.Sprintf("/v1beta/%v:testIamPermissions", req.GetResource())
3097
3098 params := url.Values{}
3099 params.Add("$alt", "json;enum-encoding=int")
3100
3101 baseUrl.RawQuery = params.Encode()
3102
3103 // Build HTTP headers from client and context metadata.
3104 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
3105
3106 hds = append(c.xGoogHeaders, hds...)
3107 hds = append(hds, "Content-Type", "application/json")
3108 headers := gax.BuildHeaders(ctx, hds...)
3109 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
3110 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3111 resp := &iampb.TestIamPermissionsResponse{}
3112 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3113 if settings.Path != "" {
3114 baseUrl.Path = settings.Path
3115 }
3116 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3117 if err != nil {
3118 return err
3119 }
3120 httpReq = httpReq.WithContext(ctx)
3121 httpReq.Header = headers
3122
3123 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
3124 if err != nil {
3125 return err
3126 }
3127
3128 if err := unm.Unmarshal(buf, resp); err != nil {
3129 return err
3130 }
3131
3132 return nil
3133 }, opts...)
3134 if e != nil {
3135 return nil, e
3136 }
3137 return resp, nil
3138 }
3139
3140 // CancelOperation is a utility method from google.longrunning.Operations.
3141 func (c *dataprocMetastoreRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
3142 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3143 jsonReq, err := m.Marshal(req)
3144 if err != nil {
3145 return err
3146 }
3147
3148 baseUrl, err := url.Parse(c.endpoint)
3149 if err != nil {
3150 return err
3151 }
3152 baseUrl.Path += fmt.Sprintf("/v1beta/%v:cancel", req.GetName())
3153
3154 params := url.Values{}
3155 params.Add("$alt", "json;enum-encoding=int")
3156
3157 baseUrl.RawQuery = params.Encode()
3158
3159 // Build HTTP headers from client and context metadata.
3160 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3161
3162 hds = append(c.xGoogHeaders, hds...)
3163 hds = append(hds, "Content-Type", "application/json")
3164 headers := gax.BuildHeaders(ctx, hds...)
3165 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3166 if settings.Path != "" {
3167 baseUrl.Path = settings.Path
3168 }
3169 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3170 if err != nil {
3171 return err
3172 }
3173 httpReq = httpReq.WithContext(ctx)
3174 httpReq.Header = headers
3175
3176 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation")
3177 return err
3178 }, opts...)
3179 }
3180
3181 // DeleteOperation is a utility method from google.longrunning.Operations.
3182 func (c *dataprocMetastoreRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
3183 baseUrl, err := url.Parse(c.endpoint)
3184 if err != nil {
3185 return err
3186 }
3187 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
3188
3189 params := url.Values{}
3190 params.Add("$alt", "json;enum-encoding=int")
3191
3192 baseUrl.RawQuery = params.Encode()
3193
3194 // Build HTTP headers from client and context metadata.
3195 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3196
3197 hds = append(c.xGoogHeaders, hds...)
3198 hds = append(hds, "Content-Type", "application/json")
3199 headers := gax.BuildHeaders(ctx, hds...)
3200 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3201 if settings.Path != "" {
3202 baseUrl.Path = settings.Path
3203 }
3204 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
3205 if err != nil {
3206 return err
3207 }
3208 httpReq = httpReq.WithContext(ctx)
3209 httpReq.Header = headers
3210
3211 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
3212 return err
3213 }, opts...)
3214 }
3215
3216 // GetOperation is a utility method from google.longrunning.Operations.
3217 func (c *dataprocMetastoreRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
3218 baseUrl, err := url.Parse(c.endpoint)
3219 if err != nil {
3220 return nil, err
3221 }
3222 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
3223
3224 params := url.Values{}
3225 params.Add("$alt", "json;enum-encoding=int")
3226
3227 baseUrl.RawQuery = params.Encode()
3228
3229 // Build HTTP headers from client and context metadata.
3230 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3231
3232 hds = append(c.xGoogHeaders, hds...)
3233 hds = append(hds, "Content-Type", "application/json")
3234 headers := gax.BuildHeaders(ctx, hds...)
3235 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
3236 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3237 resp := &longrunningpb.Operation{}
3238 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3239 if settings.Path != "" {
3240 baseUrl.Path = settings.Path
3241 }
3242 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3243 if err != nil {
3244 return err
3245 }
3246 httpReq = httpReq.WithContext(ctx)
3247 httpReq.Header = headers
3248
3249 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
3250 if err != nil {
3251 return err
3252 }
3253
3254 if err := unm.Unmarshal(buf, resp); err != nil {
3255 return err
3256 }
3257
3258 return nil
3259 }, opts...)
3260 if e != nil {
3261 return nil, e
3262 }
3263 return resp, nil
3264 }
3265
3266 // ListOperations is a utility method from google.longrunning.Operations.
3267 func (c *dataprocMetastoreRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
3268 it := &OperationIterator{}
3269 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
3270 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3271 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
3272 resp := &longrunningpb.ListOperationsResponse{}
3273 if pageToken != "" {
3274 req.PageToken = pageToken
3275 }
3276 if pageSize > math.MaxInt32 {
3277 req.PageSize = math.MaxInt32
3278 } else if pageSize != 0 {
3279 req.PageSize = int32(pageSize)
3280 }
3281 baseUrl, err := url.Parse(c.endpoint)
3282 if err != nil {
3283 return nil, "", err
3284 }
3285 baseUrl.Path += fmt.Sprintf("/v1beta/%v/operations", req.GetName())
3286
3287 params := url.Values{}
3288 params.Add("$alt", "json;enum-encoding=int")
3289 if req.GetFilter() != "" {
3290 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3291 }
3292 if req.GetPageSize() != 0 {
3293 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3294 }
3295 if req.GetPageToken() != "" {
3296 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3297 }
3298
3299 baseUrl.RawQuery = params.Encode()
3300
3301 // Build HTTP headers from client and context metadata.
3302 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3303 headers := gax.BuildHeaders(ctx, hds...)
3304 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3305 if settings.Path != "" {
3306 baseUrl.Path = settings.Path
3307 }
3308 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3309 if err != nil {
3310 return err
3311 }
3312 httpReq.Header = headers
3313
3314 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
3315 if err != nil {
3316 return err
3317 }
3318 if err := unm.Unmarshal(buf, resp); err != nil {
3319 return err
3320 }
3321
3322 return nil
3323 }, opts...)
3324 if e != nil {
3325 return nil, "", e
3326 }
3327 it.Response = resp
3328 return resp.GetOperations(), resp.GetNextPageToken(), nil
3329 }
3330
3331 fetch := func(pageSize int, pageToken string) (string, error) {
3332 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3333 if err != nil {
3334 return "", err
3335 }
3336 it.items = append(it.items, items...)
3337 return nextPageToken, nil
3338 }
3339
3340 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3341 it.pageInfo.MaxSize = int(req.GetPageSize())
3342 it.pageInfo.Token = req.GetPageToken()
3343
3344 return it
3345 }
3346
3347 // AlterMetadataResourceLocationOperation returns a new AlterMetadataResourceLocationOperation from a given name.
3348 // The name must be that of a previously created AlterMetadataResourceLocationOperation, possibly from a different process.
3349 func (c *dataprocMetastoreGRPCClient) AlterMetadataResourceLocationOperation(name string) *AlterMetadataResourceLocationOperation {
3350 return &AlterMetadataResourceLocationOperation{
3351 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3352 }
3353 }
3354
3355 // AlterMetadataResourceLocationOperation returns a new AlterMetadataResourceLocationOperation from a given name.
3356 // The name must be that of a previously created AlterMetadataResourceLocationOperation, possibly from a different process.
3357 func (c *dataprocMetastoreRESTClient) AlterMetadataResourceLocationOperation(name string) *AlterMetadataResourceLocationOperation {
3358 override := fmt.Sprintf("/v1beta/%s", name)
3359 return &AlterMetadataResourceLocationOperation{
3360 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3361 pollPath: override,
3362 }
3363 }
3364
3365 // CreateBackupOperation returns a new CreateBackupOperation from a given name.
3366 // The name must be that of a previously created CreateBackupOperation, possibly from a different process.
3367 func (c *dataprocMetastoreGRPCClient) CreateBackupOperation(name string) *CreateBackupOperation {
3368 return &CreateBackupOperation{
3369 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3370 }
3371 }
3372
3373 // CreateBackupOperation returns a new CreateBackupOperation from a given name.
3374 // The name must be that of a previously created CreateBackupOperation, possibly from a different process.
3375 func (c *dataprocMetastoreRESTClient) CreateBackupOperation(name string) *CreateBackupOperation {
3376 override := fmt.Sprintf("/v1beta/%s", name)
3377 return &CreateBackupOperation{
3378 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3379 pollPath: override,
3380 }
3381 }
3382
3383 // CreateMetadataImportOperation returns a new CreateMetadataImportOperation from a given name.
3384 // The name must be that of a previously created CreateMetadataImportOperation, possibly from a different process.
3385 func (c *dataprocMetastoreGRPCClient) CreateMetadataImportOperation(name string) *CreateMetadataImportOperation {
3386 return &CreateMetadataImportOperation{
3387 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3388 }
3389 }
3390
3391 // CreateMetadataImportOperation returns a new CreateMetadataImportOperation from a given name.
3392 // The name must be that of a previously created CreateMetadataImportOperation, possibly from a different process.
3393 func (c *dataprocMetastoreRESTClient) CreateMetadataImportOperation(name string) *CreateMetadataImportOperation {
3394 override := fmt.Sprintf("/v1beta/%s", name)
3395 return &CreateMetadataImportOperation{
3396 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3397 pollPath: override,
3398 }
3399 }
3400
3401 // CreateServiceOperation returns a new CreateServiceOperation from a given name.
3402 // The name must be that of a previously created CreateServiceOperation, possibly from a different process.
3403 func (c *dataprocMetastoreGRPCClient) CreateServiceOperation(name string) *CreateServiceOperation {
3404 return &CreateServiceOperation{
3405 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3406 }
3407 }
3408
3409 // CreateServiceOperation returns a new CreateServiceOperation from a given name.
3410 // The name must be that of a previously created CreateServiceOperation, possibly from a different process.
3411 func (c *dataprocMetastoreRESTClient) CreateServiceOperation(name string) *CreateServiceOperation {
3412 override := fmt.Sprintf("/v1beta/%s", name)
3413 return &CreateServiceOperation{
3414 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3415 pollPath: override,
3416 }
3417 }
3418
3419 // DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
3420 // The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
3421 func (c *dataprocMetastoreGRPCClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
3422 return &DeleteBackupOperation{
3423 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3424 }
3425 }
3426
3427 // DeleteBackupOperation returns a new DeleteBackupOperation from a given name.
3428 // The name must be that of a previously created DeleteBackupOperation, possibly from a different process.
3429 func (c *dataprocMetastoreRESTClient) DeleteBackupOperation(name string) *DeleteBackupOperation {
3430 override := fmt.Sprintf("/v1beta/%s", name)
3431 return &DeleteBackupOperation{
3432 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3433 pollPath: override,
3434 }
3435 }
3436
3437 // DeleteServiceOperation returns a new DeleteServiceOperation from a given name.
3438 // The name must be that of a previously created DeleteServiceOperation, possibly from a different process.
3439 func (c *dataprocMetastoreGRPCClient) DeleteServiceOperation(name string) *DeleteServiceOperation {
3440 return &DeleteServiceOperation{
3441 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3442 }
3443 }
3444
3445 // DeleteServiceOperation returns a new DeleteServiceOperation from a given name.
3446 // The name must be that of a previously created DeleteServiceOperation, possibly from a different process.
3447 func (c *dataprocMetastoreRESTClient) DeleteServiceOperation(name string) *DeleteServiceOperation {
3448 override := fmt.Sprintf("/v1beta/%s", name)
3449 return &DeleteServiceOperation{
3450 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3451 pollPath: override,
3452 }
3453 }
3454
3455 // ExportMetadataOperation returns a new ExportMetadataOperation from a given name.
3456 // The name must be that of a previously created ExportMetadataOperation, possibly from a different process.
3457 func (c *dataprocMetastoreGRPCClient) ExportMetadataOperation(name string) *ExportMetadataOperation {
3458 return &ExportMetadataOperation{
3459 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3460 }
3461 }
3462
3463 // ExportMetadataOperation returns a new ExportMetadataOperation from a given name.
3464 // The name must be that of a previously created ExportMetadataOperation, possibly from a different process.
3465 func (c *dataprocMetastoreRESTClient) ExportMetadataOperation(name string) *ExportMetadataOperation {
3466 override := fmt.Sprintf("/v1beta/%s", name)
3467 return &ExportMetadataOperation{
3468 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3469 pollPath: override,
3470 }
3471 }
3472
3473 // MoveTableToDatabaseOperation returns a new MoveTableToDatabaseOperation from a given name.
3474 // The name must be that of a previously created MoveTableToDatabaseOperation, possibly from a different process.
3475 func (c *dataprocMetastoreGRPCClient) MoveTableToDatabaseOperation(name string) *MoveTableToDatabaseOperation {
3476 return &MoveTableToDatabaseOperation{
3477 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3478 }
3479 }
3480
3481 // MoveTableToDatabaseOperation returns a new MoveTableToDatabaseOperation from a given name.
3482 // The name must be that of a previously created MoveTableToDatabaseOperation, possibly from a different process.
3483 func (c *dataprocMetastoreRESTClient) MoveTableToDatabaseOperation(name string) *MoveTableToDatabaseOperation {
3484 override := fmt.Sprintf("/v1beta/%s", name)
3485 return &MoveTableToDatabaseOperation{
3486 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3487 pollPath: override,
3488 }
3489 }
3490
3491 // QueryMetadataOperation returns a new QueryMetadataOperation from a given name.
3492 // The name must be that of a previously created QueryMetadataOperation, possibly from a different process.
3493 func (c *dataprocMetastoreGRPCClient) QueryMetadataOperation(name string) *QueryMetadataOperation {
3494 return &QueryMetadataOperation{
3495 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3496 }
3497 }
3498
3499 // QueryMetadataOperation returns a new QueryMetadataOperation from a given name.
3500 // The name must be that of a previously created QueryMetadataOperation, possibly from a different process.
3501 func (c *dataprocMetastoreRESTClient) QueryMetadataOperation(name string) *QueryMetadataOperation {
3502 override := fmt.Sprintf("/v1beta/%s", name)
3503 return &QueryMetadataOperation{
3504 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3505 pollPath: override,
3506 }
3507 }
3508
3509 // RestoreServiceOperation returns a new RestoreServiceOperation from a given name.
3510 // The name must be that of a previously created RestoreServiceOperation, possibly from a different process.
3511 func (c *dataprocMetastoreGRPCClient) RestoreServiceOperation(name string) *RestoreServiceOperation {
3512 return &RestoreServiceOperation{
3513 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3514 }
3515 }
3516
3517 // RestoreServiceOperation returns a new RestoreServiceOperation from a given name.
3518 // The name must be that of a previously created RestoreServiceOperation, possibly from a different process.
3519 func (c *dataprocMetastoreRESTClient) RestoreServiceOperation(name string) *RestoreServiceOperation {
3520 override := fmt.Sprintf("/v1beta/%s", name)
3521 return &RestoreServiceOperation{
3522 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3523 pollPath: override,
3524 }
3525 }
3526
3527 // UpdateMetadataImportOperation returns a new UpdateMetadataImportOperation from a given name.
3528 // The name must be that of a previously created UpdateMetadataImportOperation, possibly from a different process.
3529 func (c *dataprocMetastoreGRPCClient) UpdateMetadataImportOperation(name string) *UpdateMetadataImportOperation {
3530 return &UpdateMetadataImportOperation{
3531 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3532 }
3533 }
3534
3535 // UpdateMetadataImportOperation returns a new UpdateMetadataImportOperation from a given name.
3536 // The name must be that of a previously created UpdateMetadataImportOperation, possibly from a different process.
3537 func (c *dataprocMetastoreRESTClient) UpdateMetadataImportOperation(name string) *UpdateMetadataImportOperation {
3538 override := fmt.Sprintf("/v1beta/%s", name)
3539 return &UpdateMetadataImportOperation{
3540 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3541 pollPath: override,
3542 }
3543 }
3544
3545 // UpdateServiceOperation returns a new UpdateServiceOperation from a given name.
3546 // The name must be that of a previously created UpdateServiceOperation, possibly from a different process.
3547 func (c *dataprocMetastoreGRPCClient) UpdateServiceOperation(name string) *UpdateServiceOperation {
3548 return &UpdateServiceOperation{
3549 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3550 }
3551 }
3552
3553 // UpdateServiceOperation returns a new UpdateServiceOperation from a given name.
3554 // The name must be that of a previously created UpdateServiceOperation, possibly from a different process.
3555 func (c *dataprocMetastoreRESTClient) UpdateServiceOperation(name string) *UpdateServiceOperation {
3556 override := fmt.Sprintf("/v1beta/%s", name)
3557 return &UpdateServiceOperation{
3558 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3559 pollPath: override,
3560 }
3561 }