Debian Codegraph @

bigquery/datapolicies/apiv1beta1/data_policy_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 datapolicies
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1beta1/datapoliciespb"
30 iampb "cloud.google.com/go/iam/apiv1/iampb"
31 gax "github.com/googleapis/gax-go/v2"
32 "google.golang.org/api/iterator"
33 "google.golang.org/api/option"
34 "google.golang.org/api/option/internaloption"
35 gtransport "google.golang.org/api/transport/grpc"
36 httptransport "google.golang.org/api/transport/http"
37 "google.golang.org/grpc"
38 "google.golang.org/grpc/codes"
39 "google.golang.org/protobuf/encoding/protojson"
40 "google.golang.org/protobuf/proto"
41 )
42
43 var newDataPolicyClientHook clientHook
44
45 // DataPolicyCallOptions contains the retry settings for each method of DataPolicyClient.
46 type DataPolicyCallOptions struct {
47 CreateDataPolicy []gax.CallOption
48 UpdateDataPolicy []gax.CallOption
49 DeleteDataPolicy []gax.CallOption
50 GetDataPolicy []gax.CallOption
51 ListDataPolicies []gax.CallOption
52 GetIamPolicy []gax.CallOption
53 SetIamPolicy []gax.CallOption
54 TestIamPermissions []gax.CallOption
55 }
56
57 func defaultDataPolicyGRPCClientOptions() []option.ClientOption {
58 return []option.ClientOption{
59 internaloption.WithDefaultEndpoint("bigquerydatapolicy.googleapis.com:443"),
60 internaloption.WithDefaultEndpointTemplate("bigquerydatapolicy.UNIVERSE_DOMAIN:443"),
61 internaloption.WithDefaultMTLSEndpoint("bigquerydatapolicy.mtls.googleapis.com:443"),
62 internaloption.WithDefaultUniverseDomain("googleapis.com"),
63 internaloption.WithDefaultAudience("https://bigquerydatapolicy.googleapis.com/"),
64 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
65 internaloption.EnableJwtWithScope(),
66 internaloption.EnableNewAuthLibrary(),
67 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
68 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
69 }
70 }
71
72 func defaultDataPolicyCallOptions() *DataPolicyCallOptions {
73 return &DataPolicyCallOptions{
74 CreateDataPolicy: []gax.CallOption{
75 gax.WithTimeout(60000 * time.Millisecond),
76 gax.WithRetry(func() gax.Retryer {
77 return gax.OnCodes([]codes.Code{
78 codes.Unavailable,
79 }, gax.Backoff{
80 Initial: 1000 * time.Millisecond,
81 Max: 10000 * time.Millisecond,
82 Multiplier: 1.30,
83 })
84 }),
85 },
86 UpdateDataPolicy: []gax.CallOption{
87 gax.WithTimeout(60000 * time.Millisecond),
88 gax.WithRetry(func() gax.Retryer {
89 return gax.OnCodes([]codes.Code{
90 codes.Unavailable,
91 }, gax.Backoff{
92 Initial: 1000 * time.Millisecond,
93 Max: 10000 * time.Millisecond,
94 Multiplier: 1.30,
95 })
96 }),
97 },
98 DeleteDataPolicy: []gax.CallOption{
99 gax.WithTimeout(60000 * time.Millisecond),
100 gax.WithRetry(func() gax.Retryer {
101 return gax.OnCodes([]codes.Code{
102 codes.Unavailable,
103 }, gax.Backoff{
104 Initial: 1000 * time.Millisecond,
105 Max: 10000 * time.Millisecond,
106 Multiplier: 1.30,
107 })
108 }),
109 },
110 GetDataPolicy: []gax.CallOption{
111 gax.WithTimeout(60000 * time.Millisecond),
112 gax.WithRetry(func() gax.Retryer {
113 return gax.OnCodes([]codes.Code{
114 codes.Unavailable,
115 }, gax.Backoff{
116 Initial: 1000 * time.Millisecond,
117 Max: 10000 * time.Millisecond,
118 Multiplier: 1.30,
119 })
120 }),
121 },
122 ListDataPolicies: []gax.CallOption{
123 gax.WithTimeout(60000 * time.Millisecond),
124 gax.WithRetry(func() gax.Retryer {
125 return gax.OnCodes([]codes.Code{
126 codes.Unavailable,
127 }, gax.Backoff{
128 Initial: 1000 * time.Millisecond,
129 Max: 10000 * time.Millisecond,
130 Multiplier: 1.30,
131 })
132 }),
133 },
134 GetIamPolicy: []gax.CallOption{
135 gax.WithTimeout(60000 * time.Millisecond),
136 gax.WithRetry(func() gax.Retryer {
137 return gax.OnCodes([]codes.Code{
138 codes.Unavailable,
139 }, gax.Backoff{
140 Initial: 1000 * time.Millisecond,
141 Max: 10000 * time.Millisecond,
142 Multiplier: 1.30,
143 })
144 }),
145 },
146 SetIamPolicy: []gax.CallOption{
147 gax.WithTimeout(60000 * time.Millisecond),
148 gax.WithRetry(func() gax.Retryer {
149 return gax.OnCodes([]codes.Code{
150 codes.Unavailable,
151 }, gax.Backoff{
152 Initial: 1000 * time.Millisecond,
153 Max: 10000 * time.Millisecond,
154 Multiplier: 1.30,
155 })
156 }),
157 },
158 TestIamPermissions: []gax.CallOption{
159 gax.WithTimeout(60000 * time.Millisecond),
160 gax.WithRetry(func() gax.Retryer {
161 return gax.OnCodes([]codes.Code{
162 codes.Unavailable,
163 }, gax.Backoff{
164 Initial: 1000 * time.Millisecond,
165 Max: 10000 * time.Millisecond,
166 Multiplier: 1.30,
167 })
168 }),
169 },
170 }
171 }
172
173 func defaultDataPolicyRESTCallOptions() *DataPolicyCallOptions {
174 return &DataPolicyCallOptions{
175 CreateDataPolicy: []gax.CallOption{
176 gax.WithTimeout(60000 * time.Millisecond),
177 gax.WithRetry(func() gax.Retryer {
178 return gax.OnHTTPCodes(gax.Backoff{
179 Initial: 1000 * time.Millisecond,
180 Max: 10000 * time.Millisecond,
181 Multiplier: 1.30,
182 },
183 http.StatusServiceUnavailable)
184 }),
185 },
186 UpdateDataPolicy: []gax.CallOption{
187 gax.WithTimeout(60000 * time.Millisecond),
188 gax.WithRetry(func() gax.Retryer {
189 return gax.OnHTTPCodes(gax.Backoff{
190 Initial: 1000 * time.Millisecond,
191 Max: 10000 * time.Millisecond,
192 Multiplier: 1.30,
193 },
194 http.StatusServiceUnavailable)
195 }),
196 },
197 DeleteDataPolicy: []gax.CallOption{
198 gax.WithTimeout(60000 * time.Millisecond),
199 gax.WithRetry(func() gax.Retryer {
200 return gax.OnHTTPCodes(gax.Backoff{
201 Initial: 1000 * time.Millisecond,
202 Max: 10000 * time.Millisecond,
203 Multiplier: 1.30,
204 },
205 http.StatusServiceUnavailable)
206 }),
207 },
208 GetDataPolicy: []gax.CallOption{
209 gax.WithTimeout(60000 * time.Millisecond),
210 gax.WithRetry(func() gax.Retryer {
211 return gax.OnHTTPCodes(gax.Backoff{
212 Initial: 1000 * time.Millisecond,
213 Max: 10000 * time.Millisecond,
214 Multiplier: 1.30,
215 },
216 http.StatusServiceUnavailable)
217 }),
218 },
219 ListDataPolicies: []gax.CallOption{
220 gax.WithTimeout(60000 * time.Millisecond),
221 gax.WithRetry(func() gax.Retryer {
222 return gax.OnHTTPCodes(gax.Backoff{
223 Initial: 1000 * time.Millisecond,
224 Max: 10000 * time.Millisecond,
225 Multiplier: 1.30,
226 },
227 http.StatusServiceUnavailable)
228 }),
229 },
230 GetIamPolicy: []gax.CallOption{
231 gax.WithTimeout(60000 * time.Millisecond),
232 gax.WithRetry(func() gax.Retryer {
233 return gax.OnHTTPCodes(gax.Backoff{
234 Initial: 1000 * time.Millisecond,
235 Max: 10000 * time.Millisecond,
236 Multiplier: 1.30,
237 },
238 http.StatusServiceUnavailable)
239 }),
240 },
241 SetIamPolicy: []gax.CallOption{
242 gax.WithTimeout(60000 * time.Millisecond),
243 gax.WithRetry(func() gax.Retryer {
244 return gax.OnHTTPCodes(gax.Backoff{
245 Initial: 1000 * time.Millisecond,
246 Max: 10000 * time.Millisecond,
247 Multiplier: 1.30,
248 },
249 http.StatusServiceUnavailable)
250 }),
251 },
252 TestIamPermissions: []gax.CallOption{
253 gax.WithTimeout(60000 * time.Millisecond),
254 gax.WithRetry(func() gax.Retryer {
255 return gax.OnHTTPCodes(gax.Backoff{
256 Initial: 1000 * time.Millisecond,
257 Max: 10000 * time.Millisecond,
258 Multiplier: 1.30,
259 },
260 http.StatusServiceUnavailable)
261 }),
262 },
263 }
264 }
265
266 // internalDataPolicyClient is an interface that defines the methods available from BigQuery Data Policy API.
267 type internalDataPolicyClient interface {
268 Close() error
269 setGoogleClientInfo(...string)
270 Connection() *grpc.ClientConn
271 CreateDataPolicy(context.Context, *datapoliciespb.CreateDataPolicyRequest, ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
272 UpdateDataPolicy(context.Context, *datapoliciespb.UpdateDataPolicyRequest, ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
273 DeleteDataPolicy(context.Context, *datapoliciespb.DeleteDataPolicyRequest, ...gax.CallOption) error
274 GetDataPolicy(context.Context, *datapoliciespb.GetDataPolicyRequest, ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
275 ListDataPolicies(context.Context, *datapoliciespb.ListDataPoliciesRequest, ...gax.CallOption) *DataPolicyIterator
276 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
277 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
278 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
279 }
280
281 // DataPolicyClient is a client for interacting with BigQuery Data Policy API.
282 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
283 //
284 // Data Policy Service provides APIs for managing the label-policy bindings.
285 type DataPolicyClient struct {
286 // The internal transport-dependent client.
287 internalClient internalDataPolicyClient
288
289 // The call options for this service.
290 CallOptions *DataPolicyCallOptions
291 }
292
293 // Wrapper methods routed to the internal client.
294
295 // Close closes the connection to the API service. The user should invoke this when
296 // the client is no longer required.
297 func (c *DataPolicyClient) Close() error {
298 return c.internalClient.Close()
299 }
300
301 // setGoogleClientInfo sets the name and version of the application in
302 // the `x-goog-api-client` header passed on each request. Intended for
303 // use by Google-written clients.
304 func (c *DataPolicyClient) setGoogleClientInfo(keyval ...string) {
305 c.internalClient.setGoogleClientInfo(keyval...)
306 }
307
308 // Connection returns a connection to the API service.
309 //
310 // Deprecated: Connections are now pooled so this method does not always
311 // return the same resource.
312 func (c *DataPolicyClient) Connection() *grpc.ClientConn {
313 return c.internalClient.Connection()
314 }
315
316 // CreateDataPolicy creates a new data policy under a project with the given dataPolicyId
317 // (used as the display name), policy tag, and data policy type.
318 func (c *DataPolicyClient) CreateDataPolicy(ctx context.Context, req *datapoliciespb.CreateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
319 return c.internalClient.CreateDataPolicy(ctx, req, opts...)
320 }
321
322 // UpdateDataPolicy updates the metadata for an existing data policy. The target data policy
323 // can be specified by the resource name.
324 func (c *DataPolicyClient) UpdateDataPolicy(ctx context.Context, req *datapoliciespb.UpdateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
325 return c.internalClient.UpdateDataPolicy(ctx, req, opts...)
326 }
327
328 // DeleteDataPolicy deletes the data policy specified by its resource name.
329 func (c *DataPolicyClient) DeleteDataPolicy(ctx context.Context, req *datapoliciespb.DeleteDataPolicyRequest, opts ...gax.CallOption) error {
330 return c.internalClient.DeleteDataPolicy(ctx, req, opts...)
331 }
332
333 // GetDataPolicy gets the data policy specified by its resource name.
334 func (c *DataPolicyClient) GetDataPolicy(ctx context.Context, req *datapoliciespb.GetDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
335 return c.internalClient.GetDataPolicy(ctx, req, opts...)
336 }
337
338 // ListDataPolicies list all of the data policies in the specified parent project.
339 func (c *DataPolicyClient) ListDataPolicies(ctx context.Context, req *datapoliciespb.ListDataPoliciesRequest, opts ...gax.CallOption) *DataPolicyIterator {
340 return c.internalClient.ListDataPolicies(ctx, req, opts...)
341 }
342
343 // GetIamPolicy gets the IAM policy for the specified data policy.
344 func (c *DataPolicyClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
345 return c.internalClient.GetIamPolicy(ctx, req, opts...)
346 }
347
348 // SetIamPolicy sets the IAM policy for the specified data policy.
349 func (c *DataPolicyClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
350 return c.internalClient.SetIamPolicy(ctx, req, opts...)
351 }
352
353 // TestIamPermissions returns the caller’s permission on the specified data policy resource.
354 func (c *DataPolicyClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
355 return c.internalClient.TestIamPermissions(ctx, req, opts...)
356 }
357
358 // dataPolicyGRPCClient is a client for interacting with BigQuery Data Policy API over gRPC transport.
359 //
360 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
361 type dataPolicyGRPCClient struct {
362 // Connection pool of gRPC connections to the service.
363 connPool gtransport.ConnPool
364
365 // Points back to the CallOptions field of the containing DataPolicyClient
366 CallOptions **DataPolicyCallOptions
367
368 // The gRPC API client.
369 dataPolicyClient datapoliciespb.DataPolicyServiceClient
370
371 // The x-goog-* metadata to be sent with each request.
372 xGoogHeaders []string
373
374 logger *slog.Logger
375 }
376
377 // NewDataPolicyClient creates a new data policy service client based on gRPC.
378 // The returned client must be Closed when it is done being used to clean up its underlying connections.
379 //
380 // Data Policy Service provides APIs for managing the label-policy bindings.
381 func NewDataPolicyClient(ctx context.Context, opts ...option.ClientOption) (*DataPolicyClient, error) {
382 clientOpts := defaultDataPolicyGRPCClientOptions()
383 if newDataPolicyClientHook != nil {
384 hookOpts, err := newDataPolicyClientHook(ctx, clientHookParams{})
385 if err != nil {
386 return nil, err
387 }
388 clientOpts = append(clientOpts, hookOpts...)
389 }
390
391 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
392 if err != nil {
393 return nil, err
394 }
395 client := DataPolicyClient{CallOptions: defaultDataPolicyCallOptions()}
396
397 c := &dataPolicyGRPCClient{
398 connPool: connPool,
399 dataPolicyClient: datapoliciespb.NewDataPolicyServiceClient(connPool),
400 CallOptions: &client.CallOptions,
401 logger: internaloption.GetLogger(opts),
402 }
403 c.setGoogleClientInfo()
404
405 client.internalClient = c
406
407 return &client, nil
408 }
409
410 // Connection returns a connection to the API service.
411 //
412 // Deprecated: Connections are now pooled so this method does not always
413 // return the same resource.
414 func (c *dataPolicyGRPCClient) Connection() *grpc.ClientConn {
415 return c.connPool.Conn()
416 }
417
418 // setGoogleClientInfo sets the name and version of the application in
419 // the `x-goog-api-client` header passed on each request. Intended for
420 // use by Google-written clients.
421 func (c *dataPolicyGRPCClient) setGoogleClientInfo(keyval ...string) {
422 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
423 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
424 c.xGoogHeaders = []string{
425 "x-goog-api-client", gax.XGoogHeader(kv...),
426 }
427 }
428
429 // Close closes the connection to the API service. The user should invoke this when
430 // the client is no longer required.
431 func (c *dataPolicyGRPCClient) Close() error {
432 return c.connPool.Close()
433 }
434
435 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
436 type dataPolicyRESTClient struct {
437 // The http endpoint to connect to.
438 endpoint string
439
440 // The http client.
441 httpClient *http.Client
442
443 // The x-goog-* headers to be sent with each request.
444 xGoogHeaders []string
445
446 // Points back to the CallOptions field of the containing DataPolicyClient
447 CallOptions **DataPolicyCallOptions
448
449 logger *slog.Logger
450 }
451
452 // NewDataPolicyRESTClient creates a new data policy service rest client.
453 //
454 // Data Policy Service provides APIs for managing the label-policy bindings.
455 func NewDataPolicyRESTClient(ctx context.Context, opts ...option.ClientOption) (*DataPolicyClient, error) {
456 clientOpts := append(defaultDataPolicyRESTClientOptions(), opts...)
457 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
458 if err != nil {
459 return nil, err
460 }
461
462 callOpts := defaultDataPolicyRESTCallOptions()
463 c := &dataPolicyRESTClient{
464 endpoint: endpoint,
465 httpClient: httpClient,
466 CallOptions: &callOpts,
467 logger: internaloption.GetLogger(opts),
468 }
469 c.setGoogleClientInfo()
470
471 return &DataPolicyClient{internalClient: c, CallOptions: callOpts}, nil
472 }
473
474 func defaultDataPolicyRESTClientOptions() []option.ClientOption {
475 return []option.ClientOption{
476 internaloption.WithDefaultEndpoint("https://bigquerydatapolicy.googleapis.com"),
477 internaloption.WithDefaultEndpointTemplate("https://bigquerydatapolicy.UNIVERSE_DOMAIN"),
478 internaloption.WithDefaultMTLSEndpoint("https://bigquerydatapolicy.mtls.googleapis.com"),
479 internaloption.WithDefaultUniverseDomain("googleapis.com"),
480 internaloption.WithDefaultAudience("https://bigquerydatapolicy.googleapis.com/"),
481 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
482 internaloption.EnableNewAuthLibrary(),
483 }
484 }
485
486 // setGoogleClientInfo sets the name and version of the application in
487 // the `x-goog-api-client` header passed on each request. Intended for
488 // use by Google-written clients.
489 func (c *dataPolicyRESTClient) setGoogleClientInfo(keyval ...string) {
490 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
491 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
492 c.xGoogHeaders = []string{
493 "x-goog-api-client", gax.XGoogHeader(kv...),
494 }
495 }
496
497 // Close closes the connection to the API service. The user should invoke this when
498 // the client is no longer required.
499 func (c *dataPolicyRESTClient) Close() error {
500 // Replace httpClient with nil to force cleanup.
501 c.httpClient = nil
502 return nil
503 }
504
505 // Connection returns a connection to the API service.
506 //
507 // Deprecated: This method always returns nil.
508 func (c *dataPolicyRESTClient) Connection() *grpc.ClientConn {
509 return nil
510 }
511 func (c *dataPolicyGRPCClient) CreateDataPolicy(ctx context.Context, req *datapoliciespb.CreateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
512 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
513
514 hds = append(c.xGoogHeaders, hds...)
515 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
516 opts = append((*c.CallOptions).CreateDataPolicy[0:len((*c.CallOptions).CreateDataPolicy):len((*c.CallOptions).CreateDataPolicy)], opts...)
517 var resp *datapoliciespb.DataPolicy
518 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
519 var err error
520 resp, err = executeRPC(ctx, c.dataPolicyClient.CreateDataPolicy, req, settings.GRPC, c.logger, "CreateDataPolicy")
521 return err
522 }, opts...)
523 if err != nil {
524 return nil, err
525 }
526 return resp, nil
527 }
528
529 func (c *dataPolicyGRPCClient) UpdateDataPolicy(ctx context.Context, req *datapoliciespb.UpdateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
530 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "data_policy.name", url.QueryEscape(req.GetDataPolicy().GetName()))}
531
532 hds = append(c.xGoogHeaders, hds...)
533 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
534 opts = append((*c.CallOptions).UpdateDataPolicy[0:len((*c.CallOptions).UpdateDataPolicy):len((*c.CallOptions).UpdateDataPolicy)], opts...)
535 var resp *datapoliciespb.DataPolicy
536 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
537 var err error
538 resp, err = executeRPC(ctx, c.dataPolicyClient.UpdateDataPolicy, req, settings.GRPC, c.logger, "UpdateDataPolicy")
539 return err
540 }, opts...)
541 if err != nil {
542 return nil, err
543 }
544 return resp, nil
545 }
546
547 func (c *dataPolicyGRPCClient) DeleteDataPolicy(ctx context.Context, req *datapoliciespb.DeleteDataPolicyRequest, opts ...gax.CallOption) error {
548 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
549
550 hds = append(c.xGoogHeaders, hds...)
551 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
552 opts = append((*c.CallOptions).DeleteDataPolicy[0:len((*c.CallOptions).DeleteDataPolicy):len((*c.CallOptions).DeleteDataPolicy)], opts...)
553 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
554 var err error
555 _, err = executeRPC(ctx, c.dataPolicyClient.DeleteDataPolicy, req, settings.GRPC, c.logger, "DeleteDataPolicy")
556 return err
557 }, opts...)
558 return err
559 }
560
561 func (c *dataPolicyGRPCClient) GetDataPolicy(ctx context.Context, req *datapoliciespb.GetDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
562 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
563
564 hds = append(c.xGoogHeaders, hds...)
565 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
566 opts = append((*c.CallOptions).GetDataPolicy[0:len((*c.CallOptions).GetDataPolicy):len((*c.CallOptions).GetDataPolicy)], opts...)
567 var resp *datapoliciespb.DataPolicy
568 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
569 var err error
570 resp, err = executeRPC(ctx, c.dataPolicyClient.GetDataPolicy, req, settings.GRPC, c.logger, "GetDataPolicy")
571 return err
572 }, opts...)
573 if err != nil {
574 return nil, err
575 }
576 return resp, nil
577 }
578
579 func (c *dataPolicyGRPCClient) ListDataPolicies(ctx context.Context, req *datapoliciespb.ListDataPoliciesRequest, opts ...gax.CallOption) *DataPolicyIterator {
580 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
581
582 hds = append(c.xGoogHeaders, hds...)
583 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
584 opts = append((*c.CallOptions).ListDataPolicies[0:len((*c.CallOptions).ListDataPolicies):len((*c.CallOptions).ListDataPolicies)], opts...)
585 it := &DataPolicyIterator{}
586 req = proto.Clone(req).(*datapoliciespb.ListDataPoliciesRequest)
587 it.InternalFetch = func(pageSize int, pageToken string) ([]*datapoliciespb.DataPolicy, string, error) {
588 resp := &datapoliciespb.ListDataPoliciesResponse{}
589 if pageToken != "" {
590 req.PageToken = pageToken
591 }
592 if pageSize > math.MaxInt32 {
593 req.PageSize = math.MaxInt32
594 } else if pageSize != 0 {
595 req.PageSize = int32(pageSize)
596 }
597 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
598 var err error
599 resp, err = executeRPC(ctx, c.dataPolicyClient.ListDataPolicies, req, settings.GRPC, c.logger, "ListDataPolicies")
600 return err
601 }, opts...)
602 if err != nil {
603 return nil, "", err
604 }
605
606 it.Response = resp
607 return resp.GetDataPolicies(), resp.GetNextPageToken(), nil
608 }
609 fetch := func(pageSize int, pageToken string) (string, error) {
610 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
611 if err != nil {
612 return "", err
613 }
614 it.items = append(it.items, items...)
615 return nextPageToken, nil
616 }
617
618 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
619 it.pageInfo.MaxSize = int(req.GetPageSize())
620 it.pageInfo.Token = req.GetPageToken()
621
622 return it
623 }
624
625 func (c *dataPolicyGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
626 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
627
628 hds = append(c.xGoogHeaders, hds...)
629 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
630 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
631 var resp *iampb.Policy
632 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
633 var err error
634 resp, err = executeRPC(ctx, c.dataPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
635 return err
636 }, opts...)
637 if err != nil {
638 return nil, err
639 }
640 return resp, nil
641 }
642
643 func (c *dataPolicyGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
644 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
645
646 hds = append(c.xGoogHeaders, hds...)
647 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
648 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
649 var resp *iampb.Policy
650 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
651 var err error
652 resp, err = executeRPC(ctx, c.dataPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
653 return err
654 }, opts...)
655 if err != nil {
656 return nil, err
657 }
658 return resp, nil
659 }
660
661 func (c *dataPolicyGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
662 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
663
664 hds = append(c.xGoogHeaders, hds...)
665 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
666 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
667 var resp *iampb.TestIamPermissionsResponse
668 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
669 var err error
670 resp, err = executeRPC(ctx, c.dataPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
671 return err
672 }, opts...)
673 if err != nil {
674 return nil, err
675 }
676 return resp, nil
677 }
678
679 // CreateDataPolicy creates a new data policy under a project with the given dataPolicyId
680 // (used as the display name), policy tag, and data policy type.
681 func (c *dataPolicyRESTClient) CreateDataPolicy(ctx context.Context, req *datapoliciespb.CreateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
682 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
683 body := req.GetDataPolicy()
684 jsonReq, err := m.Marshal(body)
685 if err != nil {
686 return nil, err
687 }
688
689 baseUrl, err := url.Parse(c.endpoint)
690 if err != nil {
691 return nil, err
692 }
693 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/dataPolicies", req.GetParent())
694
695 // Build HTTP headers from client and context metadata.
696 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
697
698 hds = append(c.xGoogHeaders, hds...)
699 hds = append(hds, "Content-Type", "application/json")
700 headers := gax.BuildHeaders(ctx, hds...)
701 opts = append((*c.CallOptions).CreateDataPolicy[0:len((*c.CallOptions).CreateDataPolicy):len((*c.CallOptions).CreateDataPolicy)], opts...)
702 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
703 resp := &datapoliciespb.DataPolicy{}
704 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
705 if settings.Path != "" {
706 baseUrl.Path = settings.Path
707 }
708 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
709 if err != nil {
710 return err
711 }
712 httpReq = httpReq.WithContext(ctx)
713 httpReq.Header = headers
714
715 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateDataPolicy")
716 if err != nil {
717 return err
718 }
719
720 if err := unm.Unmarshal(buf, resp); err != nil {
721 return err
722 }
723
724 return nil
725 }, opts...)
726 if e != nil {
727 return nil, e
728 }
729 return resp, nil
730 }
731
732 // UpdateDataPolicy updates the metadata for an existing data policy. The target data policy
733 // can be specified by the resource name.
734 func (c *dataPolicyRESTClient) UpdateDataPolicy(ctx context.Context, req *datapoliciespb.UpdateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
735 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
736 body := req.GetDataPolicy()
737 jsonReq, err := m.Marshal(body)
738 if err != nil {
739 return nil, err
740 }
741
742 baseUrl, err := url.Parse(c.endpoint)
743 if err != nil {
744 return nil, err
745 }
746 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetDataPolicy().GetName())
747
748 params := url.Values{}
749 if req.GetUpdateMask() != nil {
750 field, err := protojson.Marshal(req.GetUpdateMask())
751 if err != nil {
752 return nil, err
753 }
754 params.Add("updateMask", string(field[1:len(field)-1]))
755 }
756
757 baseUrl.RawQuery = params.Encode()
758
759 // Build HTTP headers from client and context metadata.
760 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "data_policy.name", url.QueryEscape(req.GetDataPolicy().GetName()))}
761
762 hds = append(c.xGoogHeaders, hds...)
763 hds = append(hds, "Content-Type", "application/json")
764 headers := gax.BuildHeaders(ctx, hds...)
765 opts = append((*c.CallOptions).UpdateDataPolicy[0:len((*c.CallOptions).UpdateDataPolicy):len((*c.CallOptions).UpdateDataPolicy)], opts...)
766 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
767 resp := &datapoliciespb.DataPolicy{}
768 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
769 if settings.Path != "" {
770 baseUrl.Path = settings.Path
771 }
772 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
773 if err != nil {
774 return err
775 }
776 httpReq = httpReq.WithContext(ctx)
777 httpReq.Header = headers
778
779 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateDataPolicy")
780 if err != nil {
781 return err
782 }
783
784 if err := unm.Unmarshal(buf, resp); err != nil {
785 return err
786 }
787
788 return nil
789 }, opts...)
790 if e != nil {
791 return nil, e
792 }
793 return resp, nil
794 }
795
796 // DeleteDataPolicy deletes the data policy specified by its resource name.
797 func (c *dataPolicyRESTClient) DeleteDataPolicy(ctx context.Context, req *datapoliciespb.DeleteDataPolicyRequest, opts ...gax.CallOption) error {
798 baseUrl, err := url.Parse(c.endpoint)
799 if err != nil {
800 return err
801 }
802 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
803
804 // Build HTTP headers from client and context metadata.
805 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
806
807 hds = append(c.xGoogHeaders, hds...)
808 hds = append(hds, "Content-Type", "application/json")
809 headers := gax.BuildHeaders(ctx, hds...)
810 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
811 if settings.Path != "" {
812 baseUrl.Path = settings.Path
813 }
814 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
815 if err != nil {
816 return err
817 }
818 httpReq = httpReq.WithContext(ctx)
819 httpReq.Header = headers
820
821 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteDataPolicy")
822 return err
823 }, opts...)
824 }
825
826 // GetDataPolicy gets the data policy specified by its resource name.
827 func (c *dataPolicyRESTClient) GetDataPolicy(ctx context.Context, req *datapoliciespb.GetDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error) {
828 baseUrl, err := url.Parse(c.endpoint)
829 if err != nil {
830 return nil, err
831 }
832 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
833
834 // Build HTTP headers from client and context metadata.
835 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
836
837 hds = append(c.xGoogHeaders, hds...)
838 hds = append(hds, "Content-Type", "application/json")
839 headers := gax.BuildHeaders(ctx, hds...)
840 opts = append((*c.CallOptions).GetDataPolicy[0:len((*c.CallOptions).GetDataPolicy):len((*c.CallOptions).GetDataPolicy)], opts...)
841 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
842 resp := &datapoliciespb.DataPolicy{}
843 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
844 if settings.Path != "" {
845 baseUrl.Path = settings.Path
846 }
847 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
848 if err != nil {
849 return err
850 }
851 httpReq = httpReq.WithContext(ctx)
852 httpReq.Header = headers
853
854 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDataPolicy")
855 if err != nil {
856 return err
857 }
858
859 if err := unm.Unmarshal(buf, resp); err != nil {
860 return err
861 }
862
863 return nil
864 }, opts...)
865 if e != nil {
866 return nil, e
867 }
868 return resp, nil
869 }
870
871 // ListDataPolicies list all of the data policies in the specified parent project.
872 func (c *dataPolicyRESTClient) ListDataPolicies(ctx context.Context, req *datapoliciespb.ListDataPoliciesRequest, opts ...gax.CallOption) *DataPolicyIterator {
873 it := &DataPolicyIterator{}
874 req = proto.Clone(req).(*datapoliciespb.ListDataPoliciesRequest)
875 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
876 it.InternalFetch = func(pageSize int, pageToken string) ([]*datapoliciespb.DataPolicy, string, error) {
877 resp := &datapoliciespb.ListDataPoliciesResponse{}
878 if pageToken != "" {
879 req.PageToken = pageToken
880 }
881 if pageSize > math.MaxInt32 {
882 req.PageSize = math.MaxInt32
883 } else if pageSize != 0 {
884 req.PageSize = int32(pageSize)
885 }
886 baseUrl, err := url.Parse(c.endpoint)
887 if err != nil {
888 return nil, "", err
889 }
890 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/dataPolicies", req.GetParent())
891
892 params := url.Values{}
893 if req.GetPageSize() != 0 {
894 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
895 }
896 if req.GetPageToken() != "" {
897 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
898 }
899
900 baseUrl.RawQuery = params.Encode()
901
902 // Build HTTP headers from client and context metadata.
903 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
904 headers := gax.BuildHeaders(ctx, hds...)
905 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
906 if settings.Path != "" {
907 baseUrl.Path = settings.Path
908 }
909 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
910 if err != nil {
911 return err
912 }
913 httpReq.Header = headers
914
915 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDataPolicies")
916 if err != nil {
917 return err
918 }
919 if err := unm.Unmarshal(buf, resp); err != nil {
920 return err
921 }
922
923 return nil
924 }, opts...)
925 if e != nil {
926 return nil, "", e
927 }
928 it.Response = resp
929 return resp.GetDataPolicies(), resp.GetNextPageToken(), nil
930 }
931
932 fetch := func(pageSize int, pageToken string) (string, error) {
933 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
934 if err != nil {
935 return "", err
936 }
937 it.items = append(it.items, items...)
938 return nextPageToken, nil
939 }
940
941 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
942 it.pageInfo.MaxSize = int(req.GetPageSize())
943 it.pageInfo.Token = req.GetPageToken()
944
945 return it
946 }
947
948 // GetIamPolicy gets the IAM policy for the specified data policy.
949 func (c *dataPolicyRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
950 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
951 jsonReq, err := m.Marshal(req)
952 if err != nil {
953 return nil, err
954 }
955
956 baseUrl, err := url.Parse(c.endpoint)
957 if err != nil {
958 return nil, err
959 }
960 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource())
961
962 // Build HTTP headers from client and context metadata.
963 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
964
965 hds = append(c.xGoogHeaders, hds...)
966 hds = append(hds, "Content-Type", "application/json")
967 headers := gax.BuildHeaders(ctx, hds...)
968 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
969 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
970 resp := &iampb.Policy{}
971 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
972 if settings.Path != "" {
973 baseUrl.Path = settings.Path
974 }
975 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
976 if err != nil {
977 return err
978 }
979 httpReq = httpReq.WithContext(ctx)
980 httpReq.Header = headers
981
982 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy")
983 if err != nil {
984 return err
985 }
986
987 if err := unm.Unmarshal(buf, resp); err != nil {
988 return err
989 }
990
991 return nil
992 }, opts...)
993 if e != nil {
994 return nil, e
995 }
996 return resp, nil
997 }
998
999 // SetIamPolicy sets the IAM policy for the specified data policy.
1000 func (c *dataPolicyRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1001 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1002 jsonReq, err := m.Marshal(req)
1003 if err != nil {
1004 return nil, err
1005 }
1006
1007 baseUrl, err := url.Parse(c.endpoint)
1008 if err != nil {
1009 return nil, err
1010 }
1011 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource())
1012
1013 // Build HTTP headers from client and context metadata.
1014 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1015
1016 hds = append(c.xGoogHeaders, hds...)
1017 hds = append(hds, "Content-Type", "application/json")
1018 headers := gax.BuildHeaders(ctx, hds...)
1019 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
1020 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1021 resp := &iampb.Policy{}
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, "SetIamPolicy")
1034 if err != nil {
1035 return err
1036 }
1037
1038 if err := unm.Unmarshal(buf, resp); err != nil {
1039 return err
1040 }
1041
1042 return nil
1043 }, opts...)
1044 if e != nil {
1045 return nil, e
1046 }
1047 return resp, nil
1048 }
1049
1050 // TestIamPermissions returns the caller’s permission on the specified data policy resource.
1051 func (c *dataPolicyRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
1052 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1053 jsonReq, err := m.Marshal(req)
1054 if err != nil {
1055 return nil, err
1056 }
1057
1058 baseUrl, err := url.Parse(c.endpoint)
1059 if err != nil {
1060 return nil, err
1061 }
1062 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource())
1063
1064 // Build HTTP headers from client and context metadata.
1065 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1066
1067 hds = append(c.xGoogHeaders, hds...)
1068 hds = append(hds, "Content-Type", "application/json")
1069 headers := gax.BuildHeaders(ctx, hds...)
1070 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
1071 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1072 resp := &iampb.TestIamPermissionsResponse{}
1073 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1074 if settings.Path != "" {
1075 baseUrl.Path = settings.Path
1076 }
1077 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1078 if err != nil {
1079 return err
1080 }
1081 httpReq = httpReq.WithContext(ctx)
1082 httpReq.Header = headers
1083
1084 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
1085 if err != nil {
1086 return err
1087 }
1088
1089 if err := unm.Unmarshal(buf, resp); err != nil {
1090 return err
1091 }
1092
1093 return nil
1094 }, opts...)
1095 if e != nil {
1096 return nil, e
1097 }
1098 return resp, nil
1099 }