Debian Codegraph @

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