Debian Codegraph @

metastore/apiv1beta/dataproc_metastore_federation_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
28 iampb "cloud.google.com/go/iam/apiv1/iampb"
29 "cloud.google.com/go/longrunning"
30 lroauto "cloud.google.com/go/longrunning/autogen"
31 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
32 metastorepb "cloud.google.com/go/metastore/apiv1beta/metastorepb"
33 gax "github.com/googleapis/gax-go/v2"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 gtransport "google.golang.org/api/transport/grpc"
38 httptransport "google.golang.org/api/transport/http"
39 locationpb "google.golang.org/genproto/googleapis/cloud/location"
40 "google.golang.org/grpc"
41 "google.golang.org/protobuf/encoding/protojson"
42 "google.golang.org/protobuf/proto"
43 )
44
45 var newDataprocMetastoreFederationClientHook clientHook
46
47 // DataprocMetastoreFederationCallOptions contains the retry settings for each method of DataprocMetastoreFederationClient.
48 type DataprocMetastoreFederationCallOptions struct {
49 ListFederations []gax.CallOption
50 GetFederation []gax.CallOption
51 CreateFederation []gax.CallOption
52 UpdateFederation []gax.CallOption
53 DeleteFederation []gax.CallOption
54 GetLocation []gax.CallOption
55 ListLocations []gax.CallOption
56 GetIamPolicy []gax.CallOption
57 SetIamPolicy []gax.CallOption
58 TestIamPermissions []gax.CallOption
59 CancelOperation []gax.CallOption
60 DeleteOperation []gax.CallOption
61 GetOperation []gax.CallOption
62 ListOperations []gax.CallOption
63 }
64
65 func defaultDataprocMetastoreFederationGRPCClientOptions() []option.ClientOption {
66 return []option.ClientOption{
67 internaloption.WithDefaultEndpoint("metastore.googleapis.com:443"),
68 internaloption.WithDefaultEndpointTemplate("metastore.UNIVERSE_DOMAIN:443"),
69 internaloption.WithDefaultMTLSEndpoint("metastore.mtls.googleapis.com:443"),
70 internaloption.WithDefaultUniverseDomain("googleapis.com"),
71 internaloption.WithDefaultAudience("https://metastore.googleapis.com/"),
72 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
73 internaloption.EnableJwtWithScope(),
74 internaloption.EnableNewAuthLibrary(),
75 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
76 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
77 }
78 }
79
80 func defaultDataprocMetastoreFederationCallOptions() *DataprocMetastoreFederationCallOptions {
81 return &DataprocMetastoreFederationCallOptions{
82 ListFederations: []gax.CallOption{},
83 GetFederation: []gax.CallOption{},
84 CreateFederation: []gax.CallOption{},
85 UpdateFederation: []gax.CallOption{},
86 DeleteFederation: []gax.CallOption{},
87 GetLocation: []gax.CallOption{},
88 ListLocations: []gax.CallOption{},
89 GetIamPolicy: []gax.CallOption{},
90 SetIamPolicy: []gax.CallOption{},
91 TestIamPermissions: []gax.CallOption{},
92 CancelOperation: []gax.CallOption{},
93 DeleteOperation: []gax.CallOption{},
94 GetOperation: []gax.CallOption{},
95 ListOperations: []gax.CallOption{},
96 }
97 }
98
99 func defaultDataprocMetastoreFederationRESTCallOptions() *DataprocMetastoreFederationCallOptions {
100 return &DataprocMetastoreFederationCallOptions{
101 ListFederations: []gax.CallOption{},
102 GetFederation: []gax.CallOption{},
103 CreateFederation: []gax.CallOption{},
104 UpdateFederation: []gax.CallOption{},
105 DeleteFederation: []gax.CallOption{},
106 GetLocation: []gax.CallOption{},
107 ListLocations: []gax.CallOption{},
108 GetIamPolicy: []gax.CallOption{},
109 SetIamPolicy: []gax.CallOption{},
110 TestIamPermissions: []gax.CallOption{},
111 CancelOperation: []gax.CallOption{},
112 DeleteOperation: []gax.CallOption{},
113 GetOperation: []gax.CallOption{},
114 ListOperations: []gax.CallOption{},
115 }
116 }
117
118 // internalDataprocMetastoreFederationClient is an interface that defines the methods available from Dataproc Metastore API.
119 type internalDataprocMetastoreFederationClient interface {
120 Close() error
121 setGoogleClientInfo(...string)
122 Connection() *grpc.ClientConn
123 ListFederations(context.Context, *metastorepb.ListFederationsRequest, ...gax.CallOption) *FederationIterator
124 GetFederation(context.Context, *metastorepb.GetFederationRequest, ...gax.CallOption) (*metastorepb.Federation, error)
125 CreateFederation(context.Context, *metastorepb.CreateFederationRequest, ...gax.CallOption) (*CreateFederationOperation, error)
126 CreateFederationOperation(name string) *CreateFederationOperation
127 UpdateFederation(context.Context, *metastorepb.UpdateFederationRequest, ...gax.CallOption) (*UpdateFederationOperation, error)
128 UpdateFederationOperation(name string) *UpdateFederationOperation
129 DeleteFederation(context.Context, *metastorepb.DeleteFederationRequest, ...gax.CallOption) (*DeleteFederationOperation, error)
130 DeleteFederationOperation(name string) *DeleteFederationOperation
131 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
132 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
133 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
134 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
135 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
136 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
137 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
138 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
139 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
140 }
141
142 // DataprocMetastoreFederationClient is a client for interacting with Dataproc Metastore API.
143 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
144 //
145 // Configures and manages metastore federation services.
146 // Dataproc Metastore Federation Service allows federating a collection of
147 // backend metastores like BigQuery, Dataplex Lakes, and other Dataproc
148 // Metastores. The Federation Service exposes a gRPC URL through which metadata
149 // from the backend metastores are served at query time.
150 //
151 // The Dataproc Metastore Federation API defines the following resource model:
152 //
153 // The service works with a collection of Google Cloud projects.
154 //
155 // Each project has a collection of available locations.
156 //
157 // Each location has a collection of federations.
158 //
159 // Dataproc Metastore Federations are resources with names of the
160 // form:
161 // projects/{project_number}/locations/{location_id}/federations/{federation_id}.
162 type DataprocMetastoreFederationClient struct {
163 // The internal transport-dependent client.
164 internalClient internalDataprocMetastoreFederationClient
165
166 // The call options for this service.
167 CallOptions *DataprocMetastoreFederationCallOptions
168
169 // LROClient is used internally to handle long-running operations.
170 // It is exposed so that its CallOptions can be modified if required.
171 // Users should not Close this client.
172 LROClient *lroauto.OperationsClient
173 }
174
175 // Wrapper methods routed to the internal client.
176
177 // Close closes the connection to the API service. The user should invoke this when
178 // the client is no longer required.
179 func (c *DataprocMetastoreFederationClient) Close() error {
180 return c.internalClient.Close()
181 }
182
183 // setGoogleClientInfo sets the name and version of the application in
184 // the `x-goog-api-client` header passed on each request. Intended for
185 // use by Google-written clients.
186 func (c *DataprocMetastoreFederationClient) setGoogleClientInfo(keyval ...string) {
187 c.internalClient.setGoogleClientInfo(keyval...)
188 }
189
190 // Connection returns a connection to the API service.
191 //
192 // Deprecated: Connections are now pooled so this method does not always
193 // return the same resource.
194 func (c *DataprocMetastoreFederationClient) Connection() *grpc.ClientConn {
195 return c.internalClient.Connection()
196 }
197
198 // ListFederations lists federations in a project and location.
199 func (c *DataprocMetastoreFederationClient) ListFederations(ctx context.Context, req *metastorepb.ListFederationsRequest, opts ...gax.CallOption) *FederationIterator {
200 return c.internalClient.ListFederations(ctx, req, opts...)
201 }
202
203 // GetFederation gets the details of a single federation.
204 func (c *DataprocMetastoreFederationClient) GetFederation(ctx context.Context, req *metastorepb.GetFederationRequest, opts ...gax.CallOption) (*metastorepb.Federation, error) {
205 return c.internalClient.GetFederation(ctx, req, opts...)
206 }
207
208 // CreateFederation creates a metastore federation in a project and location.
209 func (c *DataprocMetastoreFederationClient) CreateFederation(ctx context.Context, req *metastorepb.CreateFederationRequest, opts ...gax.CallOption) (*CreateFederationOperation, error) {
210 return c.internalClient.CreateFederation(ctx, req, opts...)
211 }
212
213 // CreateFederationOperation returns a new CreateFederationOperation from a given name.
214 // The name must be that of a previously created CreateFederationOperation, possibly from a different process.
215 func (c *DataprocMetastoreFederationClient) CreateFederationOperation(name string) *CreateFederationOperation {
216 return c.internalClient.CreateFederationOperation(name)
217 }
218
219 // UpdateFederation updates the fields of a federation.
220 func (c *DataprocMetastoreFederationClient) UpdateFederation(ctx context.Context, req *metastorepb.UpdateFederationRequest, opts ...gax.CallOption) (*UpdateFederationOperation, error) {
221 return c.internalClient.UpdateFederation(ctx, req, opts...)
222 }
223
224 // UpdateFederationOperation returns a new UpdateFederationOperation from a given name.
225 // The name must be that of a previously created UpdateFederationOperation, possibly from a different process.
226 func (c *DataprocMetastoreFederationClient) UpdateFederationOperation(name string) *UpdateFederationOperation {
227 return c.internalClient.UpdateFederationOperation(name)
228 }
229
230 // DeleteFederation deletes a single federation.
231 func (c *DataprocMetastoreFederationClient) DeleteFederation(ctx context.Context, req *metastorepb.DeleteFederationRequest, opts ...gax.CallOption) (*DeleteFederationOperation, error) {
232 return c.internalClient.DeleteFederation(ctx, req, opts...)
233 }
234
235 // DeleteFederationOperation returns a new DeleteFederationOperation from a given name.
236 // The name must be that of a previously created DeleteFederationOperation, possibly from a different process.
237 func (c *DataprocMetastoreFederationClient) DeleteFederationOperation(name string) *DeleteFederationOperation {
238 return c.internalClient.DeleteFederationOperation(name)
239 }
240
241 // GetLocation gets information about a location.
242 func (c *DataprocMetastoreFederationClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
243 return c.internalClient.GetLocation(ctx, req, opts...)
244 }
245
246 // ListLocations lists information about the supported locations for this service.
247 func (c *DataprocMetastoreFederationClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
248 return c.internalClient.ListLocations(ctx, req, opts...)
249 }
250
251 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
252 // if the resource exists and does not have a policy set.
253 func (c *DataprocMetastoreFederationClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
254 return c.internalClient.GetIamPolicy(ctx, req, opts...)
255 }
256
257 // SetIamPolicy sets the access control policy on the specified resource. Replaces
258 // any existing policy.
259 //
260 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
261 // errors.
262 func (c *DataprocMetastoreFederationClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
263 return c.internalClient.SetIamPolicy(ctx, req, opts...)
264 }
265
266 // TestIamPermissions returns permissions that a caller has on the specified resource. If the
267 // resource does not exist, this will return an empty set of
268 // permissions, not a NOT_FOUND error.
269 //
270 // Note: This operation is designed to be used for building
271 // permission-aware UIs and command-line tools, not for authorization
272 // checking. This operation may “fail open” without warning.
273 func (c *DataprocMetastoreFederationClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
274 return c.internalClient.TestIamPermissions(ctx, req, opts...)
275 }
276
277 // CancelOperation is a utility method from google.longrunning.Operations.
278 func (c *DataprocMetastoreFederationClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
279 return c.internalClient.CancelOperation(ctx, req, opts...)
280 }
281
282 // DeleteOperation is a utility method from google.longrunning.Operations.
283 func (c *DataprocMetastoreFederationClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
284 return c.internalClient.DeleteOperation(ctx, req, opts...)
285 }
286
287 // GetOperation is a utility method from google.longrunning.Operations.
288 func (c *DataprocMetastoreFederationClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
289 return c.internalClient.GetOperation(ctx, req, opts...)
290 }
291
292 // ListOperations is a utility method from google.longrunning.Operations.
293 func (c *DataprocMetastoreFederationClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
294 return c.internalClient.ListOperations(ctx, req, opts...)
295 }
296
297 // dataprocMetastoreFederationGRPCClient is a client for interacting with Dataproc Metastore API over gRPC transport.
298 //
299 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
300 type dataprocMetastoreFederationGRPCClient struct {
301 // Connection pool of gRPC connections to the service.
302 connPool gtransport.ConnPool
303
304 // Points back to the CallOptions field of the containing DataprocMetastoreFederationClient
305 CallOptions **DataprocMetastoreFederationCallOptions
306
307 // The gRPC API client.
308 dataprocMetastoreFederationClient metastorepb.DataprocMetastoreFederationClient
309
310 // LROClient is used internally to handle long-running operations.
311 // It is exposed so that its CallOptions can be modified if required.
312 // Users should not Close this client.
313 LROClient **lroauto.OperationsClient
314
315 operationsClient longrunningpb.OperationsClient
316
317 iamPolicyClient iampb.IAMPolicyClient
318
319 locationsClient locationpb.LocationsClient
320
321 // The x-goog-* metadata to be sent with each request.
322 xGoogHeaders []string
323
324 logger *slog.Logger
325 }
326
327 // NewDataprocMetastoreFederationClient creates a new dataproc metastore federation client based on gRPC.
328 // The returned client must be Closed when it is done being used to clean up its underlying connections.
329 //
330 // Configures and manages metastore federation services.
331 // Dataproc Metastore Federation Service allows federating a collection of
332 // backend metastores like BigQuery, Dataplex Lakes, and other Dataproc
333 // Metastores. The Federation Service exposes a gRPC URL through which metadata
334 // from the backend metastores are served at query time.
335 //
336 // The Dataproc Metastore Federation API defines the following resource model:
337 //
338 // The service works with a collection of Google Cloud projects.
339 //
340 // Each project has a collection of available locations.
341 //
342 // Each location has a collection of federations.
343 //
344 // Dataproc Metastore Federations are resources with names of the
345 // form:
346 // projects/{project_number}/locations/{location_id}/federations/{federation_id}.
347 func NewDataprocMetastoreFederationClient(ctx context.Context, opts ...option.ClientOption) (*DataprocMetastoreFederationClient, error) {
348 clientOpts := defaultDataprocMetastoreFederationGRPCClientOptions()
349 if newDataprocMetastoreFederationClientHook != nil {
350 hookOpts, err := newDataprocMetastoreFederationClientHook(ctx, clientHookParams{})
351 if err != nil {
352 return nil, err
353 }
354 clientOpts = append(clientOpts, hookOpts...)
355 }
356
357 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
358 if err != nil {
359 return nil, err
360 }
361 client := DataprocMetastoreFederationClient{CallOptions: defaultDataprocMetastoreFederationCallOptions()}
362
363 c := &dataprocMetastoreFederationGRPCClient{
364 connPool: connPool,
365 dataprocMetastoreFederationClient: metastorepb.NewDataprocMetastoreFederationClient(connPool),
366 CallOptions: &client.CallOptions,
367 logger: internaloption.GetLogger(opts),
368 operationsClient: longrunningpb.NewOperationsClient(connPool),
369 iamPolicyClient: iampb.NewIAMPolicyClient(connPool),
370 locationsClient: locationpb.NewLocationsClient(connPool),
371 }
372 c.setGoogleClientInfo()
373
374 client.internalClient = c
375
376 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
377 if err != nil {
378 // This error "should not happen", since we are just reusing old connection pool
379 // and never actually need to dial.
380 // If this does happen, we could leak connp. However, we cannot close conn:
381 // If the user invoked the constructor with option.WithGRPCConn,
382 // we would close a connection that's still in use.
383 // TODO: investigate error conditions.
384 return nil, err
385 }
386 c.LROClient = &client.LROClient
387 return &client, nil
388 }
389
390 // Connection returns a connection to the API service.
391 //
392 // Deprecated: Connections are now pooled so this method does not always
393 // return the same resource.
394 func (c *dataprocMetastoreFederationGRPCClient) Connection() *grpc.ClientConn {
395 return c.connPool.Conn()
396 }
397
398 // setGoogleClientInfo sets the name and version of the application in
399 // the `x-goog-api-client` header passed on each request. Intended for
400 // use by Google-written clients.
401 func (c *dataprocMetastoreFederationGRPCClient) setGoogleClientInfo(keyval ...string) {
402 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
403 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
404 c.xGoogHeaders = []string{
405 "x-goog-api-client", gax.XGoogHeader(kv...),
406 }
407 }
408
409 // Close closes the connection to the API service. The user should invoke this when
410 // the client is no longer required.
411 func (c *dataprocMetastoreFederationGRPCClient) Close() error {
412 return c.connPool.Close()
413 }
414
415 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
416 type dataprocMetastoreFederationRESTClient struct {
417 // The http endpoint to connect to.
418 endpoint string
419
420 // The http client.
421 httpClient *http.Client
422
423 // LROClient is used internally to handle long-running operations.
424 // It is exposed so that its CallOptions can be modified if required.
425 // Users should not Close this client.
426 LROClient **lroauto.OperationsClient
427
428 // The x-goog-* headers to be sent with each request.
429 xGoogHeaders []string
430
431 // Points back to the CallOptions field of the containing DataprocMetastoreFederationClient
432 CallOptions **DataprocMetastoreFederationCallOptions
433
434 logger *slog.Logger
435 }
436
437 // NewDataprocMetastoreFederationRESTClient creates a new dataproc metastore federation rest client.
438 //
439 // Configures and manages metastore federation services.
440 // Dataproc Metastore Federation Service allows federating a collection of
441 // backend metastores like BigQuery, Dataplex Lakes, and other Dataproc
442 // Metastores. The Federation Service exposes a gRPC URL through which metadata
443 // from the backend metastores are served at query time.
444 //
445 // The Dataproc Metastore Federation API defines the following resource model:
446 //
447 // The service works with a collection of Google Cloud projects.
448 //
449 // Each project has a collection of available locations.
450 //
451 // Each location has a collection of federations.
452 //
453 // Dataproc Metastore Federations are resources with names of the
454 // form:
455 // projects/{project_number}/locations/{location_id}/federations/{federation_id}.
456 func NewDataprocMetastoreFederationRESTClient(ctx context.Context, opts ...option.ClientOption) (*DataprocMetastoreFederationClient, error) {
457 clientOpts := append(defaultDataprocMetastoreFederationRESTClientOptions(), opts...)
458 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
459 if err != nil {
460 return nil, err
461 }
462
463 callOpts := defaultDataprocMetastoreFederationRESTCallOptions()
464 c := &dataprocMetastoreFederationRESTClient{
465 endpoint: endpoint,
466 httpClient: httpClient,
467 CallOptions: &callOpts,
468 logger: internaloption.GetLogger(opts),
469 }
470 c.setGoogleClientInfo()
471
472 lroOpts := []option.ClientOption{
473 option.WithHTTPClient(httpClient),
474 option.WithEndpoint(endpoint),
475 }
476 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
477 if err != nil {
478 return nil, err
479 }
480 c.LROClient = &opClient
481
482 return &DataprocMetastoreFederationClient{internalClient: c, CallOptions: callOpts}, nil
483 }
484
485 func defaultDataprocMetastoreFederationRESTClientOptions() []option.ClientOption {
486 return []option.ClientOption{
487 internaloption.WithDefaultEndpoint("https://metastore.googleapis.com"),
488 internaloption.WithDefaultEndpointTemplate("https://metastore.UNIVERSE_DOMAIN"),
489 internaloption.WithDefaultMTLSEndpoint("https://metastore.mtls.googleapis.com"),
490 internaloption.WithDefaultUniverseDomain("googleapis.com"),
491 internaloption.WithDefaultAudience("https://metastore.googleapis.com/"),
492 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
493 internaloption.EnableNewAuthLibrary(),
494 }
495 }
496
497 // setGoogleClientInfo sets the name and version of the application in
498 // the `x-goog-api-client` header passed on each request. Intended for
499 // use by Google-written clients.
500 func (c *dataprocMetastoreFederationRESTClient) setGoogleClientInfo(keyval ...string) {
501 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
502 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
503 c.xGoogHeaders = []string{
504 "x-goog-api-client", gax.XGoogHeader(kv...),
505 }
506 }
507
508 // Close closes the connection to the API service. The user should invoke this when
509 // the client is no longer required.
510 func (c *dataprocMetastoreFederationRESTClient) Close() error {
511 // Replace httpClient with nil to force cleanup.
512 c.httpClient = nil
513 return nil
514 }
515
516 // Connection returns a connection to the API service.
517 //
518 // Deprecated: This method always returns nil.
519 func (c *dataprocMetastoreFederationRESTClient) Connection() *grpc.ClientConn {
520 return nil
521 }
522 func (c *dataprocMetastoreFederationGRPCClient) ListFederations(ctx context.Context, req *metastorepb.ListFederationsRequest, opts ...gax.CallOption) *FederationIterator {
523 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
524
525 hds = append(c.xGoogHeaders, hds...)
526 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
527 opts = append((*c.CallOptions).ListFederations[0:len((*c.CallOptions).ListFederations):len((*c.CallOptions).ListFederations)], opts...)
528 it := &FederationIterator{}
529 req = proto.Clone(req).(*metastorepb.ListFederationsRequest)
530 it.InternalFetch = func(pageSize int, pageToken string) ([]*metastorepb.Federation, string, error) {
531 resp := &metastorepb.ListFederationsResponse{}
532 if pageToken != "" {
533 req.PageToken = pageToken
534 }
535 if pageSize > math.MaxInt32 {
536 req.PageSize = math.MaxInt32
537 } else if pageSize != 0 {
538 req.PageSize = int32(pageSize)
539 }
540 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
541 var err error
542 resp, err = executeRPC(ctx, c.dataprocMetastoreFederationClient.ListFederations, req, settings.GRPC, c.logger, "ListFederations")
543 return err
544 }, opts...)
545 if err != nil {
546 return nil, "", err
547 }
548
549 it.Response = resp
550 return resp.GetFederations(), resp.GetNextPageToken(), nil
551 }
552 fetch := func(pageSize int, pageToken string) (string, error) {
553 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
554 if err != nil {
555 return "", err
556 }
557 it.items = append(it.items, items...)
558 return nextPageToken, nil
559 }
560
561 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
562 it.pageInfo.MaxSize = int(req.GetPageSize())
563 it.pageInfo.Token = req.GetPageToken()
564
565 return it
566 }
567
568 func (c *dataprocMetastoreFederationGRPCClient) GetFederation(ctx context.Context, req *metastorepb.GetFederationRequest, opts ...gax.CallOption) (*metastorepb.Federation, error) {
569 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
570
571 hds = append(c.xGoogHeaders, hds...)
572 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
573 opts = append((*c.CallOptions).GetFederation[0:len((*c.CallOptions).GetFederation):len((*c.CallOptions).GetFederation)], opts...)
574 var resp *metastorepb.Federation
575 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
576 var err error
577 resp, err = executeRPC(ctx, c.dataprocMetastoreFederationClient.GetFederation, req, settings.GRPC, c.logger, "GetFederation")
578 return err
579 }, opts...)
580 if err != nil {
581 return nil, err
582 }
583 return resp, nil
584 }
585
586 func (c *dataprocMetastoreFederationGRPCClient) CreateFederation(ctx context.Context, req *metastorepb.CreateFederationRequest, opts ...gax.CallOption) (*CreateFederationOperation, error) {
587 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
588
589 hds = append(c.xGoogHeaders, hds...)
590 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
591 opts = append((*c.CallOptions).CreateFederation[0:len((*c.CallOptions).CreateFederation):len((*c.CallOptions).CreateFederation)], opts...)
592 var resp *longrunningpb.Operation
593 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
594 var err error
595 resp, err = executeRPC(ctx, c.dataprocMetastoreFederationClient.CreateFederation, req, settings.GRPC, c.logger, "CreateFederation")
596 return err
597 }, opts...)
598 if err != nil {
599 return nil, err
600 }
601 return &CreateFederationOperation{
602 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
603 }, nil
604 }
605
606 func (c *dataprocMetastoreFederationGRPCClient) UpdateFederation(ctx context.Context, req *metastorepb.UpdateFederationRequest, opts ...gax.CallOption) (*UpdateFederationOperation, error) {
607 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "federation.name", url.QueryEscape(req.GetFederation().GetName()))}
608
609 hds = append(c.xGoogHeaders, hds...)
610 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
611 opts = append((*c.CallOptions).UpdateFederation[0:len((*c.CallOptions).UpdateFederation):len((*c.CallOptions).UpdateFederation)], opts...)
612 var resp *longrunningpb.Operation
613 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
614 var err error
615 resp, err = executeRPC(ctx, c.dataprocMetastoreFederationClient.UpdateFederation, req, settings.GRPC, c.logger, "UpdateFederation")
616 return err
617 }, opts...)
618 if err != nil {
619 return nil, err
620 }
621 return &UpdateFederationOperation{
622 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
623 }, nil
624 }
625
626 func (c *dataprocMetastoreFederationGRPCClient) DeleteFederation(ctx context.Context, req *metastorepb.DeleteFederationRequest, opts ...gax.CallOption) (*DeleteFederationOperation, error) {
627 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
628
629 hds = append(c.xGoogHeaders, hds...)
630 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
631 opts = append((*c.CallOptions).DeleteFederation[0:len((*c.CallOptions).DeleteFederation):len((*c.CallOptions).DeleteFederation)], opts...)
632 var resp *longrunningpb.Operation
633 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
634 var err error
635 resp, err = executeRPC(ctx, c.dataprocMetastoreFederationClient.DeleteFederation, req, settings.GRPC, c.logger, "DeleteFederation")
636 return err
637 }, opts...)
638 if err != nil {
639 return nil, err
640 }
641 return &DeleteFederationOperation{
642 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
643 }, nil
644 }
645
646 func (c *dataprocMetastoreFederationGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
647 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
648
649 hds = append(c.xGoogHeaders, hds...)
650 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
651 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
652 var resp *locationpb.Location
653 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
654 var err error
655 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
656 return err
657 }, opts...)
658 if err != nil {
659 return nil, err
660 }
661 return resp, nil
662 }
663
664 func (c *dataprocMetastoreFederationGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
665 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
666
667 hds = append(c.xGoogHeaders, hds...)
668 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
669 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
670 it := &LocationIterator{}
671 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
672 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
673 resp := &locationpb.ListLocationsResponse{}
674 if pageToken != "" {
675 req.PageToken = pageToken
676 }
677 if pageSize > math.MaxInt32 {
678 req.PageSize = math.MaxInt32
679 } else if pageSize != 0 {
680 req.PageSize = int32(pageSize)
681 }
682 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
683 var err error
684 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
685 return err
686 }, opts...)
687 if err != nil {
688 return nil, "", err
689 }
690
691 it.Response = resp
692 return resp.GetLocations(), resp.GetNextPageToken(), nil
693 }
694 fetch := func(pageSize int, pageToken string) (string, error) {
695 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
696 if err != nil {
697 return "", err
698 }
699 it.items = append(it.items, items...)
700 return nextPageToken, nil
701 }
702
703 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
704 it.pageInfo.MaxSize = int(req.GetPageSize())
705 it.pageInfo.Token = req.GetPageToken()
706
707 return it
708 }
709
710 func (c *dataprocMetastoreFederationGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
711 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
712
713 hds = append(c.xGoogHeaders, hds...)
714 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
715 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
716 var resp *iampb.Policy
717 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
718 var err error
719 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
720 return err
721 }, opts...)
722 if err != nil {
723 return nil, err
724 }
725 return resp, nil
726 }
727
728 func (c *dataprocMetastoreFederationGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
729 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
730
731 hds = append(c.xGoogHeaders, hds...)
732 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
733 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
734 var resp *iampb.Policy
735 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
736 var err error
737 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
738 return err
739 }, opts...)
740 if err != nil {
741 return nil, err
742 }
743 return resp, nil
744 }
745
746 func (c *dataprocMetastoreFederationGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
747 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
748
749 hds = append(c.xGoogHeaders, hds...)
750 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
751 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
752 var resp *iampb.TestIamPermissionsResponse
753 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
754 var err error
755 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
756 return err
757 }, opts...)
758 if err != nil {
759 return nil, err
760 }
761 return resp, nil
762 }
763
764 func (c *dataprocMetastoreFederationGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
765 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
766
767 hds = append(c.xGoogHeaders, hds...)
768 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
769 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
770 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
771 var err error
772 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
773 return err
774 }, opts...)
775 return err
776 }
777
778 func (c *dataprocMetastoreFederationGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
779 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
780
781 hds = append(c.xGoogHeaders, hds...)
782 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
783 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
784 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
785 var err error
786 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
787 return err
788 }, opts...)
789 return err
790 }
791
792 func (c *dataprocMetastoreFederationGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
793 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
794
795 hds = append(c.xGoogHeaders, hds...)
796 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
797 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
798 var resp *longrunningpb.Operation
799 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
800 var err error
801 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
802 return err
803 }, opts...)
804 if err != nil {
805 return nil, err
806 }
807 return resp, nil
808 }
809
810 func (c *dataprocMetastoreFederationGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
811 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
812
813 hds = append(c.xGoogHeaders, hds...)
814 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
815 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
816 it := &OperationIterator{}
817 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
818 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
819 resp := &longrunningpb.ListOperationsResponse{}
820 if pageToken != "" {
821 req.PageToken = pageToken
822 }
823 if pageSize > math.MaxInt32 {
824 req.PageSize = math.MaxInt32
825 } else if pageSize != 0 {
826 req.PageSize = int32(pageSize)
827 }
828 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
829 var err error
830 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
831 return err
832 }, opts...)
833 if err != nil {
834 return nil, "", err
835 }
836
837 it.Response = resp
838 return resp.GetOperations(), resp.GetNextPageToken(), nil
839 }
840 fetch := func(pageSize int, pageToken string) (string, error) {
841 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
842 if err != nil {
843 return "", err
844 }
845 it.items = append(it.items, items...)
846 return nextPageToken, nil
847 }
848
849 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
850 it.pageInfo.MaxSize = int(req.GetPageSize())
851 it.pageInfo.Token = req.GetPageToken()
852
853 return it
854 }
855
856 // ListFederations lists federations in a project and location.
857 func (c *dataprocMetastoreFederationRESTClient) ListFederations(ctx context.Context, req *metastorepb.ListFederationsRequest, opts ...gax.CallOption) *FederationIterator {
858 it := &FederationIterator{}
859 req = proto.Clone(req).(*metastorepb.ListFederationsRequest)
860 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
861 it.InternalFetch = func(pageSize int, pageToken string) ([]*metastorepb.Federation, string, error) {
862 resp := &metastorepb.ListFederationsResponse{}
863 if pageToken != "" {
864 req.PageToken = pageToken
865 }
866 if pageSize > math.MaxInt32 {
867 req.PageSize = math.MaxInt32
868 } else if pageSize != 0 {
869 req.PageSize = int32(pageSize)
870 }
871 baseUrl, err := url.Parse(c.endpoint)
872 if err != nil {
873 return nil, "", err
874 }
875 baseUrl.Path += fmt.Sprintf("/v1beta/%v/federations", req.GetParent())
876
877 params := url.Values{}
878 params.Add("$alt", "json;enum-encoding=int")
879 if req.GetFilter() != "" {
880 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
881 }
882 if req.GetOrderBy() != "" {
883 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
884 }
885 if req.GetPageSize() != 0 {
886 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
887 }
888 if req.GetPageToken() != "" {
889 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
890 }
891
892 baseUrl.RawQuery = params.Encode()
893
894 // Build HTTP headers from client and context metadata.
895 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
896 headers := gax.BuildHeaders(ctx, hds...)
897 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
898 if settings.Path != "" {
899 baseUrl.Path = settings.Path
900 }
901 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
902 if err != nil {
903 return err
904 }
905 httpReq.Header = headers
906
907 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListFederations")
908 if err != nil {
909 return err
910 }
911 if err := unm.Unmarshal(buf, resp); err != nil {
912 return err
913 }
914
915 return nil
916 }, opts...)
917 if e != nil {
918 return nil, "", e
919 }
920 it.Response = resp
921 return resp.GetFederations(), resp.GetNextPageToken(), nil
922 }
923
924 fetch := func(pageSize int, pageToken string) (string, error) {
925 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
926 if err != nil {
927 return "", err
928 }
929 it.items = append(it.items, items...)
930 return nextPageToken, nil
931 }
932
933 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
934 it.pageInfo.MaxSize = int(req.GetPageSize())
935 it.pageInfo.Token = req.GetPageToken()
936
937 return it
938 }
939
940 // GetFederation gets the details of a single federation.
941 func (c *dataprocMetastoreFederationRESTClient) GetFederation(ctx context.Context, req *metastorepb.GetFederationRequest, opts ...gax.CallOption) (*metastorepb.Federation, error) {
942 baseUrl, err := url.Parse(c.endpoint)
943 if err != nil {
944 return nil, err
945 }
946 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
947
948 params := url.Values{}
949 params.Add("$alt", "json;enum-encoding=int")
950
951 baseUrl.RawQuery = params.Encode()
952
953 // Build HTTP headers from client and context metadata.
954 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
955
956 hds = append(c.xGoogHeaders, hds...)
957 hds = append(hds, "Content-Type", "application/json")
958 headers := gax.BuildHeaders(ctx, hds...)
959 opts = append((*c.CallOptions).GetFederation[0:len((*c.CallOptions).GetFederation):len((*c.CallOptions).GetFederation)], opts...)
960 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
961 resp := &metastorepb.Federation{}
962 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
963 if settings.Path != "" {
964 baseUrl.Path = settings.Path
965 }
966 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
967 if err != nil {
968 return err
969 }
970 httpReq = httpReq.WithContext(ctx)
971 httpReq.Header = headers
972
973 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetFederation")
974 if err != nil {
975 return err
976 }
977
978 if err := unm.Unmarshal(buf, resp); err != nil {
979 return err
980 }
981
982 return nil
983 }, opts...)
984 if e != nil {
985 return nil, e
986 }
987 return resp, nil
988 }
989
990 // CreateFederation creates a metastore federation in a project and location.
991 func (c *dataprocMetastoreFederationRESTClient) CreateFederation(ctx context.Context, req *metastorepb.CreateFederationRequest, opts ...gax.CallOption) (*CreateFederationOperation, error) {
992 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
993 body := req.GetFederation()
994 jsonReq, err := m.Marshal(body)
995 if err != nil {
996 return nil, err
997 }
998
999 baseUrl, err := url.Parse(c.endpoint)
1000 if err != nil {
1001 return nil, err
1002 }
1003 baseUrl.Path += fmt.Sprintf("/v1beta/%v/federations", req.GetParent())
1004
1005 params := url.Values{}
1006 params.Add("$alt", "json;enum-encoding=int")
1007 params.Add("federationId", fmt.Sprintf("%v", req.GetFederationId()))
1008 if req.GetRequestId() != "" {
1009 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1010 }
1011
1012 baseUrl.RawQuery = params.Encode()
1013
1014 // Build HTTP headers from client and context metadata.
1015 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1016
1017 hds = append(c.xGoogHeaders, hds...)
1018 hds = append(hds, "Content-Type", "application/json")
1019 headers := gax.BuildHeaders(ctx, hds...)
1020 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1021 resp := &longrunningpb.Operation{}
1022 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1023 if settings.Path != "" {
1024 baseUrl.Path = settings.Path
1025 }
1026 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1027 if err != nil {
1028 return err
1029 }
1030 httpReq = httpReq.WithContext(ctx)
1031 httpReq.Header = headers
1032
1033 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateFederation")
1034 if err != nil {
1035 return err
1036 }
1037 if err := unm.Unmarshal(buf, resp); err != nil {
1038 return err
1039 }
1040
1041 return nil
1042 }, opts...)
1043 if e != nil {
1044 return nil, e
1045 }
1046
1047 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
1048 return &CreateFederationOperation{
1049 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1050 pollPath: override,
1051 }, nil
1052 }
1053
1054 // UpdateFederation updates the fields of a federation.
1055 func (c *dataprocMetastoreFederationRESTClient) UpdateFederation(ctx context.Context, req *metastorepb.UpdateFederationRequest, opts ...gax.CallOption) (*UpdateFederationOperation, error) {
1056 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1057 body := req.GetFederation()
1058 jsonReq, err := m.Marshal(body)
1059 if err != nil {
1060 return nil, err
1061 }
1062
1063 baseUrl, err := url.Parse(c.endpoint)
1064 if err != nil {
1065 return nil, err
1066 }
1067 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetFederation().GetName())
1068
1069 params := url.Values{}
1070 params.Add("$alt", "json;enum-encoding=int")
1071 if req.GetRequestId() != "" {
1072 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1073 }
1074 if req.GetUpdateMask() != nil {
1075 field, err := protojson.Marshal(req.GetUpdateMask())
1076 if err != nil {
1077 return nil, err
1078 }
1079 params.Add("updateMask", string(field[1:len(field)-1]))
1080 }
1081
1082 baseUrl.RawQuery = params.Encode()
1083
1084 // Build HTTP headers from client and context metadata.
1085 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "federation.name", url.QueryEscape(req.GetFederation().GetName()))}
1086
1087 hds = append(c.xGoogHeaders, hds...)
1088 hds = append(hds, "Content-Type", "application/json")
1089 headers := gax.BuildHeaders(ctx, hds...)
1090 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1091 resp := &longrunningpb.Operation{}
1092 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1093 if settings.Path != "" {
1094 baseUrl.Path = settings.Path
1095 }
1096 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1097 if err != nil {
1098 return err
1099 }
1100 httpReq = httpReq.WithContext(ctx)
1101 httpReq.Header = headers
1102
1103 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateFederation")
1104 if err != nil {
1105 return err
1106 }
1107 if err := unm.Unmarshal(buf, resp); err != nil {
1108 return err
1109 }
1110
1111 return nil
1112 }, opts...)
1113 if e != nil {
1114 return nil, e
1115 }
1116
1117 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
1118 return &UpdateFederationOperation{
1119 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1120 pollPath: override,
1121 }, nil
1122 }
1123
1124 // DeleteFederation deletes a single federation.
1125 func (c *dataprocMetastoreFederationRESTClient) DeleteFederation(ctx context.Context, req *metastorepb.DeleteFederationRequest, opts ...gax.CallOption) (*DeleteFederationOperation, error) {
1126 baseUrl, err := url.Parse(c.endpoint)
1127 if err != nil {
1128 return nil, err
1129 }
1130 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
1131
1132 params := url.Values{}
1133 params.Add("$alt", "json;enum-encoding=int")
1134 if req.GetRequestId() != "" {
1135 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1136 }
1137
1138 baseUrl.RawQuery = params.Encode()
1139
1140 // Build HTTP headers from client and context metadata.
1141 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1142
1143 hds = append(c.xGoogHeaders, hds...)
1144 hds = append(hds, "Content-Type", "application/json")
1145 headers := gax.BuildHeaders(ctx, hds...)
1146 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1147 resp := &longrunningpb.Operation{}
1148 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1149 if settings.Path != "" {
1150 baseUrl.Path = settings.Path
1151 }
1152 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1153 if err != nil {
1154 return err
1155 }
1156 httpReq = httpReq.WithContext(ctx)
1157 httpReq.Header = headers
1158
1159 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteFederation")
1160 if err != nil {
1161 return err
1162 }
1163 if err := unm.Unmarshal(buf, resp); err != nil {
1164 return err
1165 }
1166
1167 return nil
1168 }, opts...)
1169 if e != nil {
1170 return nil, e
1171 }
1172
1173 override := fmt.Sprintf("/v1beta/%s", resp.GetName())
1174 return &DeleteFederationOperation{
1175 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1176 pollPath: override,
1177 }, nil
1178 }
1179
1180 // GetLocation gets information about a location.
1181 func (c *dataprocMetastoreFederationRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1182 baseUrl, err := url.Parse(c.endpoint)
1183 if err != nil {
1184 return nil, err
1185 }
1186 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
1187
1188 params := url.Values{}
1189 params.Add("$alt", "json;enum-encoding=int")
1190
1191 baseUrl.RawQuery = params.Encode()
1192
1193 // Build HTTP headers from client and context metadata.
1194 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1195
1196 hds = append(c.xGoogHeaders, hds...)
1197 hds = append(hds, "Content-Type", "application/json")
1198 headers := gax.BuildHeaders(ctx, hds...)
1199 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1200 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1201 resp := &locationpb.Location{}
1202 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1203 if settings.Path != "" {
1204 baseUrl.Path = settings.Path
1205 }
1206 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1207 if err != nil {
1208 return err
1209 }
1210 httpReq = httpReq.WithContext(ctx)
1211 httpReq.Header = headers
1212
1213 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
1214 if err != nil {
1215 return err
1216 }
1217
1218 if err := unm.Unmarshal(buf, resp); err != nil {
1219 return err
1220 }
1221
1222 return nil
1223 }, opts...)
1224 if e != nil {
1225 return nil, e
1226 }
1227 return resp, nil
1228 }
1229
1230 // ListLocations lists information about the supported locations for this service.
1231 func (c *dataprocMetastoreFederationRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1232 it := &LocationIterator{}
1233 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1234 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1235 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1236 resp := &locationpb.ListLocationsResponse{}
1237 if pageToken != "" {
1238 req.PageToken = pageToken
1239 }
1240 if pageSize > math.MaxInt32 {
1241 req.PageSize = math.MaxInt32
1242 } else if pageSize != 0 {
1243 req.PageSize = int32(pageSize)
1244 }
1245 baseUrl, err := url.Parse(c.endpoint)
1246 if err != nil {
1247 return nil, "", err
1248 }
1249 baseUrl.Path += fmt.Sprintf("/v1beta/%v/locations", req.GetName())
1250
1251 params := url.Values{}
1252 params.Add("$alt", "json;enum-encoding=int")
1253 if req.GetFilter() != "" {
1254 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1255 }
1256 if req.GetPageSize() != 0 {
1257 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1258 }
1259 if req.GetPageToken() != "" {
1260 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1261 }
1262
1263 baseUrl.RawQuery = params.Encode()
1264
1265 // Build HTTP headers from client and context metadata.
1266 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1267 headers := gax.BuildHeaders(ctx, hds...)
1268 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1269 if settings.Path != "" {
1270 baseUrl.Path = settings.Path
1271 }
1272 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1273 if err != nil {
1274 return err
1275 }
1276 httpReq.Header = headers
1277
1278 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
1279 if err != nil {
1280 return err
1281 }
1282 if err := unm.Unmarshal(buf, resp); err != nil {
1283 return err
1284 }
1285
1286 return nil
1287 }, opts...)
1288 if e != nil {
1289 return nil, "", e
1290 }
1291 it.Response = resp
1292 return resp.GetLocations(), resp.GetNextPageToken(), nil
1293 }
1294
1295 fetch := func(pageSize int, pageToken string) (string, error) {
1296 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1297 if err != nil {
1298 return "", err
1299 }
1300 it.items = append(it.items, items...)
1301 return nextPageToken, nil
1302 }
1303
1304 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1305 it.pageInfo.MaxSize = int(req.GetPageSize())
1306 it.pageInfo.Token = req.GetPageToken()
1307
1308 return it
1309 }
1310
1311 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
1312 // if the resource exists and does not have a policy set.
1313 func (c *dataprocMetastoreFederationRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1314 baseUrl, err := url.Parse(c.endpoint)
1315 if err != nil {
1316 return nil, err
1317 }
1318 baseUrl.Path += fmt.Sprintf("/v1beta/%v:getIamPolicy", req.GetResource())
1319
1320 params := url.Values{}
1321 params.Add("$alt", "json;enum-encoding=int")
1322 if req.GetOptions().GetRequestedPolicyVersion() != 0 {
1323 params.Add("options.requestedPolicyVersion", fmt.Sprintf("%v", req.GetOptions().GetRequestedPolicyVersion()))
1324 }
1325
1326 baseUrl.RawQuery = params.Encode()
1327
1328 // Build HTTP headers from client and context metadata.
1329 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1330
1331 hds = append(c.xGoogHeaders, hds...)
1332 hds = append(hds, "Content-Type", "application/json")
1333 headers := gax.BuildHeaders(ctx, hds...)
1334 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
1335 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1336 resp := &iampb.Policy{}
1337 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1338 if settings.Path != "" {
1339 baseUrl.Path = settings.Path
1340 }
1341 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1342 if err != nil {
1343 return err
1344 }
1345 httpReq = httpReq.WithContext(ctx)
1346 httpReq.Header = headers
1347
1348 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIamPolicy")
1349 if err != nil {
1350 return err
1351 }
1352
1353 if err := unm.Unmarshal(buf, resp); err != nil {
1354 return err
1355 }
1356
1357 return nil
1358 }, opts...)
1359 if e != nil {
1360 return nil, e
1361 }
1362 return resp, nil
1363 }
1364
1365 // SetIamPolicy sets the access control policy on the specified resource. Replaces
1366 // any existing policy.
1367 //
1368 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
1369 // errors.
1370 func (c *dataprocMetastoreFederationRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1371 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1372 jsonReq, err := m.Marshal(req)
1373 if err != nil {
1374 return nil, err
1375 }
1376
1377 baseUrl, err := url.Parse(c.endpoint)
1378 if err != nil {
1379 return nil, err
1380 }
1381 baseUrl.Path += fmt.Sprintf("/v1beta/%v:setIamPolicy", req.GetResource())
1382
1383 params := url.Values{}
1384 params.Add("$alt", "json;enum-encoding=int")
1385
1386 baseUrl.RawQuery = params.Encode()
1387
1388 // Build HTTP headers from client and context metadata.
1389 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1390
1391 hds = append(c.xGoogHeaders, hds...)
1392 hds = append(hds, "Content-Type", "application/json")
1393 headers := gax.BuildHeaders(ctx, hds...)
1394 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
1395 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1396 resp := &iampb.Policy{}
1397 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1398 if settings.Path != "" {
1399 baseUrl.Path = settings.Path
1400 }
1401 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1402 if err != nil {
1403 return err
1404 }
1405 httpReq = httpReq.WithContext(ctx)
1406 httpReq.Header = headers
1407
1408 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
1409 if err != nil {
1410 return err
1411 }
1412
1413 if err := unm.Unmarshal(buf, resp); err != nil {
1414 return err
1415 }
1416
1417 return nil
1418 }, opts...)
1419 if e != nil {
1420 return nil, e
1421 }
1422 return resp, nil
1423 }
1424
1425 // TestIamPermissions returns permissions that a caller has on the specified resource. If the
1426 // resource does not exist, this will return an empty set of
1427 // permissions, not a NOT_FOUND error.
1428 //
1429 // Note: This operation is designed to be used for building
1430 // permission-aware UIs and command-line tools, not for authorization
1431 // checking. This operation may “fail open” without warning.
1432 func (c *dataprocMetastoreFederationRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
1433 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1434 jsonReq, err := m.Marshal(req)
1435 if err != nil {
1436 return nil, err
1437 }
1438
1439 baseUrl, err := url.Parse(c.endpoint)
1440 if err != nil {
1441 return nil, err
1442 }
1443 baseUrl.Path += fmt.Sprintf("/v1beta/%v:testIamPermissions", req.GetResource())
1444
1445 params := url.Values{}
1446 params.Add("$alt", "json;enum-encoding=int")
1447
1448 baseUrl.RawQuery = params.Encode()
1449
1450 // Build HTTP headers from client and context metadata.
1451 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1452
1453 hds = append(c.xGoogHeaders, hds...)
1454 hds = append(hds, "Content-Type", "application/json")
1455 headers := gax.BuildHeaders(ctx, hds...)
1456 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
1457 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1458 resp := &iampb.TestIamPermissionsResponse{}
1459 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1460 if settings.Path != "" {
1461 baseUrl.Path = settings.Path
1462 }
1463 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1464 if err != nil {
1465 return err
1466 }
1467 httpReq = httpReq.WithContext(ctx)
1468 httpReq.Header = headers
1469
1470 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
1471 if err != nil {
1472 return err
1473 }
1474
1475 if err := unm.Unmarshal(buf, resp); err != nil {
1476 return err
1477 }
1478
1479 return nil
1480 }, opts...)
1481 if e != nil {
1482 return nil, e
1483 }
1484 return resp, nil
1485 }
1486
1487 // CancelOperation is a utility method from google.longrunning.Operations.
1488 func (c *dataprocMetastoreFederationRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1489 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1490 jsonReq, err := m.Marshal(req)
1491 if err != nil {
1492 return err
1493 }
1494
1495 baseUrl, err := url.Parse(c.endpoint)
1496 if err != nil {
1497 return err
1498 }
1499 baseUrl.Path += fmt.Sprintf("/v1beta/%v:cancel", req.GetName())
1500
1501 params := url.Values{}
1502 params.Add("$alt", "json;enum-encoding=int")
1503
1504 baseUrl.RawQuery = params.Encode()
1505
1506 // Build HTTP headers from client and context metadata.
1507 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1508
1509 hds = append(c.xGoogHeaders, hds...)
1510 hds = append(hds, "Content-Type", "application/json")
1511 headers := gax.BuildHeaders(ctx, hds...)
1512 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1513 if settings.Path != "" {
1514 baseUrl.Path = settings.Path
1515 }
1516 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1517 if err != nil {
1518 return err
1519 }
1520 httpReq = httpReq.WithContext(ctx)
1521 httpReq.Header = headers
1522
1523 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation")
1524 return err
1525 }, opts...)
1526 }
1527
1528 // DeleteOperation is a utility method from google.longrunning.Operations.
1529 func (c *dataprocMetastoreFederationRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
1530 baseUrl, err := url.Parse(c.endpoint)
1531 if err != nil {
1532 return err
1533 }
1534 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
1535
1536 params := url.Values{}
1537 params.Add("$alt", "json;enum-encoding=int")
1538
1539 baseUrl.RawQuery = params.Encode()
1540
1541 // Build HTTP headers from client and context metadata.
1542 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1543
1544 hds = append(c.xGoogHeaders, hds...)
1545 hds = append(hds, "Content-Type", "application/json")
1546 headers := gax.BuildHeaders(ctx, hds...)
1547 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1548 if settings.Path != "" {
1549 baseUrl.Path = settings.Path
1550 }
1551 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1552 if err != nil {
1553 return err
1554 }
1555 httpReq = httpReq.WithContext(ctx)
1556 httpReq.Header = headers
1557
1558 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
1559 return err
1560 }, opts...)
1561 }
1562
1563 // GetOperation is a utility method from google.longrunning.Operations.
1564 func (c *dataprocMetastoreFederationRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1565 baseUrl, err := url.Parse(c.endpoint)
1566 if err != nil {
1567 return nil, err
1568 }
1569 baseUrl.Path += fmt.Sprintf("/v1beta/%v", req.GetName())
1570
1571 params := url.Values{}
1572 params.Add("$alt", "json;enum-encoding=int")
1573
1574 baseUrl.RawQuery = params.Encode()
1575
1576 // Build HTTP headers from client and context metadata.
1577 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1578
1579 hds = append(c.xGoogHeaders, hds...)
1580 hds = append(hds, "Content-Type", "application/json")
1581 headers := gax.BuildHeaders(ctx, hds...)
1582 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1583 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1584 resp := &longrunningpb.Operation{}
1585 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1586 if settings.Path != "" {
1587 baseUrl.Path = settings.Path
1588 }
1589 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1590 if err != nil {
1591 return err
1592 }
1593 httpReq = httpReq.WithContext(ctx)
1594 httpReq.Header = headers
1595
1596 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
1597 if err != nil {
1598 return err
1599 }
1600
1601 if err := unm.Unmarshal(buf, resp); err != nil {
1602 return err
1603 }
1604
1605 return nil
1606 }, opts...)
1607 if e != nil {
1608 return nil, e
1609 }
1610 return resp, nil
1611 }
1612
1613 // ListOperations is a utility method from google.longrunning.Operations.
1614 func (c *dataprocMetastoreFederationRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1615 it := &OperationIterator{}
1616 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
1617 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1618 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
1619 resp := &longrunningpb.ListOperationsResponse{}
1620 if pageToken != "" {
1621 req.PageToken = pageToken
1622 }
1623 if pageSize > math.MaxInt32 {
1624 req.PageSize = math.MaxInt32
1625 } else if pageSize != 0 {
1626 req.PageSize = int32(pageSize)
1627 }
1628 baseUrl, err := url.Parse(c.endpoint)
1629 if err != nil {
1630 return nil, "", err
1631 }
1632 baseUrl.Path += fmt.Sprintf("/v1beta/%v/operations", req.GetName())
1633
1634 params := url.Values{}
1635 params.Add("$alt", "json;enum-encoding=int")
1636 if req.GetFilter() != "" {
1637 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1638 }
1639 if req.GetPageSize() != 0 {
1640 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1641 }
1642 if req.GetPageToken() != "" {
1643 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1644 }
1645
1646 baseUrl.RawQuery = params.Encode()
1647
1648 // Build HTTP headers from client and context metadata.
1649 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1650 headers := gax.BuildHeaders(ctx, hds...)
1651 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1652 if settings.Path != "" {
1653 baseUrl.Path = settings.Path
1654 }
1655 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1656 if err != nil {
1657 return err
1658 }
1659 httpReq.Header = headers
1660
1661 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
1662 if err != nil {
1663 return err
1664 }
1665 if err := unm.Unmarshal(buf, resp); err != nil {
1666 return err
1667 }
1668
1669 return nil
1670 }, opts...)
1671 if e != nil {
1672 return nil, "", e
1673 }
1674 it.Response = resp
1675 return resp.GetOperations(), resp.GetNextPageToken(), nil
1676 }
1677
1678 fetch := func(pageSize int, pageToken string) (string, error) {
1679 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1680 if err != nil {
1681 return "", err
1682 }
1683 it.items = append(it.items, items...)
1684 return nextPageToken, nil
1685 }
1686
1687 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1688 it.pageInfo.MaxSize = int(req.GetPageSize())
1689 it.pageInfo.Token = req.GetPageToken()
1690
1691 return it
1692 }
1693
1694 // CreateFederationOperation returns a new CreateFederationOperation from a given name.
1695 // The name must be that of a previously created CreateFederationOperation, possibly from a different process.
1696 func (c *dataprocMetastoreFederationGRPCClient) CreateFederationOperation(name string) *CreateFederationOperation {
1697 return &CreateFederationOperation{
1698 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1699 }
1700 }
1701
1702 // CreateFederationOperation returns a new CreateFederationOperation from a given name.
1703 // The name must be that of a previously created CreateFederationOperation, possibly from a different process.
1704 func (c *dataprocMetastoreFederationRESTClient) CreateFederationOperation(name string) *CreateFederationOperation {
1705 override := fmt.Sprintf("/v1beta/%s", name)
1706 return &CreateFederationOperation{
1707 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1708 pollPath: override,
1709 }
1710 }
1711
1712 // DeleteFederationOperation returns a new DeleteFederationOperation from a given name.
1713 // The name must be that of a previously created DeleteFederationOperation, possibly from a different process.
1714 func (c *dataprocMetastoreFederationGRPCClient) DeleteFederationOperation(name string) *DeleteFederationOperation {
1715 return &DeleteFederationOperation{
1716 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1717 }
1718 }
1719
1720 // DeleteFederationOperation returns a new DeleteFederationOperation from a given name.
1721 // The name must be that of a previously created DeleteFederationOperation, possibly from a different process.
1722 func (c *dataprocMetastoreFederationRESTClient) DeleteFederationOperation(name string) *DeleteFederationOperation {
1723 override := fmt.Sprintf("/v1beta/%s", name)
1724 return &DeleteFederationOperation{
1725 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1726 pollPath: override,
1727 }
1728 }
1729
1730 // UpdateFederationOperation returns a new UpdateFederationOperation from a given name.
1731 // The name must be that of a previously created UpdateFederationOperation, possibly from a different process.
1732 func (c *dataprocMetastoreFederationGRPCClient) UpdateFederationOperation(name string) *UpdateFederationOperation {
1733 return &UpdateFederationOperation{
1734 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1735 }
1736 }
1737
1738 // UpdateFederationOperation returns a new UpdateFederationOperation from a given name.
1739 // The name must be that of a previously created UpdateFederationOperation, possibly from a different process.
1740 func (c *dataprocMetastoreFederationRESTClient) UpdateFederationOperation(name string) *UpdateFederationOperation {
1741 override := fmt.Sprintf("/v1beta/%s", name)
1742 return &UpdateFederationOperation{
1743 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1744 pollPath: override,
1745 }
1746 }