1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package analyticshub
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "io"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 analyticshubpb "cloud.google.com/go/bigquery/analyticshub/apiv1/analyticshubpb"
30 iampb "cloud.google.com/go/iam/apiv1/iampb"
31 "cloud.google.com/go/longrunning"
32 lroauto "cloud.google.com/go/longrunning/autogen"
33 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
34 gax "github.com/googleapis/gax-go/v2"
35 "google.golang.org/api/googleapi"
36 "google.golang.org/api/iterator"
37 "google.golang.org/api/option"
38 "google.golang.org/api/option/internaloption"
39 gtransport "google.golang.org/api/transport/grpc"
40 httptransport "google.golang.org/api/transport/http"
41 "google.golang.org/grpc"
42 "google.golang.org/grpc/codes"
43 "google.golang.org/protobuf/encoding/protojson"
44 "google.golang.org/protobuf/proto"
45 )
46
47 var newClientHook clientHook
48
49
50 type CallOptions struct {
51 ListDataExchanges []gax.CallOption
52 ListOrgDataExchanges []gax.CallOption
53 GetDataExchange []gax.CallOption
54 CreateDataExchange []gax.CallOption
55 UpdateDataExchange []gax.CallOption
56 DeleteDataExchange []gax.CallOption
57 ListListings []gax.CallOption
58 GetListing []gax.CallOption
59 CreateListing []gax.CallOption
60 UpdateListing []gax.CallOption
61 DeleteListing []gax.CallOption
62 SubscribeListing []gax.CallOption
63 SubscribeDataExchange []gax.CallOption
64 RefreshSubscription []gax.CallOption
65 GetSubscription []gax.CallOption
66 ListSubscriptions []gax.CallOption
67 ListSharedResourceSubscriptions []gax.CallOption
68 RevokeSubscription []gax.CallOption
69 DeleteSubscription []gax.CallOption
70 GetIamPolicy []gax.CallOption
71 SetIamPolicy []gax.CallOption
72 TestIamPermissions []gax.CallOption
73 }
74
75 func defaultGRPCClientOptions() []option.ClientOption {
76 return []option.ClientOption{
77 internaloption.WithDefaultEndpoint("analyticshub.googleapis.com:443"),
78 internaloption.WithDefaultEndpointTemplate("analyticshub.UNIVERSE_DOMAIN:443"),
79 internaloption.WithDefaultMTLSEndpoint("analyticshub.mtls.googleapis.com:443"),
80 internaloption.WithDefaultUniverseDomain("googleapis.com"),
81 internaloption.WithDefaultAudience("https://analyticshub.googleapis.com/"),
82 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
83 internaloption.EnableJwtWithScope(),
84 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
85 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
86 }
87 }
88
89 func defaultCallOptions() *CallOptions {
90 return &CallOptions{
91 ListDataExchanges: []gax.CallOption{
92 gax.WithTimeout(60000 * time.Millisecond),
93 gax.WithRetry(func() gax.Retryer {
94 return gax.OnCodes([]codes.Code{
95 codes.DeadlineExceeded,
96 codes.Unavailable,
97 }, gax.Backoff{
98 Initial: 1000 * time.Millisecond,
99 Max: 60000 * time.Millisecond,
100 Multiplier: 1.30,
101 })
102 }),
103 },
104 ListOrgDataExchanges: []gax.CallOption{
105 gax.WithTimeout(60000 * time.Millisecond),
106 gax.WithRetry(func() gax.Retryer {
107 return gax.OnCodes([]codes.Code{
108 codes.DeadlineExceeded,
109 codes.Unavailable,
110 }, gax.Backoff{
111 Initial: 1000 * time.Millisecond,
112 Max: 60000 * time.Millisecond,
113 Multiplier: 1.30,
114 })
115 }),
116 },
117 GetDataExchange: []gax.CallOption{
118 gax.WithTimeout(60000 * time.Millisecond),
119 gax.WithRetry(func() gax.Retryer {
120 return gax.OnCodes([]codes.Code{
121 codes.DeadlineExceeded,
122 codes.Unavailable,
123 }, gax.Backoff{
124 Initial: 1000 * time.Millisecond,
125 Max: 60000 * time.Millisecond,
126 Multiplier: 1.30,
127 })
128 }),
129 },
130 CreateDataExchange: []gax.CallOption{
131 gax.WithTimeout(60000 * time.Millisecond),
132 gax.WithRetry(func() gax.Retryer {
133 return gax.OnCodes([]codes.Code{
134 codes.DeadlineExceeded,
135 codes.Unavailable,
136 }, gax.Backoff{
137 Initial: 1000 * time.Millisecond,
138 Max: 60000 * time.Millisecond,
139 Multiplier: 1.30,
140 })
141 }),
142 },
143 UpdateDataExchange: []gax.CallOption{
144 gax.WithTimeout(60000 * time.Millisecond),
145 gax.WithRetry(func() gax.Retryer {
146 return gax.OnCodes([]codes.Code{
147 codes.DeadlineExceeded,
148 codes.Unavailable,
149 }, gax.Backoff{
150 Initial: 1000 * time.Millisecond,
151 Max: 60000 * time.Millisecond,
152 Multiplier: 1.30,
153 })
154 }),
155 },
156 DeleteDataExchange: []gax.CallOption{
157 gax.WithTimeout(60000 * time.Millisecond),
158 gax.WithRetry(func() gax.Retryer {
159 return gax.OnCodes([]codes.Code{
160 codes.DeadlineExceeded,
161 codes.Unavailable,
162 }, gax.Backoff{
163 Initial: 1000 * time.Millisecond,
164 Max: 60000 * time.Millisecond,
165 Multiplier: 1.30,
166 })
167 }),
168 },
169 ListListings: []gax.CallOption{
170 gax.WithTimeout(60000 * time.Millisecond),
171 gax.WithRetry(func() gax.Retryer {
172 return gax.OnCodes([]codes.Code{
173 codes.DeadlineExceeded,
174 codes.Unavailable,
175 }, gax.Backoff{
176 Initial: 1000 * time.Millisecond,
177 Max: 60000 * time.Millisecond,
178 Multiplier: 1.30,
179 })
180 }),
181 },
182 GetListing: []gax.CallOption{
183 gax.WithTimeout(60000 * time.Millisecond),
184 gax.WithRetry(func() gax.Retryer {
185 return gax.OnCodes([]codes.Code{
186 codes.DeadlineExceeded,
187 codes.Unavailable,
188 }, gax.Backoff{
189 Initial: 1000 * time.Millisecond,
190 Max: 60000 * time.Millisecond,
191 Multiplier: 1.30,
192 })
193 }),
194 },
195 CreateListing: []gax.CallOption{
196 gax.WithTimeout(60000 * time.Millisecond),
197 gax.WithRetry(func() gax.Retryer {
198 return gax.OnCodes([]codes.Code{
199 codes.DeadlineExceeded,
200 codes.Unavailable,
201 }, gax.Backoff{
202 Initial: 1000 * time.Millisecond,
203 Max: 60000 * time.Millisecond,
204 Multiplier: 1.30,
205 })
206 }),
207 },
208 UpdateListing: []gax.CallOption{
209 gax.WithTimeout(60000 * time.Millisecond),
210 gax.WithRetry(func() gax.Retryer {
211 return gax.OnCodes([]codes.Code{
212 codes.DeadlineExceeded,
213 codes.Unavailable,
214 }, gax.Backoff{
215 Initial: 1000 * time.Millisecond,
216 Max: 60000 * time.Millisecond,
217 Multiplier: 1.30,
218 })
219 }),
220 },
221 DeleteListing: []gax.CallOption{
222 gax.WithTimeout(60000 * time.Millisecond),
223 gax.WithRetry(func() gax.Retryer {
224 return gax.OnCodes([]codes.Code{
225 codes.DeadlineExceeded,
226 codes.Unavailable,
227 }, gax.Backoff{
228 Initial: 1000 * time.Millisecond,
229 Max: 60000 * time.Millisecond,
230 Multiplier: 1.30,
231 })
232 }),
233 },
234 SubscribeListing: []gax.CallOption{
235 gax.WithTimeout(60000 * time.Millisecond),
236 gax.WithRetry(func() gax.Retryer {
237 return gax.OnCodes([]codes.Code{
238 codes.DeadlineExceeded,
239 codes.Unavailable,
240 }, gax.Backoff{
241 Initial: 1000 * time.Millisecond,
242 Max: 60000 * time.Millisecond,
243 Multiplier: 1.30,
244 })
245 }),
246 },
247 SubscribeDataExchange: []gax.CallOption{
248 gax.WithTimeout(60000 * time.Millisecond),
249 gax.WithRetry(func() gax.Retryer {
250 return gax.OnCodes([]codes.Code{
251 codes.DeadlineExceeded,
252 codes.Unavailable,
253 }, gax.Backoff{
254 Initial: 1000 * time.Millisecond,
255 Max: 60000 * time.Millisecond,
256 Multiplier: 1.30,
257 })
258 }),
259 },
260 RefreshSubscription: []gax.CallOption{
261 gax.WithTimeout(60000 * time.Millisecond),
262 gax.WithRetry(func() gax.Retryer {
263 return gax.OnCodes([]codes.Code{
264 codes.DeadlineExceeded,
265 codes.Unavailable,
266 }, gax.Backoff{
267 Initial: 1000 * time.Millisecond,
268 Max: 60000 * time.Millisecond,
269 Multiplier: 1.30,
270 })
271 }),
272 },
273 GetSubscription: []gax.CallOption{
274 gax.WithTimeout(60000 * time.Millisecond),
275 gax.WithRetry(func() gax.Retryer {
276 return gax.OnCodes([]codes.Code{
277 codes.DeadlineExceeded,
278 codes.Unavailable,
279 }, gax.Backoff{
280 Initial: 1000 * time.Millisecond,
281 Max: 60000 * time.Millisecond,
282 Multiplier: 1.30,
283 })
284 }),
285 },
286 ListSubscriptions: []gax.CallOption{
287 gax.WithTimeout(60000 * time.Millisecond),
288 gax.WithRetry(func() gax.Retryer {
289 return gax.OnCodes([]codes.Code{
290 codes.DeadlineExceeded,
291 codes.Unavailable,
292 }, gax.Backoff{
293 Initial: 1000 * time.Millisecond,
294 Max: 60000 * time.Millisecond,
295 Multiplier: 1.30,
296 })
297 }),
298 },
299 ListSharedResourceSubscriptions: []gax.CallOption{
300 gax.WithTimeout(60000 * time.Millisecond),
301 gax.WithRetry(func() gax.Retryer {
302 return gax.OnCodes([]codes.Code{
303 codes.DeadlineExceeded,
304 codes.Unavailable,
305 }, gax.Backoff{
306 Initial: 1000 * time.Millisecond,
307 Max: 60000 * time.Millisecond,
308 Multiplier: 1.30,
309 })
310 }),
311 },
312 RevokeSubscription: []gax.CallOption{
313 gax.WithTimeout(60000 * time.Millisecond),
314 gax.WithRetry(func() gax.Retryer {
315 return gax.OnCodes([]codes.Code{
316 codes.DeadlineExceeded,
317 codes.Unavailable,
318 }, gax.Backoff{
319 Initial: 1000 * time.Millisecond,
320 Max: 60000 * time.Millisecond,
321 Multiplier: 1.30,
322 })
323 }),
324 },
325 DeleteSubscription: []gax.CallOption{
326 gax.WithTimeout(60000 * time.Millisecond),
327 gax.WithRetry(func() gax.Retryer {
328 return gax.OnCodes([]codes.Code{
329 codes.DeadlineExceeded,
330 codes.Unavailable,
331 }, gax.Backoff{
332 Initial: 1000 * time.Millisecond,
333 Max: 60000 * time.Millisecond,
334 Multiplier: 1.30,
335 })
336 }),
337 },
338 GetIamPolicy: []gax.CallOption{
339 gax.WithTimeout(60000 * time.Millisecond),
340 gax.WithRetry(func() gax.Retryer {
341 return gax.OnCodes([]codes.Code{
342 codes.DeadlineExceeded,
343 codes.Unavailable,
344 }, gax.Backoff{
345 Initial: 1000 * time.Millisecond,
346 Max: 60000 * time.Millisecond,
347 Multiplier: 1.30,
348 })
349 }),
350 },
351 SetIamPolicy: []gax.CallOption{
352 gax.WithTimeout(60000 * time.Millisecond),
353 gax.WithRetry(func() gax.Retryer {
354 return gax.OnCodes([]codes.Code{
355 codes.DeadlineExceeded,
356 codes.Unavailable,
357 }, gax.Backoff{
358 Initial: 1000 * time.Millisecond,
359 Max: 60000 * time.Millisecond,
360 Multiplier: 1.30,
361 })
362 }),
363 },
364 TestIamPermissions: []gax.CallOption{
365 gax.WithTimeout(60000 * time.Millisecond),
366 gax.WithRetry(func() gax.Retryer {
367 return gax.OnCodes([]codes.Code{
368 codes.DeadlineExceeded,
369 codes.Unavailable,
370 }, gax.Backoff{
371 Initial: 1000 * time.Millisecond,
372 Max: 60000 * time.Millisecond,
373 Multiplier: 1.30,
374 })
375 }),
376 },
377 }
378 }
379
380 func defaultRESTCallOptions() *CallOptions {
381 return &CallOptions{
382 ListDataExchanges: []gax.CallOption{
383 gax.WithTimeout(60000 * time.Millisecond),
384 gax.WithRetry(func() gax.Retryer {
385 return gax.OnHTTPCodes(gax.Backoff{
386 Initial: 1000 * time.Millisecond,
387 Max: 60000 * time.Millisecond,
388 Multiplier: 1.30,
389 },
390 http.StatusGatewayTimeout,
391 http.StatusServiceUnavailable)
392 }),
393 },
394 ListOrgDataExchanges: []gax.CallOption{
395 gax.WithTimeout(60000 * time.Millisecond),
396 gax.WithRetry(func() gax.Retryer {
397 return gax.OnHTTPCodes(gax.Backoff{
398 Initial: 1000 * time.Millisecond,
399 Max: 60000 * time.Millisecond,
400 Multiplier: 1.30,
401 },
402 http.StatusGatewayTimeout,
403 http.StatusServiceUnavailable)
404 }),
405 },
406 GetDataExchange: []gax.CallOption{
407 gax.WithTimeout(60000 * time.Millisecond),
408 gax.WithRetry(func() gax.Retryer {
409 return gax.OnHTTPCodes(gax.Backoff{
410 Initial: 1000 * time.Millisecond,
411 Max: 60000 * time.Millisecond,
412 Multiplier: 1.30,
413 },
414 http.StatusGatewayTimeout,
415 http.StatusServiceUnavailable)
416 }),
417 },
418 CreateDataExchange: []gax.CallOption{
419 gax.WithTimeout(60000 * time.Millisecond),
420 gax.WithRetry(func() gax.Retryer {
421 return gax.OnHTTPCodes(gax.Backoff{
422 Initial: 1000 * time.Millisecond,
423 Max: 60000 * time.Millisecond,
424 Multiplier: 1.30,
425 },
426 http.StatusGatewayTimeout,
427 http.StatusServiceUnavailable)
428 }),
429 },
430 UpdateDataExchange: []gax.CallOption{
431 gax.WithTimeout(60000 * time.Millisecond),
432 gax.WithRetry(func() gax.Retryer {
433 return gax.OnHTTPCodes(gax.Backoff{
434 Initial: 1000 * time.Millisecond,
435 Max: 60000 * time.Millisecond,
436 Multiplier: 1.30,
437 },
438 http.StatusGatewayTimeout,
439 http.StatusServiceUnavailable)
440 }),
441 },
442 DeleteDataExchange: []gax.CallOption{
443 gax.WithTimeout(60000 * time.Millisecond),
444 gax.WithRetry(func() gax.Retryer {
445 return gax.OnHTTPCodes(gax.Backoff{
446 Initial: 1000 * time.Millisecond,
447 Max: 60000 * time.Millisecond,
448 Multiplier: 1.30,
449 },
450 http.StatusGatewayTimeout,
451 http.StatusServiceUnavailable)
452 }),
453 },
454 ListListings: []gax.CallOption{
455 gax.WithTimeout(60000 * time.Millisecond),
456 gax.WithRetry(func() gax.Retryer {
457 return gax.OnHTTPCodes(gax.Backoff{
458 Initial: 1000 * time.Millisecond,
459 Max: 60000 * time.Millisecond,
460 Multiplier: 1.30,
461 },
462 http.StatusGatewayTimeout,
463 http.StatusServiceUnavailable)
464 }),
465 },
466 GetListing: []gax.CallOption{
467 gax.WithTimeout(60000 * time.Millisecond),
468 gax.WithRetry(func() gax.Retryer {
469 return gax.OnHTTPCodes(gax.Backoff{
470 Initial: 1000 * time.Millisecond,
471 Max: 60000 * time.Millisecond,
472 Multiplier: 1.30,
473 },
474 http.StatusGatewayTimeout,
475 http.StatusServiceUnavailable)
476 }),
477 },
478 CreateListing: []gax.CallOption{
479 gax.WithTimeout(60000 * time.Millisecond),
480 gax.WithRetry(func() gax.Retryer {
481 return gax.OnHTTPCodes(gax.Backoff{
482 Initial: 1000 * time.Millisecond,
483 Max: 60000 * time.Millisecond,
484 Multiplier: 1.30,
485 },
486 http.StatusGatewayTimeout,
487 http.StatusServiceUnavailable)
488 }),
489 },
490 UpdateListing: []gax.CallOption{
491 gax.WithTimeout(60000 * time.Millisecond),
492 gax.WithRetry(func() gax.Retryer {
493 return gax.OnHTTPCodes(gax.Backoff{
494 Initial: 1000 * time.Millisecond,
495 Max: 60000 * time.Millisecond,
496 Multiplier: 1.30,
497 },
498 http.StatusGatewayTimeout,
499 http.StatusServiceUnavailable)
500 }),
501 },
502 DeleteListing: []gax.CallOption{
503 gax.WithTimeout(60000 * time.Millisecond),
504 gax.WithRetry(func() gax.Retryer {
505 return gax.OnHTTPCodes(gax.Backoff{
506 Initial: 1000 * time.Millisecond,
507 Max: 60000 * time.Millisecond,
508 Multiplier: 1.30,
509 },
510 http.StatusGatewayTimeout,
511 http.StatusServiceUnavailable)
512 }),
513 },
514 SubscribeListing: []gax.CallOption{
515 gax.WithTimeout(60000 * time.Millisecond),
516 gax.WithRetry(func() gax.Retryer {
517 return gax.OnHTTPCodes(gax.Backoff{
518 Initial: 1000 * time.Millisecond,
519 Max: 60000 * time.Millisecond,
520 Multiplier: 1.30,
521 },
522 http.StatusGatewayTimeout,
523 http.StatusServiceUnavailable)
524 }),
525 },
526 SubscribeDataExchange: []gax.CallOption{
527 gax.WithTimeout(60000 * time.Millisecond),
528 gax.WithRetry(func() gax.Retryer {
529 return gax.OnHTTPCodes(gax.Backoff{
530 Initial: 1000 * time.Millisecond,
531 Max: 60000 * time.Millisecond,
532 Multiplier: 1.30,
533 },
534 http.StatusGatewayTimeout,
535 http.StatusServiceUnavailable)
536 }),
537 },
538 RefreshSubscription: []gax.CallOption{
539 gax.WithTimeout(60000 * time.Millisecond),
540 gax.WithRetry(func() gax.Retryer {
541 return gax.OnHTTPCodes(gax.Backoff{
542 Initial: 1000 * time.Millisecond,
543 Max: 60000 * time.Millisecond,
544 Multiplier: 1.30,
545 },
546 http.StatusGatewayTimeout,
547 http.StatusServiceUnavailable)
548 }),
549 },
550 GetSubscription: []gax.CallOption{
551 gax.WithTimeout(60000 * time.Millisecond),
552 gax.WithRetry(func() gax.Retryer {
553 return gax.OnHTTPCodes(gax.Backoff{
554 Initial: 1000 * time.Millisecond,
555 Max: 60000 * time.Millisecond,
556 Multiplier: 1.30,
557 },
558 http.StatusGatewayTimeout,
559 http.StatusServiceUnavailable)
560 }),
561 },
562 ListSubscriptions: []gax.CallOption{
563 gax.WithTimeout(60000 * time.Millisecond),
564 gax.WithRetry(func() gax.Retryer {
565 return gax.OnHTTPCodes(gax.Backoff{
566 Initial: 1000 * time.Millisecond,
567 Max: 60000 * time.Millisecond,
568 Multiplier: 1.30,
569 },
570 http.StatusGatewayTimeout,
571 http.StatusServiceUnavailable)
572 }),
573 },
574 ListSharedResourceSubscriptions: []gax.CallOption{
575 gax.WithTimeout(60000 * time.Millisecond),
576 gax.WithRetry(func() gax.Retryer {
577 return gax.OnHTTPCodes(gax.Backoff{
578 Initial: 1000 * time.Millisecond,
579 Max: 60000 * time.Millisecond,
580 Multiplier: 1.30,
581 },
582 http.StatusGatewayTimeout,
583 http.StatusServiceUnavailable)
584 }),
585 },
586 RevokeSubscription: []gax.CallOption{
587 gax.WithTimeout(60000 * time.Millisecond),
588 gax.WithRetry(func() gax.Retryer {
589 return gax.OnHTTPCodes(gax.Backoff{
590 Initial: 1000 * time.Millisecond,
591 Max: 60000 * time.Millisecond,
592 Multiplier: 1.30,
593 },
594 http.StatusGatewayTimeout,
595 http.StatusServiceUnavailable)
596 }),
597 },
598 DeleteSubscription: []gax.CallOption{
599 gax.WithTimeout(60000 * time.Millisecond),
600 gax.WithRetry(func() gax.Retryer {
601 return gax.OnHTTPCodes(gax.Backoff{
602 Initial: 1000 * time.Millisecond,
603 Max: 60000 * time.Millisecond,
604 Multiplier: 1.30,
605 },
606 http.StatusGatewayTimeout,
607 http.StatusServiceUnavailable)
608 }),
609 },
610 GetIamPolicy: []gax.CallOption{
611 gax.WithTimeout(60000 * time.Millisecond),
612 gax.WithRetry(func() gax.Retryer {
613 return gax.OnHTTPCodes(gax.Backoff{
614 Initial: 1000 * time.Millisecond,
615 Max: 60000 * time.Millisecond,
616 Multiplier: 1.30,
617 },
618 http.StatusGatewayTimeout,
619 http.StatusServiceUnavailable)
620 }),
621 },
622 SetIamPolicy: []gax.CallOption{
623 gax.WithTimeout(60000 * time.Millisecond),
624 gax.WithRetry(func() gax.Retryer {
625 return gax.OnHTTPCodes(gax.Backoff{
626 Initial: 1000 * time.Millisecond,
627 Max: 60000 * time.Millisecond,
628 Multiplier: 1.30,
629 },
630 http.StatusGatewayTimeout,
631 http.StatusServiceUnavailable)
632 }),
633 },
634 TestIamPermissions: []gax.CallOption{
635 gax.WithTimeout(60000 * time.Millisecond),
636 gax.WithRetry(func() gax.Retryer {
637 return gax.OnHTTPCodes(gax.Backoff{
638 Initial: 1000 * time.Millisecond,
639 Max: 60000 * time.Millisecond,
640 Multiplier: 1.30,
641 },
642 http.StatusGatewayTimeout,
643 http.StatusServiceUnavailable)
644 }),
645 },
646 }
647 }
648
649
650 type internalClient interface {
651 Close() error
652 setGoogleClientInfo(...string)
653 Connection() *grpc.ClientConn
654 ListDataExchanges(context.Context, *analyticshubpb.ListDataExchangesRequest, ...gax.CallOption) *DataExchangeIterator
655 ListOrgDataExchanges(context.Context, *analyticshubpb.ListOrgDataExchangesRequest, ...gax.CallOption) *DataExchangeIterator
656 GetDataExchange(context.Context, *analyticshubpb.GetDataExchangeRequest, ...gax.CallOption) (*analyticshubpb.DataExchange, error)
657 CreateDataExchange(context.Context, *analyticshubpb.CreateDataExchangeRequest, ...gax.CallOption) (*analyticshubpb.DataExchange, error)
658 UpdateDataExchange(context.Context, *analyticshubpb.UpdateDataExchangeRequest, ...gax.CallOption) (*analyticshubpb.DataExchange, error)
659 DeleteDataExchange(context.Context, *analyticshubpb.DeleteDataExchangeRequest, ...gax.CallOption) error
660 ListListings(context.Context, *analyticshubpb.ListListingsRequest, ...gax.CallOption) *ListingIterator
661 GetListing(context.Context, *analyticshubpb.GetListingRequest, ...gax.CallOption) (*analyticshubpb.Listing, error)
662 CreateListing(context.Context, *analyticshubpb.CreateListingRequest, ...gax.CallOption) (*analyticshubpb.Listing, error)
663 UpdateListing(context.Context, *analyticshubpb.UpdateListingRequest, ...gax.CallOption) (*analyticshubpb.Listing, error)
664 DeleteListing(context.Context, *analyticshubpb.DeleteListingRequest, ...gax.CallOption) error
665 SubscribeListing(context.Context, *analyticshubpb.SubscribeListingRequest, ...gax.CallOption) (*analyticshubpb.SubscribeListingResponse, error)
666 SubscribeDataExchange(context.Context, *analyticshubpb.SubscribeDataExchangeRequest, ...gax.CallOption) (*SubscribeDataExchangeOperation, error)
667 SubscribeDataExchangeOperation(name string) *SubscribeDataExchangeOperation
668 RefreshSubscription(context.Context, *analyticshubpb.RefreshSubscriptionRequest, ...gax.CallOption) (*RefreshSubscriptionOperation, error)
669 RefreshSubscriptionOperation(name string) *RefreshSubscriptionOperation
670 GetSubscription(context.Context, *analyticshubpb.GetSubscriptionRequest, ...gax.CallOption) (*analyticshubpb.Subscription, error)
671 ListSubscriptions(context.Context, *analyticshubpb.ListSubscriptionsRequest, ...gax.CallOption) *SubscriptionIterator
672 ListSharedResourceSubscriptions(context.Context, *analyticshubpb.ListSharedResourceSubscriptionsRequest, ...gax.CallOption) *SubscriptionIterator
673 RevokeSubscription(context.Context, *analyticshubpb.RevokeSubscriptionRequest, ...gax.CallOption) (*analyticshubpb.RevokeSubscriptionResponse, error)
674 DeleteSubscription(context.Context, *analyticshubpb.DeleteSubscriptionRequest, ...gax.CallOption) (*DeleteSubscriptionOperation, error)
675 DeleteSubscriptionOperation(name string) *DeleteSubscriptionOperation
676 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
677 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
678 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
679 }
680
681
682
683
684
685
686
687
688
689
690 type Client struct {
691
692 internalClient internalClient
693
694
695 CallOptions *CallOptions
696
697
698
699
700 LROClient *lroauto.OperationsClient
701 }
702
703
704
705
706
707 func (c *Client) Close() error {
708 return c.internalClient.Close()
709 }
710
711
712
713
714 func (c *Client) setGoogleClientInfo(keyval ...string) {
715 c.internalClient.setGoogleClientInfo(keyval...)
716 }
717
718
719
720
721
722 func (c *Client) Connection() *grpc.ClientConn {
723 return c.internalClient.Connection()
724 }
725
726
727 func (c *Client) ListDataExchanges(ctx context.Context, req *analyticshubpb.ListDataExchangesRequest, opts ...gax.CallOption) *DataExchangeIterator {
728 return c.internalClient.ListDataExchanges(ctx, req, opts...)
729 }
730
731
732
733 func (c *Client) ListOrgDataExchanges(ctx context.Context, req *analyticshubpb.ListOrgDataExchangesRequest, opts ...gax.CallOption) *DataExchangeIterator {
734 return c.internalClient.ListOrgDataExchanges(ctx, req, opts...)
735 }
736
737
738 func (c *Client) GetDataExchange(ctx context.Context, req *analyticshubpb.GetDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
739 return c.internalClient.GetDataExchange(ctx, req, opts...)
740 }
741
742
743 func (c *Client) CreateDataExchange(ctx context.Context, req *analyticshubpb.CreateDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
744 return c.internalClient.CreateDataExchange(ctx, req, opts...)
745 }
746
747
748 func (c *Client) UpdateDataExchange(ctx context.Context, req *analyticshubpb.UpdateDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
749 return c.internalClient.UpdateDataExchange(ctx, req, opts...)
750 }
751
752
753 func (c *Client) DeleteDataExchange(ctx context.Context, req *analyticshubpb.DeleteDataExchangeRequest, opts ...gax.CallOption) error {
754 return c.internalClient.DeleteDataExchange(ctx, req, opts...)
755 }
756
757
758 func (c *Client) ListListings(ctx context.Context, req *analyticshubpb.ListListingsRequest, opts ...gax.CallOption) *ListingIterator {
759 return c.internalClient.ListListings(ctx, req, opts...)
760 }
761
762
763 func (c *Client) GetListing(ctx context.Context, req *analyticshubpb.GetListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
764 return c.internalClient.GetListing(ctx, req, opts...)
765 }
766
767
768 func (c *Client) CreateListing(ctx context.Context, req *analyticshubpb.CreateListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
769 return c.internalClient.CreateListing(ctx, req, opts...)
770 }
771
772
773 func (c *Client) UpdateListing(ctx context.Context, req *analyticshubpb.UpdateListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
774 return c.internalClient.UpdateListing(ctx, req, opts...)
775 }
776
777
778 func (c *Client) DeleteListing(ctx context.Context, req *analyticshubpb.DeleteListingRequest, opts ...gax.CallOption) error {
779 return c.internalClient.DeleteListing(ctx, req, opts...)
780 }
781
782
783
784
785
786
787
788 func (c *Client) SubscribeListing(ctx context.Context, req *analyticshubpb.SubscribeListingRequest, opts ...gax.CallOption) (*analyticshubpb.SubscribeListingResponse, error) {
789 return c.internalClient.SubscribeListing(ctx, req, opts...)
790 }
791
792
793
794 func (c *Client) SubscribeDataExchange(ctx context.Context, req *analyticshubpb.SubscribeDataExchangeRequest, opts ...gax.CallOption) (*SubscribeDataExchangeOperation, error) {
795 return c.internalClient.SubscribeDataExchange(ctx, req, opts...)
796 }
797
798
799
800 func (c *Client) SubscribeDataExchangeOperation(name string) *SubscribeDataExchangeOperation {
801 return c.internalClient.SubscribeDataExchangeOperation(name)
802 }
803
804
805
806
807 func (c *Client) RefreshSubscription(ctx context.Context, req *analyticshubpb.RefreshSubscriptionRequest, opts ...gax.CallOption) (*RefreshSubscriptionOperation, error) {
808 return c.internalClient.RefreshSubscription(ctx, req, opts...)
809 }
810
811
812
813 func (c *Client) RefreshSubscriptionOperation(name string) *RefreshSubscriptionOperation {
814 return c.internalClient.RefreshSubscriptionOperation(name)
815 }
816
817
818 func (c *Client) GetSubscription(ctx context.Context, req *analyticshubpb.GetSubscriptionRequest, opts ...gax.CallOption) (*analyticshubpb.Subscription, error) {
819 return c.internalClient.GetSubscription(ctx, req, opts...)
820 }
821
822
823 func (c *Client) ListSubscriptions(ctx context.Context, req *analyticshubpb.ListSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator {
824 return c.internalClient.ListSubscriptions(ctx, req, opts...)
825 }
826
827
828 func (c *Client) ListSharedResourceSubscriptions(ctx context.Context, req *analyticshubpb.ListSharedResourceSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator {
829 return c.internalClient.ListSharedResourceSubscriptions(ctx, req, opts...)
830 }
831
832
833 func (c *Client) RevokeSubscription(ctx context.Context, req *analyticshubpb.RevokeSubscriptionRequest, opts ...gax.CallOption) (*analyticshubpb.RevokeSubscriptionResponse, error) {
834 return c.internalClient.RevokeSubscription(ctx, req, opts...)
835 }
836
837
838 func (c *Client) DeleteSubscription(ctx context.Context, req *analyticshubpb.DeleteSubscriptionRequest, opts ...gax.CallOption) (*DeleteSubscriptionOperation, error) {
839 return c.internalClient.DeleteSubscription(ctx, req, opts...)
840 }
841
842
843
844 func (c *Client) DeleteSubscriptionOperation(name string) *DeleteSubscriptionOperation {
845 return c.internalClient.DeleteSubscriptionOperation(name)
846 }
847
848
849 func (c *Client) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
850 return c.internalClient.GetIamPolicy(ctx, req, opts...)
851 }
852
853
854 func (c *Client) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
855 return c.internalClient.SetIamPolicy(ctx, req, opts...)
856 }
857
858
859 func (c *Client) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
860 return c.internalClient.TestIamPermissions(ctx, req, opts...)
861 }
862
863
864
865
866 type gRPCClient struct {
867
868 connPool gtransport.ConnPool
869
870
871 CallOptions **CallOptions
872
873
874 client analyticshubpb.AnalyticsHubServiceClient
875
876
877
878
879 LROClient **lroauto.OperationsClient
880
881
882 xGoogHeaders []string
883 }
884
885
886
887
888
889
890
891
892
893
894 func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
895 clientOpts := defaultGRPCClientOptions()
896 if newClientHook != nil {
897 hookOpts, err := newClientHook(ctx, clientHookParams{})
898 if err != nil {
899 return nil, err
900 }
901 clientOpts = append(clientOpts, hookOpts...)
902 }
903
904 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
905 if err != nil {
906 return nil, err
907 }
908 client := Client{CallOptions: defaultCallOptions()}
909
910 c := &gRPCClient{
911 connPool: connPool,
912 client: analyticshubpb.NewAnalyticsHubServiceClient(connPool),
913 CallOptions: &client.CallOptions,
914 }
915 c.setGoogleClientInfo()
916
917 client.internalClient = c
918
919 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
920 if err != nil {
921
922
923
924
925
926
927 return nil, err
928 }
929 c.LROClient = &client.LROClient
930 return &client, nil
931 }
932
933
934
935
936
937 func (c *gRPCClient) Connection() *grpc.ClientConn {
938 return c.connPool.Conn()
939 }
940
941
942
943
944 func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
945 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
946 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
947 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
948 }
949
950
951
952 func (c *gRPCClient) Close() error {
953 return c.connPool.Close()
954 }
955
956
957 type restClient struct {
958
959 endpoint string
960
961
962 httpClient *http.Client
963
964
965
966
967 LROClient **lroauto.OperationsClient
968
969
970 xGoogHeaders []string
971
972
973 CallOptions **CallOptions
974 }
975
976
977
978
979
980
981
982
983
984 func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
985 clientOpts := append(defaultRESTClientOptions(), opts...)
986 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
987 if err != nil {
988 return nil, err
989 }
990
991 callOpts := defaultRESTCallOptions()
992 c := &restClient{
993 endpoint: endpoint,
994 httpClient: httpClient,
995 CallOptions: &callOpts,
996 }
997 c.setGoogleClientInfo()
998
999 lroOpts := []option.ClientOption{
1000 option.WithHTTPClient(httpClient),
1001 option.WithEndpoint(endpoint),
1002 }
1003 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
1004 if err != nil {
1005 return nil, err
1006 }
1007 c.LROClient = &opClient
1008
1009 return &Client{internalClient: c, CallOptions: callOpts}, nil
1010 }
1011
1012 func defaultRESTClientOptions() []option.ClientOption {
1013 return []option.ClientOption{
1014 internaloption.WithDefaultEndpoint("https://analyticshub.googleapis.com"),
1015 internaloption.WithDefaultEndpointTemplate("https://analyticshub.UNIVERSE_DOMAIN"),
1016 internaloption.WithDefaultMTLSEndpoint("https://analyticshub.mtls.googleapis.com"),
1017 internaloption.WithDefaultUniverseDomain("googleapis.com"),
1018 internaloption.WithDefaultAudience("https://analyticshub.googleapis.com/"),
1019 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
1020 }
1021 }
1022
1023
1024
1025
1026 func (c *restClient) setGoogleClientInfo(keyval ...string) {
1027 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
1028 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
1029 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
1030 }
1031
1032
1033
1034 func (c *restClient) Close() error {
1035
1036 c.httpClient = nil
1037 return nil
1038 }
1039
1040
1041
1042
1043 func (c *restClient) Connection() *grpc.ClientConn {
1044 return nil
1045 }
1046 func (c *gRPCClient) ListDataExchanges(ctx context.Context, req *analyticshubpb.ListDataExchangesRequest, opts ...gax.CallOption) *DataExchangeIterator {
1047 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1048
1049 hds = append(c.xGoogHeaders, hds...)
1050 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1051 opts = append((*c.CallOptions).ListDataExchanges[0:len((*c.CallOptions).ListDataExchanges):len((*c.CallOptions).ListDataExchanges)], opts...)
1052 it := &DataExchangeIterator{}
1053 req = proto.Clone(req).(*analyticshubpb.ListDataExchangesRequest)
1054 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.DataExchange, string, error) {
1055 resp := &analyticshubpb.ListDataExchangesResponse{}
1056 if pageToken != "" {
1057 req.PageToken = pageToken
1058 }
1059 if pageSize > math.MaxInt32 {
1060 req.PageSize = math.MaxInt32
1061 } else if pageSize != 0 {
1062 req.PageSize = int32(pageSize)
1063 }
1064 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1065 var err error
1066 resp, err = c.client.ListDataExchanges(ctx, req, settings.GRPC...)
1067 return err
1068 }, opts...)
1069 if err != nil {
1070 return nil, "", err
1071 }
1072
1073 it.Response = resp
1074 return resp.GetDataExchanges(), resp.GetNextPageToken(), nil
1075 }
1076 fetch := func(pageSize int, pageToken string) (string, error) {
1077 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1078 if err != nil {
1079 return "", err
1080 }
1081 it.items = append(it.items, items...)
1082 return nextPageToken, nil
1083 }
1084
1085 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1086 it.pageInfo.MaxSize = int(req.GetPageSize())
1087 it.pageInfo.Token = req.GetPageToken()
1088
1089 return it
1090 }
1091
1092 func (c *gRPCClient) ListOrgDataExchanges(ctx context.Context, req *analyticshubpb.ListOrgDataExchangesRequest, opts ...gax.CallOption) *DataExchangeIterator {
1093 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "organization", url.QueryEscape(req.GetOrganization()))}
1094
1095 hds = append(c.xGoogHeaders, hds...)
1096 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1097 opts = append((*c.CallOptions).ListOrgDataExchanges[0:len((*c.CallOptions).ListOrgDataExchanges):len((*c.CallOptions).ListOrgDataExchanges)], opts...)
1098 it := &DataExchangeIterator{}
1099 req = proto.Clone(req).(*analyticshubpb.ListOrgDataExchangesRequest)
1100 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.DataExchange, string, error) {
1101 resp := &analyticshubpb.ListOrgDataExchangesResponse{}
1102 if pageToken != "" {
1103 req.PageToken = pageToken
1104 }
1105 if pageSize > math.MaxInt32 {
1106 req.PageSize = math.MaxInt32
1107 } else if pageSize != 0 {
1108 req.PageSize = int32(pageSize)
1109 }
1110 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1111 var err error
1112 resp, err = c.client.ListOrgDataExchanges(ctx, req, settings.GRPC...)
1113 return err
1114 }, opts...)
1115 if err != nil {
1116 return nil, "", err
1117 }
1118
1119 it.Response = resp
1120 return resp.GetDataExchanges(), resp.GetNextPageToken(), nil
1121 }
1122 fetch := func(pageSize int, pageToken string) (string, error) {
1123 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1124 if err != nil {
1125 return "", err
1126 }
1127 it.items = append(it.items, items...)
1128 return nextPageToken, nil
1129 }
1130
1131 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1132 it.pageInfo.MaxSize = int(req.GetPageSize())
1133 it.pageInfo.Token = req.GetPageToken()
1134
1135 return it
1136 }
1137
1138 func (c *gRPCClient) GetDataExchange(ctx context.Context, req *analyticshubpb.GetDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
1139 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1140
1141 hds = append(c.xGoogHeaders, hds...)
1142 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1143 opts = append((*c.CallOptions).GetDataExchange[0:len((*c.CallOptions).GetDataExchange):len((*c.CallOptions).GetDataExchange)], opts...)
1144 var resp *analyticshubpb.DataExchange
1145 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1146 var err error
1147 resp, err = c.client.GetDataExchange(ctx, req, settings.GRPC...)
1148 return err
1149 }, opts...)
1150 if err != nil {
1151 return nil, err
1152 }
1153 return resp, nil
1154 }
1155
1156 func (c *gRPCClient) CreateDataExchange(ctx context.Context, req *analyticshubpb.CreateDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
1157 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1158
1159 hds = append(c.xGoogHeaders, hds...)
1160 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1161 opts = append((*c.CallOptions).CreateDataExchange[0:len((*c.CallOptions).CreateDataExchange):len((*c.CallOptions).CreateDataExchange)], opts...)
1162 var resp *analyticshubpb.DataExchange
1163 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1164 var err error
1165 resp, err = c.client.CreateDataExchange(ctx, req, settings.GRPC...)
1166 return err
1167 }, opts...)
1168 if err != nil {
1169 return nil, err
1170 }
1171 return resp, nil
1172 }
1173
1174 func (c *gRPCClient) UpdateDataExchange(ctx context.Context, req *analyticshubpb.UpdateDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
1175 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "data_exchange.name", url.QueryEscape(req.GetDataExchange().GetName()))}
1176
1177 hds = append(c.xGoogHeaders, hds...)
1178 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1179 opts = append((*c.CallOptions).UpdateDataExchange[0:len((*c.CallOptions).UpdateDataExchange):len((*c.CallOptions).UpdateDataExchange)], opts...)
1180 var resp *analyticshubpb.DataExchange
1181 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1182 var err error
1183 resp, err = c.client.UpdateDataExchange(ctx, req, settings.GRPC...)
1184 return err
1185 }, opts...)
1186 if err != nil {
1187 return nil, err
1188 }
1189 return resp, nil
1190 }
1191
1192 func (c *gRPCClient) DeleteDataExchange(ctx context.Context, req *analyticshubpb.DeleteDataExchangeRequest, opts ...gax.CallOption) error {
1193 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1194
1195 hds = append(c.xGoogHeaders, hds...)
1196 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1197 opts = append((*c.CallOptions).DeleteDataExchange[0:len((*c.CallOptions).DeleteDataExchange):len((*c.CallOptions).DeleteDataExchange)], opts...)
1198 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1199 var err error
1200 _, err = c.client.DeleteDataExchange(ctx, req, settings.GRPC...)
1201 return err
1202 }, opts...)
1203 return err
1204 }
1205
1206 func (c *gRPCClient) ListListings(ctx context.Context, req *analyticshubpb.ListListingsRequest, opts ...gax.CallOption) *ListingIterator {
1207 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1208
1209 hds = append(c.xGoogHeaders, hds...)
1210 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1211 opts = append((*c.CallOptions).ListListings[0:len((*c.CallOptions).ListListings):len((*c.CallOptions).ListListings)], opts...)
1212 it := &ListingIterator{}
1213 req = proto.Clone(req).(*analyticshubpb.ListListingsRequest)
1214 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.Listing, string, error) {
1215 resp := &analyticshubpb.ListListingsResponse{}
1216 if pageToken != "" {
1217 req.PageToken = pageToken
1218 }
1219 if pageSize > math.MaxInt32 {
1220 req.PageSize = math.MaxInt32
1221 } else if pageSize != 0 {
1222 req.PageSize = int32(pageSize)
1223 }
1224 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1225 var err error
1226 resp, err = c.client.ListListings(ctx, req, settings.GRPC...)
1227 return err
1228 }, opts...)
1229 if err != nil {
1230 return nil, "", err
1231 }
1232
1233 it.Response = resp
1234 return resp.GetListings(), resp.GetNextPageToken(), nil
1235 }
1236 fetch := func(pageSize int, pageToken string) (string, error) {
1237 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1238 if err != nil {
1239 return "", err
1240 }
1241 it.items = append(it.items, items...)
1242 return nextPageToken, nil
1243 }
1244
1245 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1246 it.pageInfo.MaxSize = int(req.GetPageSize())
1247 it.pageInfo.Token = req.GetPageToken()
1248
1249 return it
1250 }
1251
1252 func (c *gRPCClient) GetListing(ctx context.Context, req *analyticshubpb.GetListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
1253 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1254
1255 hds = append(c.xGoogHeaders, hds...)
1256 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1257 opts = append((*c.CallOptions).GetListing[0:len((*c.CallOptions).GetListing):len((*c.CallOptions).GetListing)], opts...)
1258 var resp *analyticshubpb.Listing
1259 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1260 var err error
1261 resp, err = c.client.GetListing(ctx, req, settings.GRPC...)
1262 return err
1263 }, opts...)
1264 if err != nil {
1265 return nil, err
1266 }
1267 return resp, nil
1268 }
1269
1270 func (c *gRPCClient) CreateListing(ctx context.Context, req *analyticshubpb.CreateListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
1271 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1272
1273 hds = append(c.xGoogHeaders, hds...)
1274 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1275 opts = append((*c.CallOptions).CreateListing[0:len((*c.CallOptions).CreateListing):len((*c.CallOptions).CreateListing)], opts...)
1276 var resp *analyticshubpb.Listing
1277 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1278 var err error
1279 resp, err = c.client.CreateListing(ctx, req, settings.GRPC...)
1280 return err
1281 }, opts...)
1282 if err != nil {
1283 return nil, err
1284 }
1285 return resp, nil
1286 }
1287
1288 func (c *gRPCClient) UpdateListing(ctx context.Context, req *analyticshubpb.UpdateListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
1289 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "listing.name", url.QueryEscape(req.GetListing().GetName()))}
1290
1291 hds = append(c.xGoogHeaders, hds...)
1292 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1293 opts = append((*c.CallOptions).UpdateListing[0:len((*c.CallOptions).UpdateListing):len((*c.CallOptions).UpdateListing)], opts...)
1294 var resp *analyticshubpb.Listing
1295 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1296 var err error
1297 resp, err = c.client.UpdateListing(ctx, req, settings.GRPC...)
1298 return err
1299 }, opts...)
1300 if err != nil {
1301 return nil, err
1302 }
1303 return resp, nil
1304 }
1305
1306 func (c *gRPCClient) DeleteListing(ctx context.Context, req *analyticshubpb.DeleteListingRequest, opts ...gax.CallOption) error {
1307 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1308
1309 hds = append(c.xGoogHeaders, hds...)
1310 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1311 opts = append((*c.CallOptions).DeleteListing[0:len((*c.CallOptions).DeleteListing):len((*c.CallOptions).DeleteListing)], opts...)
1312 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1313 var err error
1314 _, err = c.client.DeleteListing(ctx, req, settings.GRPC...)
1315 return err
1316 }, opts...)
1317 return err
1318 }
1319
1320 func (c *gRPCClient) SubscribeListing(ctx context.Context, req *analyticshubpb.SubscribeListingRequest, opts ...gax.CallOption) (*analyticshubpb.SubscribeListingResponse, error) {
1321 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1322
1323 hds = append(c.xGoogHeaders, hds...)
1324 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1325 opts = append((*c.CallOptions).SubscribeListing[0:len((*c.CallOptions).SubscribeListing):len((*c.CallOptions).SubscribeListing)], opts...)
1326 var resp *analyticshubpb.SubscribeListingResponse
1327 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1328 var err error
1329 resp, err = c.client.SubscribeListing(ctx, req, settings.GRPC...)
1330 return err
1331 }, opts...)
1332 if err != nil {
1333 return nil, err
1334 }
1335 return resp, nil
1336 }
1337
1338 func (c *gRPCClient) SubscribeDataExchange(ctx context.Context, req *analyticshubpb.SubscribeDataExchangeRequest, opts ...gax.CallOption) (*SubscribeDataExchangeOperation, error) {
1339 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1340
1341 hds = append(c.xGoogHeaders, hds...)
1342 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1343 opts = append((*c.CallOptions).SubscribeDataExchange[0:len((*c.CallOptions).SubscribeDataExchange):len((*c.CallOptions).SubscribeDataExchange)], opts...)
1344 var resp *longrunningpb.Operation
1345 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1346 var err error
1347 resp, err = c.client.SubscribeDataExchange(ctx, req, settings.GRPC...)
1348 return err
1349 }, opts...)
1350 if err != nil {
1351 return nil, err
1352 }
1353 return &SubscribeDataExchangeOperation{
1354 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1355 }, nil
1356 }
1357
1358 func (c *gRPCClient) RefreshSubscription(ctx context.Context, req *analyticshubpb.RefreshSubscriptionRequest, opts ...gax.CallOption) (*RefreshSubscriptionOperation, error) {
1359 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1360
1361 hds = append(c.xGoogHeaders, hds...)
1362 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1363 opts = append((*c.CallOptions).RefreshSubscription[0:len((*c.CallOptions).RefreshSubscription):len((*c.CallOptions).RefreshSubscription)], opts...)
1364 var resp *longrunningpb.Operation
1365 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1366 var err error
1367 resp, err = c.client.RefreshSubscription(ctx, req, settings.GRPC...)
1368 return err
1369 }, opts...)
1370 if err != nil {
1371 return nil, err
1372 }
1373 return &RefreshSubscriptionOperation{
1374 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1375 }, nil
1376 }
1377
1378 func (c *gRPCClient) GetSubscription(ctx context.Context, req *analyticshubpb.GetSubscriptionRequest, opts ...gax.CallOption) (*analyticshubpb.Subscription, error) {
1379 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1380
1381 hds = append(c.xGoogHeaders, hds...)
1382 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1383 opts = append((*c.CallOptions).GetSubscription[0:len((*c.CallOptions).GetSubscription):len((*c.CallOptions).GetSubscription)], opts...)
1384 var resp *analyticshubpb.Subscription
1385 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1386 var err error
1387 resp, err = c.client.GetSubscription(ctx, req, settings.GRPC...)
1388 return err
1389 }, opts...)
1390 if err != nil {
1391 return nil, err
1392 }
1393 return resp, nil
1394 }
1395
1396 func (c *gRPCClient) ListSubscriptions(ctx context.Context, req *analyticshubpb.ListSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator {
1397 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1398
1399 hds = append(c.xGoogHeaders, hds...)
1400 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1401 opts = append((*c.CallOptions).ListSubscriptions[0:len((*c.CallOptions).ListSubscriptions):len((*c.CallOptions).ListSubscriptions)], opts...)
1402 it := &SubscriptionIterator{}
1403 req = proto.Clone(req).(*analyticshubpb.ListSubscriptionsRequest)
1404 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.Subscription, string, error) {
1405 resp := &analyticshubpb.ListSubscriptionsResponse{}
1406 if pageToken != "" {
1407 req.PageToken = pageToken
1408 }
1409 if pageSize > math.MaxInt32 {
1410 req.PageSize = math.MaxInt32
1411 } else if pageSize != 0 {
1412 req.PageSize = int32(pageSize)
1413 }
1414 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1415 var err error
1416 resp, err = c.client.ListSubscriptions(ctx, req, settings.GRPC...)
1417 return err
1418 }, opts...)
1419 if err != nil {
1420 return nil, "", err
1421 }
1422
1423 it.Response = resp
1424 return resp.GetSubscriptions(), resp.GetNextPageToken(), nil
1425 }
1426 fetch := func(pageSize int, pageToken string) (string, error) {
1427 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1428 if err != nil {
1429 return "", err
1430 }
1431 it.items = append(it.items, items...)
1432 return nextPageToken, nil
1433 }
1434
1435 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1436 it.pageInfo.MaxSize = int(req.GetPageSize())
1437 it.pageInfo.Token = req.GetPageToken()
1438
1439 return it
1440 }
1441
1442 func (c *gRPCClient) ListSharedResourceSubscriptions(ctx context.Context, req *analyticshubpb.ListSharedResourceSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator {
1443 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1444
1445 hds = append(c.xGoogHeaders, hds...)
1446 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1447 opts = append((*c.CallOptions).ListSharedResourceSubscriptions[0:len((*c.CallOptions).ListSharedResourceSubscriptions):len((*c.CallOptions).ListSharedResourceSubscriptions)], opts...)
1448 it := &SubscriptionIterator{}
1449 req = proto.Clone(req).(*analyticshubpb.ListSharedResourceSubscriptionsRequest)
1450 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.Subscription, string, error) {
1451 resp := &analyticshubpb.ListSharedResourceSubscriptionsResponse{}
1452 if pageToken != "" {
1453 req.PageToken = pageToken
1454 }
1455 if pageSize > math.MaxInt32 {
1456 req.PageSize = math.MaxInt32
1457 } else if pageSize != 0 {
1458 req.PageSize = int32(pageSize)
1459 }
1460 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1461 var err error
1462 resp, err = c.client.ListSharedResourceSubscriptions(ctx, req, settings.GRPC...)
1463 return err
1464 }, opts...)
1465 if err != nil {
1466 return nil, "", err
1467 }
1468
1469 it.Response = resp
1470 return resp.GetSharedResourceSubscriptions(), resp.GetNextPageToken(), nil
1471 }
1472 fetch := func(pageSize int, pageToken string) (string, error) {
1473 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1474 if err != nil {
1475 return "", err
1476 }
1477 it.items = append(it.items, items...)
1478 return nextPageToken, nil
1479 }
1480
1481 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1482 it.pageInfo.MaxSize = int(req.GetPageSize())
1483 it.pageInfo.Token = req.GetPageToken()
1484
1485 return it
1486 }
1487
1488 func (c *gRPCClient) RevokeSubscription(ctx context.Context, req *analyticshubpb.RevokeSubscriptionRequest, opts ...gax.CallOption) (*analyticshubpb.RevokeSubscriptionResponse, error) {
1489 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1490
1491 hds = append(c.xGoogHeaders, hds...)
1492 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1493 opts = append((*c.CallOptions).RevokeSubscription[0:len((*c.CallOptions).RevokeSubscription):len((*c.CallOptions).RevokeSubscription)], opts...)
1494 var resp *analyticshubpb.RevokeSubscriptionResponse
1495 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1496 var err error
1497 resp, err = c.client.RevokeSubscription(ctx, req, settings.GRPC...)
1498 return err
1499 }, opts...)
1500 if err != nil {
1501 return nil, err
1502 }
1503 return resp, nil
1504 }
1505
1506 func (c *gRPCClient) DeleteSubscription(ctx context.Context, req *analyticshubpb.DeleteSubscriptionRequest, opts ...gax.CallOption) (*DeleteSubscriptionOperation, error) {
1507 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1508
1509 hds = append(c.xGoogHeaders, hds...)
1510 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1511 opts = append((*c.CallOptions).DeleteSubscription[0:len((*c.CallOptions).DeleteSubscription):len((*c.CallOptions).DeleteSubscription)], opts...)
1512 var resp *longrunningpb.Operation
1513 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1514 var err error
1515 resp, err = c.client.DeleteSubscription(ctx, req, settings.GRPC...)
1516 return err
1517 }, opts...)
1518 if err != nil {
1519 return nil, err
1520 }
1521 return &DeleteSubscriptionOperation{
1522 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1523 }, nil
1524 }
1525
1526 func (c *gRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1527 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1528
1529 hds = append(c.xGoogHeaders, hds...)
1530 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1531 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
1532 var resp *iampb.Policy
1533 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1534 var err error
1535 resp, err = c.client.GetIamPolicy(ctx, req, settings.GRPC...)
1536 return err
1537 }, opts...)
1538 if err != nil {
1539 return nil, err
1540 }
1541 return resp, nil
1542 }
1543
1544 func (c *gRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1545 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1546
1547 hds = append(c.xGoogHeaders, hds...)
1548 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1549 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
1550 var resp *iampb.Policy
1551 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1552 var err error
1553 resp, err = c.client.SetIamPolicy(ctx, req, settings.GRPC...)
1554 return err
1555 }, opts...)
1556 if err != nil {
1557 return nil, err
1558 }
1559 return resp, nil
1560 }
1561
1562 func (c *gRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
1563 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1564
1565 hds = append(c.xGoogHeaders, hds...)
1566 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1567 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
1568 var resp *iampb.TestIamPermissionsResponse
1569 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1570 var err error
1571 resp, err = c.client.TestIamPermissions(ctx, req, settings.GRPC...)
1572 return err
1573 }, opts...)
1574 if err != nil {
1575 return nil, err
1576 }
1577 return resp, nil
1578 }
1579
1580
1581 func (c *restClient) ListDataExchanges(ctx context.Context, req *analyticshubpb.ListDataExchangesRequest, opts ...gax.CallOption) *DataExchangeIterator {
1582 it := &DataExchangeIterator{}
1583 req = proto.Clone(req).(*analyticshubpb.ListDataExchangesRequest)
1584 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1585 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.DataExchange, string, error) {
1586 resp := &analyticshubpb.ListDataExchangesResponse{}
1587 if pageToken != "" {
1588 req.PageToken = pageToken
1589 }
1590 if pageSize > math.MaxInt32 {
1591 req.PageSize = math.MaxInt32
1592 } else if pageSize != 0 {
1593 req.PageSize = int32(pageSize)
1594 }
1595 baseUrl, err := url.Parse(c.endpoint)
1596 if err != nil {
1597 return nil, "", err
1598 }
1599 baseUrl.Path += fmt.Sprintf("/v1/%v/dataExchanges", req.GetParent())
1600
1601 params := url.Values{}
1602 if req.GetPageSize() != 0 {
1603 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1604 }
1605 if req.GetPageToken() != "" {
1606 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1607 }
1608
1609 baseUrl.RawQuery = params.Encode()
1610
1611
1612 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1613 headers := gax.BuildHeaders(ctx, hds...)
1614 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1615 if settings.Path != "" {
1616 baseUrl.Path = settings.Path
1617 }
1618 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1619 if err != nil {
1620 return err
1621 }
1622 httpReq.Header = headers
1623
1624 httpRsp, err := c.httpClient.Do(httpReq)
1625 if err != nil {
1626 return err
1627 }
1628 defer httpRsp.Body.Close()
1629
1630 if err = googleapi.CheckResponse(httpRsp); err != nil {
1631 return err
1632 }
1633
1634 buf, err := io.ReadAll(httpRsp.Body)
1635 if err != nil {
1636 return err
1637 }
1638
1639 if err := unm.Unmarshal(buf, resp); err != nil {
1640 return err
1641 }
1642
1643 return nil
1644 }, opts...)
1645 if e != nil {
1646 return nil, "", e
1647 }
1648 it.Response = resp
1649 return resp.GetDataExchanges(), resp.GetNextPageToken(), nil
1650 }
1651
1652 fetch := func(pageSize int, pageToken string) (string, error) {
1653 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1654 if err != nil {
1655 return "", err
1656 }
1657 it.items = append(it.items, items...)
1658 return nextPageToken, nil
1659 }
1660
1661 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1662 it.pageInfo.MaxSize = int(req.GetPageSize())
1663 it.pageInfo.Token = req.GetPageToken()
1664
1665 return it
1666 }
1667
1668
1669
1670 func (c *restClient) ListOrgDataExchanges(ctx context.Context, req *analyticshubpb.ListOrgDataExchangesRequest, opts ...gax.CallOption) *DataExchangeIterator {
1671 it := &DataExchangeIterator{}
1672 req = proto.Clone(req).(*analyticshubpb.ListOrgDataExchangesRequest)
1673 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1674 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.DataExchange, string, error) {
1675 resp := &analyticshubpb.ListOrgDataExchangesResponse{}
1676 if pageToken != "" {
1677 req.PageToken = pageToken
1678 }
1679 if pageSize > math.MaxInt32 {
1680 req.PageSize = math.MaxInt32
1681 } else if pageSize != 0 {
1682 req.PageSize = int32(pageSize)
1683 }
1684 baseUrl, err := url.Parse(c.endpoint)
1685 if err != nil {
1686 return nil, "", err
1687 }
1688 baseUrl.Path += fmt.Sprintf("/v1/%v/dataExchanges", req.GetOrganization())
1689
1690 params := url.Values{}
1691 if req.GetPageSize() != 0 {
1692 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1693 }
1694 if req.GetPageToken() != "" {
1695 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1696 }
1697
1698 baseUrl.RawQuery = params.Encode()
1699
1700
1701 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1702 headers := gax.BuildHeaders(ctx, hds...)
1703 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1704 if settings.Path != "" {
1705 baseUrl.Path = settings.Path
1706 }
1707 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1708 if err != nil {
1709 return err
1710 }
1711 httpReq.Header = headers
1712
1713 httpRsp, err := c.httpClient.Do(httpReq)
1714 if err != nil {
1715 return err
1716 }
1717 defer httpRsp.Body.Close()
1718
1719 if err = googleapi.CheckResponse(httpRsp); err != nil {
1720 return err
1721 }
1722
1723 buf, err := io.ReadAll(httpRsp.Body)
1724 if err != nil {
1725 return err
1726 }
1727
1728 if err := unm.Unmarshal(buf, resp); err != nil {
1729 return err
1730 }
1731
1732 return nil
1733 }, opts...)
1734 if e != nil {
1735 return nil, "", e
1736 }
1737 it.Response = resp
1738 return resp.GetDataExchanges(), resp.GetNextPageToken(), nil
1739 }
1740
1741 fetch := func(pageSize int, pageToken string) (string, error) {
1742 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1743 if err != nil {
1744 return "", err
1745 }
1746 it.items = append(it.items, items...)
1747 return nextPageToken, nil
1748 }
1749
1750 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1751 it.pageInfo.MaxSize = int(req.GetPageSize())
1752 it.pageInfo.Token = req.GetPageToken()
1753
1754 return it
1755 }
1756
1757
1758 func (c *restClient) GetDataExchange(ctx context.Context, req *analyticshubpb.GetDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
1759 baseUrl, err := url.Parse(c.endpoint)
1760 if err != nil {
1761 return nil, err
1762 }
1763 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1764
1765
1766 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1767
1768 hds = append(c.xGoogHeaders, hds...)
1769 hds = append(hds, "Content-Type", "application/json")
1770 headers := gax.BuildHeaders(ctx, hds...)
1771 opts = append((*c.CallOptions).GetDataExchange[0:len((*c.CallOptions).GetDataExchange):len((*c.CallOptions).GetDataExchange)], opts...)
1772 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1773 resp := &analyticshubpb.DataExchange{}
1774 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1775 if settings.Path != "" {
1776 baseUrl.Path = settings.Path
1777 }
1778 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1779 if err != nil {
1780 return err
1781 }
1782 httpReq = httpReq.WithContext(ctx)
1783 httpReq.Header = headers
1784
1785 httpRsp, err := c.httpClient.Do(httpReq)
1786 if err != nil {
1787 return err
1788 }
1789 defer httpRsp.Body.Close()
1790
1791 if err = googleapi.CheckResponse(httpRsp); err != nil {
1792 return err
1793 }
1794
1795 buf, err := io.ReadAll(httpRsp.Body)
1796 if err != nil {
1797 return err
1798 }
1799
1800 if err := unm.Unmarshal(buf, resp); err != nil {
1801 return err
1802 }
1803
1804 return nil
1805 }, opts...)
1806 if e != nil {
1807 return nil, e
1808 }
1809 return resp, nil
1810 }
1811
1812
1813 func (c *restClient) CreateDataExchange(ctx context.Context, req *analyticshubpb.CreateDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
1814 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1815 body := req.GetDataExchange()
1816 jsonReq, err := m.Marshal(body)
1817 if err != nil {
1818 return nil, err
1819 }
1820
1821 baseUrl, err := url.Parse(c.endpoint)
1822 if err != nil {
1823 return nil, err
1824 }
1825 baseUrl.Path += fmt.Sprintf("/v1/%v/dataExchanges", req.GetParent())
1826
1827 params := url.Values{}
1828 params.Add("dataExchangeId", fmt.Sprintf("%v", req.GetDataExchangeId()))
1829
1830 baseUrl.RawQuery = params.Encode()
1831
1832
1833 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1834
1835 hds = append(c.xGoogHeaders, hds...)
1836 hds = append(hds, "Content-Type", "application/json")
1837 headers := gax.BuildHeaders(ctx, hds...)
1838 opts = append((*c.CallOptions).CreateDataExchange[0:len((*c.CallOptions).CreateDataExchange):len((*c.CallOptions).CreateDataExchange)], opts...)
1839 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1840 resp := &analyticshubpb.DataExchange{}
1841 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1842 if settings.Path != "" {
1843 baseUrl.Path = settings.Path
1844 }
1845 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1846 if err != nil {
1847 return err
1848 }
1849 httpReq = httpReq.WithContext(ctx)
1850 httpReq.Header = headers
1851
1852 httpRsp, err := c.httpClient.Do(httpReq)
1853 if err != nil {
1854 return err
1855 }
1856 defer httpRsp.Body.Close()
1857
1858 if err = googleapi.CheckResponse(httpRsp); err != nil {
1859 return err
1860 }
1861
1862 buf, err := io.ReadAll(httpRsp.Body)
1863 if err != nil {
1864 return err
1865 }
1866
1867 if err := unm.Unmarshal(buf, resp); err != nil {
1868 return err
1869 }
1870
1871 return nil
1872 }, opts...)
1873 if e != nil {
1874 return nil, e
1875 }
1876 return resp, nil
1877 }
1878
1879
1880 func (c *restClient) UpdateDataExchange(ctx context.Context, req *analyticshubpb.UpdateDataExchangeRequest, opts ...gax.CallOption) (*analyticshubpb.DataExchange, error) {
1881 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1882 body := req.GetDataExchange()
1883 jsonReq, err := m.Marshal(body)
1884 if err != nil {
1885 return nil, err
1886 }
1887
1888 baseUrl, err := url.Parse(c.endpoint)
1889 if err != nil {
1890 return nil, err
1891 }
1892 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetDataExchange().GetName())
1893
1894 params := url.Values{}
1895 if req.GetUpdateMask() != nil {
1896 updateMask, err := protojson.Marshal(req.GetUpdateMask())
1897 if err != nil {
1898 return nil, err
1899 }
1900 params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
1901 }
1902
1903 baseUrl.RawQuery = params.Encode()
1904
1905
1906 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "data_exchange.name", url.QueryEscape(req.GetDataExchange().GetName()))}
1907
1908 hds = append(c.xGoogHeaders, hds...)
1909 hds = append(hds, "Content-Type", "application/json")
1910 headers := gax.BuildHeaders(ctx, hds...)
1911 opts = append((*c.CallOptions).UpdateDataExchange[0:len((*c.CallOptions).UpdateDataExchange):len((*c.CallOptions).UpdateDataExchange)], opts...)
1912 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1913 resp := &analyticshubpb.DataExchange{}
1914 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1915 if settings.Path != "" {
1916 baseUrl.Path = settings.Path
1917 }
1918 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1919 if err != nil {
1920 return err
1921 }
1922 httpReq = httpReq.WithContext(ctx)
1923 httpReq.Header = headers
1924
1925 httpRsp, err := c.httpClient.Do(httpReq)
1926 if err != nil {
1927 return err
1928 }
1929 defer httpRsp.Body.Close()
1930
1931 if err = googleapi.CheckResponse(httpRsp); err != nil {
1932 return err
1933 }
1934
1935 buf, err := io.ReadAll(httpRsp.Body)
1936 if err != nil {
1937 return err
1938 }
1939
1940 if err := unm.Unmarshal(buf, resp); err != nil {
1941 return err
1942 }
1943
1944 return nil
1945 }, opts...)
1946 if e != nil {
1947 return nil, e
1948 }
1949 return resp, nil
1950 }
1951
1952
1953 func (c *restClient) DeleteDataExchange(ctx context.Context, req *analyticshubpb.DeleteDataExchangeRequest, opts ...gax.CallOption) error {
1954 baseUrl, err := url.Parse(c.endpoint)
1955 if err != nil {
1956 return err
1957 }
1958 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1959
1960
1961 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1962
1963 hds = append(c.xGoogHeaders, hds...)
1964 hds = append(hds, "Content-Type", "application/json")
1965 headers := gax.BuildHeaders(ctx, hds...)
1966 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1967 if settings.Path != "" {
1968 baseUrl.Path = settings.Path
1969 }
1970 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1971 if err != nil {
1972 return err
1973 }
1974 httpReq = httpReq.WithContext(ctx)
1975 httpReq.Header = headers
1976
1977 httpRsp, err := c.httpClient.Do(httpReq)
1978 if err != nil {
1979 return err
1980 }
1981 defer httpRsp.Body.Close()
1982
1983
1984
1985 return googleapi.CheckResponse(httpRsp)
1986 }, opts...)
1987 }
1988
1989
1990 func (c *restClient) ListListings(ctx context.Context, req *analyticshubpb.ListListingsRequest, opts ...gax.CallOption) *ListingIterator {
1991 it := &ListingIterator{}
1992 req = proto.Clone(req).(*analyticshubpb.ListListingsRequest)
1993 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1994 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.Listing, string, error) {
1995 resp := &analyticshubpb.ListListingsResponse{}
1996 if pageToken != "" {
1997 req.PageToken = pageToken
1998 }
1999 if pageSize > math.MaxInt32 {
2000 req.PageSize = math.MaxInt32
2001 } else if pageSize != 0 {
2002 req.PageSize = int32(pageSize)
2003 }
2004 baseUrl, err := url.Parse(c.endpoint)
2005 if err != nil {
2006 return nil, "", err
2007 }
2008 baseUrl.Path += fmt.Sprintf("/v1/%v/listings", req.GetParent())
2009
2010 params := url.Values{}
2011 if req.GetPageSize() != 0 {
2012 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2013 }
2014 if req.GetPageToken() != "" {
2015 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2016 }
2017
2018 baseUrl.RawQuery = params.Encode()
2019
2020
2021 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2022 headers := gax.BuildHeaders(ctx, hds...)
2023 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2024 if settings.Path != "" {
2025 baseUrl.Path = settings.Path
2026 }
2027 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2028 if err != nil {
2029 return err
2030 }
2031 httpReq.Header = headers
2032
2033 httpRsp, err := c.httpClient.Do(httpReq)
2034 if err != nil {
2035 return err
2036 }
2037 defer httpRsp.Body.Close()
2038
2039 if err = googleapi.CheckResponse(httpRsp); err != nil {
2040 return err
2041 }
2042
2043 buf, err := io.ReadAll(httpRsp.Body)
2044 if err != nil {
2045 return err
2046 }
2047
2048 if err := unm.Unmarshal(buf, resp); err != nil {
2049 return err
2050 }
2051
2052 return nil
2053 }, opts...)
2054 if e != nil {
2055 return nil, "", e
2056 }
2057 it.Response = resp
2058 return resp.GetListings(), resp.GetNextPageToken(), nil
2059 }
2060
2061 fetch := func(pageSize int, pageToken string) (string, error) {
2062 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2063 if err != nil {
2064 return "", err
2065 }
2066 it.items = append(it.items, items...)
2067 return nextPageToken, nil
2068 }
2069
2070 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2071 it.pageInfo.MaxSize = int(req.GetPageSize())
2072 it.pageInfo.Token = req.GetPageToken()
2073
2074 return it
2075 }
2076
2077
2078 func (c *restClient) GetListing(ctx context.Context, req *analyticshubpb.GetListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
2079 baseUrl, err := url.Parse(c.endpoint)
2080 if err != nil {
2081 return nil, err
2082 }
2083 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2084
2085
2086 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2087
2088 hds = append(c.xGoogHeaders, hds...)
2089 hds = append(hds, "Content-Type", "application/json")
2090 headers := gax.BuildHeaders(ctx, hds...)
2091 opts = append((*c.CallOptions).GetListing[0:len((*c.CallOptions).GetListing):len((*c.CallOptions).GetListing)], opts...)
2092 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2093 resp := &analyticshubpb.Listing{}
2094 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2095 if settings.Path != "" {
2096 baseUrl.Path = settings.Path
2097 }
2098 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2099 if err != nil {
2100 return err
2101 }
2102 httpReq = httpReq.WithContext(ctx)
2103 httpReq.Header = headers
2104
2105 httpRsp, err := c.httpClient.Do(httpReq)
2106 if err != nil {
2107 return err
2108 }
2109 defer httpRsp.Body.Close()
2110
2111 if err = googleapi.CheckResponse(httpRsp); err != nil {
2112 return err
2113 }
2114
2115 buf, err := io.ReadAll(httpRsp.Body)
2116 if err != nil {
2117 return err
2118 }
2119
2120 if err := unm.Unmarshal(buf, resp); err != nil {
2121 return err
2122 }
2123
2124 return nil
2125 }, opts...)
2126 if e != nil {
2127 return nil, e
2128 }
2129 return resp, nil
2130 }
2131
2132
2133 func (c *restClient) CreateListing(ctx context.Context, req *analyticshubpb.CreateListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
2134 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2135 body := req.GetListing()
2136 jsonReq, err := m.Marshal(body)
2137 if err != nil {
2138 return nil, err
2139 }
2140
2141 baseUrl, err := url.Parse(c.endpoint)
2142 if err != nil {
2143 return nil, err
2144 }
2145 baseUrl.Path += fmt.Sprintf("/v1/%v/listings", req.GetParent())
2146
2147 params := url.Values{}
2148 params.Add("listingId", fmt.Sprintf("%v", req.GetListingId()))
2149
2150 baseUrl.RawQuery = params.Encode()
2151
2152
2153 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2154
2155 hds = append(c.xGoogHeaders, hds...)
2156 hds = append(hds, "Content-Type", "application/json")
2157 headers := gax.BuildHeaders(ctx, hds...)
2158 opts = append((*c.CallOptions).CreateListing[0:len((*c.CallOptions).CreateListing):len((*c.CallOptions).CreateListing)], opts...)
2159 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2160 resp := &analyticshubpb.Listing{}
2161 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2162 if settings.Path != "" {
2163 baseUrl.Path = settings.Path
2164 }
2165 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2166 if err != nil {
2167 return err
2168 }
2169 httpReq = httpReq.WithContext(ctx)
2170 httpReq.Header = headers
2171
2172 httpRsp, err := c.httpClient.Do(httpReq)
2173 if err != nil {
2174 return err
2175 }
2176 defer httpRsp.Body.Close()
2177
2178 if err = googleapi.CheckResponse(httpRsp); err != nil {
2179 return err
2180 }
2181
2182 buf, err := io.ReadAll(httpRsp.Body)
2183 if err != nil {
2184 return err
2185 }
2186
2187 if err := unm.Unmarshal(buf, resp); err != nil {
2188 return err
2189 }
2190
2191 return nil
2192 }, opts...)
2193 if e != nil {
2194 return nil, e
2195 }
2196 return resp, nil
2197 }
2198
2199
2200 func (c *restClient) UpdateListing(ctx context.Context, req *analyticshubpb.UpdateListingRequest, opts ...gax.CallOption) (*analyticshubpb.Listing, error) {
2201 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2202 body := req.GetListing()
2203 jsonReq, err := m.Marshal(body)
2204 if err != nil {
2205 return nil, err
2206 }
2207
2208 baseUrl, err := url.Parse(c.endpoint)
2209 if err != nil {
2210 return nil, err
2211 }
2212 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetListing().GetName())
2213
2214 params := url.Values{}
2215 if req.GetUpdateMask() != nil {
2216 updateMask, err := protojson.Marshal(req.GetUpdateMask())
2217 if err != nil {
2218 return nil, err
2219 }
2220 params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
2221 }
2222
2223 baseUrl.RawQuery = params.Encode()
2224
2225
2226 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "listing.name", url.QueryEscape(req.GetListing().GetName()))}
2227
2228 hds = append(c.xGoogHeaders, hds...)
2229 hds = append(hds, "Content-Type", "application/json")
2230 headers := gax.BuildHeaders(ctx, hds...)
2231 opts = append((*c.CallOptions).UpdateListing[0:len((*c.CallOptions).UpdateListing):len((*c.CallOptions).UpdateListing)], opts...)
2232 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2233 resp := &analyticshubpb.Listing{}
2234 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2235 if settings.Path != "" {
2236 baseUrl.Path = settings.Path
2237 }
2238 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
2239 if err != nil {
2240 return err
2241 }
2242 httpReq = httpReq.WithContext(ctx)
2243 httpReq.Header = headers
2244
2245 httpRsp, err := c.httpClient.Do(httpReq)
2246 if err != nil {
2247 return err
2248 }
2249 defer httpRsp.Body.Close()
2250
2251 if err = googleapi.CheckResponse(httpRsp); err != nil {
2252 return err
2253 }
2254
2255 buf, err := io.ReadAll(httpRsp.Body)
2256 if err != nil {
2257 return err
2258 }
2259
2260 if err := unm.Unmarshal(buf, resp); err != nil {
2261 return err
2262 }
2263
2264 return nil
2265 }, opts...)
2266 if e != nil {
2267 return nil, e
2268 }
2269 return resp, nil
2270 }
2271
2272
2273 func (c *restClient) DeleteListing(ctx context.Context, req *analyticshubpb.DeleteListingRequest, opts ...gax.CallOption) error {
2274 baseUrl, err := url.Parse(c.endpoint)
2275 if err != nil {
2276 return err
2277 }
2278 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2279
2280
2281 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2282
2283 hds = append(c.xGoogHeaders, hds...)
2284 hds = append(hds, "Content-Type", "application/json")
2285 headers := gax.BuildHeaders(ctx, hds...)
2286 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2287 if settings.Path != "" {
2288 baseUrl.Path = settings.Path
2289 }
2290 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2291 if err != nil {
2292 return err
2293 }
2294 httpReq = httpReq.WithContext(ctx)
2295 httpReq.Header = headers
2296
2297 httpRsp, err := c.httpClient.Do(httpReq)
2298 if err != nil {
2299 return err
2300 }
2301 defer httpRsp.Body.Close()
2302
2303
2304
2305 return googleapi.CheckResponse(httpRsp)
2306 }, opts...)
2307 }
2308
2309
2310
2311
2312
2313
2314
2315 func (c *restClient) SubscribeListing(ctx context.Context, req *analyticshubpb.SubscribeListingRequest, opts ...gax.CallOption) (*analyticshubpb.SubscribeListingResponse, error) {
2316 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2317 jsonReq, err := m.Marshal(req)
2318 if err != nil {
2319 return nil, err
2320 }
2321
2322 baseUrl, err := url.Parse(c.endpoint)
2323 if err != nil {
2324 return nil, err
2325 }
2326 baseUrl.Path += fmt.Sprintf("/v1/%v:subscribe", req.GetName())
2327
2328
2329 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2330
2331 hds = append(c.xGoogHeaders, hds...)
2332 hds = append(hds, "Content-Type", "application/json")
2333 headers := gax.BuildHeaders(ctx, hds...)
2334 opts = append((*c.CallOptions).SubscribeListing[0:len((*c.CallOptions).SubscribeListing):len((*c.CallOptions).SubscribeListing)], opts...)
2335 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2336 resp := &analyticshubpb.SubscribeListingResponse{}
2337 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2338 if settings.Path != "" {
2339 baseUrl.Path = settings.Path
2340 }
2341 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2342 if err != nil {
2343 return err
2344 }
2345 httpReq = httpReq.WithContext(ctx)
2346 httpReq.Header = headers
2347
2348 httpRsp, err := c.httpClient.Do(httpReq)
2349 if err != nil {
2350 return err
2351 }
2352 defer httpRsp.Body.Close()
2353
2354 if err = googleapi.CheckResponse(httpRsp); err != nil {
2355 return err
2356 }
2357
2358 buf, err := io.ReadAll(httpRsp.Body)
2359 if err != nil {
2360 return err
2361 }
2362
2363 if err := unm.Unmarshal(buf, resp); err != nil {
2364 return err
2365 }
2366
2367 return nil
2368 }, opts...)
2369 if e != nil {
2370 return nil, e
2371 }
2372 return resp, nil
2373 }
2374
2375
2376
2377 func (c *restClient) SubscribeDataExchange(ctx context.Context, req *analyticshubpb.SubscribeDataExchangeRequest, opts ...gax.CallOption) (*SubscribeDataExchangeOperation, error) {
2378 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2379 jsonReq, err := m.Marshal(req)
2380 if err != nil {
2381 return nil, err
2382 }
2383
2384 baseUrl, err := url.Parse(c.endpoint)
2385 if err != nil {
2386 return nil, err
2387 }
2388 baseUrl.Path += fmt.Sprintf("/v1/%v:subscribe", req.GetName())
2389
2390
2391 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2392
2393 hds = append(c.xGoogHeaders, hds...)
2394 hds = append(hds, "Content-Type", "application/json")
2395 headers := gax.BuildHeaders(ctx, hds...)
2396 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2397 resp := &longrunningpb.Operation{}
2398 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2399 if settings.Path != "" {
2400 baseUrl.Path = settings.Path
2401 }
2402 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2403 if err != nil {
2404 return err
2405 }
2406 httpReq = httpReq.WithContext(ctx)
2407 httpReq.Header = headers
2408
2409 httpRsp, err := c.httpClient.Do(httpReq)
2410 if err != nil {
2411 return err
2412 }
2413 defer httpRsp.Body.Close()
2414
2415 if err = googleapi.CheckResponse(httpRsp); err != nil {
2416 return err
2417 }
2418
2419 buf, err := io.ReadAll(httpRsp.Body)
2420 if err != nil {
2421 return err
2422 }
2423
2424 if err := unm.Unmarshal(buf, resp); err != nil {
2425 return err
2426 }
2427
2428 return nil
2429 }, opts...)
2430 if e != nil {
2431 return nil, e
2432 }
2433
2434 override := fmt.Sprintf("/v1/%s", resp.GetName())
2435 return &SubscribeDataExchangeOperation{
2436 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2437 pollPath: override,
2438 }, nil
2439 }
2440
2441
2442
2443
2444 func (c *restClient) RefreshSubscription(ctx context.Context, req *analyticshubpb.RefreshSubscriptionRequest, opts ...gax.CallOption) (*RefreshSubscriptionOperation, error) {
2445 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2446 jsonReq, err := m.Marshal(req)
2447 if err != nil {
2448 return nil, err
2449 }
2450
2451 baseUrl, err := url.Parse(c.endpoint)
2452 if err != nil {
2453 return nil, err
2454 }
2455 baseUrl.Path += fmt.Sprintf("/v1/%v:refresh", req.GetName())
2456
2457
2458 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2459
2460 hds = append(c.xGoogHeaders, hds...)
2461 hds = append(hds, "Content-Type", "application/json")
2462 headers := gax.BuildHeaders(ctx, hds...)
2463 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2464 resp := &longrunningpb.Operation{}
2465 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2466 if settings.Path != "" {
2467 baseUrl.Path = settings.Path
2468 }
2469 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2470 if err != nil {
2471 return err
2472 }
2473 httpReq = httpReq.WithContext(ctx)
2474 httpReq.Header = headers
2475
2476 httpRsp, err := c.httpClient.Do(httpReq)
2477 if err != nil {
2478 return err
2479 }
2480 defer httpRsp.Body.Close()
2481
2482 if err = googleapi.CheckResponse(httpRsp); err != nil {
2483 return err
2484 }
2485
2486 buf, err := io.ReadAll(httpRsp.Body)
2487 if err != nil {
2488 return err
2489 }
2490
2491 if err := unm.Unmarshal(buf, resp); err != nil {
2492 return err
2493 }
2494
2495 return nil
2496 }, opts...)
2497 if e != nil {
2498 return nil, e
2499 }
2500
2501 override := fmt.Sprintf("/v1/%s", resp.GetName())
2502 return &RefreshSubscriptionOperation{
2503 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2504 pollPath: override,
2505 }, nil
2506 }
2507
2508
2509 func (c *restClient) GetSubscription(ctx context.Context, req *analyticshubpb.GetSubscriptionRequest, opts ...gax.CallOption) (*analyticshubpb.Subscription, error) {
2510 baseUrl, err := url.Parse(c.endpoint)
2511 if err != nil {
2512 return nil, err
2513 }
2514 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2515
2516
2517 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2518
2519 hds = append(c.xGoogHeaders, hds...)
2520 hds = append(hds, "Content-Type", "application/json")
2521 headers := gax.BuildHeaders(ctx, hds...)
2522 opts = append((*c.CallOptions).GetSubscription[0:len((*c.CallOptions).GetSubscription):len((*c.CallOptions).GetSubscription)], opts...)
2523 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2524 resp := &analyticshubpb.Subscription{}
2525 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2526 if settings.Path != "" {
2527 baseUrl.Path = settings.Path
2528 }
2529 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2530 if err != nil {
2531 return err
2532 }
2533 httpReq = httpReq.WithContext(ctx)
2534 httpReq.Header = headers
2535
2536 httpRsp, err := c.httpClient.Do(httpReq)
2537 if err != nil {
2538 return err
2539 }
2540 defer httpRsp.Body.Close()
2541
2542 if err = googleapi.CheckResponse(httpRsp); err != nil {
2543 return err
2544 }
2545
2546 buf, err := io.ReadAll(httpRsp.Body)
2547 if err != nil {
2548 return err
2549 }
2550
2551 if err := unm.Unmarshal(buf, resp); err != nil {
2552 return err
2553 }
2554
2555 return nil
2556 }, opts...)
2557 if e != nil {
2558 return nil, e
2559 }
2560 return resp, nil
2561 }
2562
2563
2564 func (c *restClient) ListSubscriptions(ctx context.Context, req *analyticshubpb.ListSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator {
2565 it := &SubscriptionIterator{}
2566 req = proto.Clone(req).(*analyticshubpb.ListSubscriptionsRequest)
2567 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2568 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.Subscription, string, error) {
2569 resp := &analyticshubpb.ListSubscriptionsResponse{}
2570 if pageToken != "" {
2571 req.PageToken = pageToken
2572 }
2573 if pageSize > math.MaxInt32 {
2574 req.PageSize = math.MaxInt32
2575 } else if pageSize != 0 {
2576 req.PageSize = int32(pageSize)
2577 }
2578 baseUrl, err := url.Parse(c.endpoint)
2579 if err != nil {
2580 return nil, "", err
2581 }
2582 baseUrl.Path += fmt.Sprintf("/v1/%v/subscriptions", req.GetParent())
2583
2584 params := url.Values{}
2585 if req.GetFilter() != "" {
2586 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2587 }
2588 if req.GetPageSize() != 0 {
2589 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2590 }
2591 if req.GetPageToken() != "" {
2592 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2593 }
2594
2595 baseUrl.RawQuery = params.Encode()
2596
2597
2598 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2599 headers := gax.BuildHeaders(ctx, hds...)
2600 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2601 if settings.Path != "" {
2602 baseUrl.Path = settings.Path
2603 }
2604 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2605 if err != nil {
2606 return err
2607 }
2608 httpReq.Header = headers
2609
2610 httpRsp, err := c.httpClient.Do(httpReq)
2611 if err != nil {
2612 return err
2613 }
2614 defer httpRsp.Body.Close()
2615
2616 if err = googleapi.CheckResponse(httpRsp); err != nil {
2617 return err
2618 }
2619
2620 buf, err := io.ReadAll(httpRsp.Body)
2621 if err != nil {
2622 return err
2623 }
2624
2625 if err := unm.Unmarshal(buf, resp); err != nil {
2626 return err
2627 }
2628
2629 return nil
2630 }, opts...)
2631 if e != nil {
2632 return nil, "", e
2633 }
2634 it.Response = resp
2635 return resp.GetSubscriptions(), resp.GetNextPageToken(), nil
2636 }
2637
2638 fetch := func(pageSize int, pageToken string) (string, error) {
2639 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2640 if err != nil {
2641 return "", err
2642 }
2643 it.items = append(it.items, items...)
2644 return nextPageToken, nil
2645 }
2646
2647 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2648 it.pageInfo.MaxSize = int(req.GetPageSize())
2649 it.pageInfo.Token = req.GetPageToken()
2650
2651 return it
2652 }
2653
2654
2655 func (c *restClient) ListSharedResourceSubscriptions(ctx context.Context, req *analyticshubpb.ListSharedResourceSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator {
2656 it := &SubscriptionIterator{}
2657 req = proto.Clone(req).(*analyticshubpb.ListSharedResourceSubscriptionsRequest)
2658 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2659 it.InternalFetch = func(pageSize int, pageToken string) ([]*analyticshubpb.Subscription, string, error) {
2660 resp := &analyticshubpb.ListSharedResourceSubscriptionsResponse{}
2661 if pageToken != "" {
2662 req.PageToken = pageToken
2663 }
2664 if pageSize > math.MaxInt32 {
2665 req.PageSize = math.MaxInt32
2666 } else if pageSize != 0 {
2667 req.PageSize = int32(pageSize)
2668 }
2669 baseUrl, err := url.Parse(c.endpoint)
2670 if err != nil {
2671 return nil, "", err
2672 }
2673 baseUrl.Path += fmt.Sprintf("/v1/%v:listSubscriptions", req.GetResource())
2674
2675 params := url.Values{}
2676 if req.GetIncludeDeletedSubscriptions() {
2677 params.Add("includeDeletedSubscriptions", fmt.Sprintf("%v", req.GetIncludeDeletedSubscriptions()))
2678 }
2679 if req.GetPageSize() != 0 {
2680 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2681 }
2682 if req.GetPageToken() != "" {
2683 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2684 }
2685
2686 baseUrl.RawQuery = params.Encode()
2687
2688
2689 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2690 headers := gax.BuildHeaders(ctx, hds...)
2691 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2692 if settings.Path != "" {
2693 baseUrl.Path = settings.Path
2694 }
2695 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2696 if err != nil {
2697 return err
2698 }
2699 httpReq.Header = headers
2700
2701 httpRsp, err := c.httpClient.Do(httpReq)
2702 if err != nil {
2703 return err
2704 }
2705 defer httpRsp.Body.Close()
2706
2707 if err = googleapi.CheckResponse(httpRsp); err != nil {
2708 return err
2709 }
2710
2711 buf, err := io.ReadAll(httpRsp.Body)
2712 if err != nil {
2713 return err
2714 }
2715
2716 if err := unm.Unmarshal(buf, resp); err != nil {
2717 return err
2718 }
2719
2720 return nil
2721 }, opts...)
2722 if e != nil {
2723 return nil, "", e
2724 }
2725 it.Response = resp
2726 return resp.GetSharedResourceSubscriptions(), resp.GetNextPageToken(), nil
2727 }
2728
2729 fetch := func(pageSize int, pageToken string) (string, error) {
2730 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2731 if err != nil {
2732 return "", err
2733 }
2734 it.items = append(it.items, items...)
2735 return nextPageToken, nil
2736 }
2737
2738 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2739 it.pageInfo.MaxSize = int(req.GetPageSize())
2740 it.pageInfo.Token = req.GetPageToken()
2741
2742 return it
2743 }
2744
2745
2746 func (c *restClient) RevokeSubscription(ctx context.Context, req *analyticshubpb.RevokeSubscriptionRequest, opts ...gax.CallOption) (*analyticshubpb.RevokeSubscriptionResponse, error) {
2747 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2748 jsonReq, err := m.Marshal(req)
2749 if err != nil {
2750 return nil, err
2751 }
2752
2753 baseUrl, err := url.Parse(c.endpoint)
2754 if err != nil {
2755 return nil, err
2756 }
2757 baseUrl.Path += fmt.Sprintf("/v1/%v:revoke", req.GetName())
2758
2759
2760 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2761
2762 hds = append(c.xGoogHeaders, hds...)
2763 hds = append(hds, "Content-Type", "application/json")
2764 headers := gax.BuildHeaders(ctx, hds...)
2765 opts = append((*c.CallOptions).RevokeSubscription[0:len((*c.CallOptions).RevokeSubscription):len((*c.CallOptions).RevokeSubscription)], opts...)
2766 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2767 resp := &analyticshubpb.RevokeSubscriptionResponse{}
2768 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2769 if settings.Path != "" {
2770 baseUrl.Path = settings.Path
2771 }
2772 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2773 if err != nil {
2774 return err
2775 }
2776 httpReq = httpReq.WithContext(ctx)
2777 httpReq.Header = headers
2778
2779 httpRsp, err := c.httpClient.Do(httpReq)
2780 if err != nil {
2781 return err
2782 }
2783 defer httpRsp.Body.Close()
2784
2785 if err = googleapi.CheckResponse(httpRsp); err != nil {
2786 return err
2787 }
2788
2789 buf, err := io.ReadAll(httpRsp.Body)
2790 if err != nil {
2791 return err
2792 }
2793
2794 if err := unm.Unmarshal(buf, resp); err != nil {
2795 return err
2796 }
2797
2798 return nil
2799 }, opts...)
2800 if e != nil {
2801 return nil, e
2802 }
2803 return resp, nil
2804 }
2805
2806
2807 func (c *restClient) DeleteSubscription(ctx context.Context, req *analyticshubpb.DeleteSubscriptionRequest, opts ...gax.CallOption) (*DeleteSubscriptionOperation, error) {
2808 baseUrl, err := url.Parse(c.endpoint)
2809 if err != nil {
2810 return nil, err
2811 }
2812 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2813
2814
2815 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2816
2817 hds = append(c.xGoogHeaders, hds...)
2818 hds = append(hds, "Content-Type", "application/json")
2819 headers := gax.BuildHeaders(ctx, hds...)
2820 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2821 resp := &longrunningpb.Operation{}
2822 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2823 if settings.Path != "" {
2824 baseUrl.Path = settings.Path
2825 }
2826 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2827 if err != nil {
2828 return err
2829 }
2830 httpReq = httpReq.WithContext(ctx)
2831 httpReq.Header = headers
2832
2833 httpRsp, err := c.httpClient.Do(httpReq)
2834 if err != nil {
2835 return err
2836 }
2837 defer httpRsp.Body.Close()
2838
2839 if err = googleapi.CheckResponse(httpRsp); err != nil {
2840 return err
2841 }
2842
2843 buf, err := io.ReadAll(httpRsp.Body)
2844 if err != nil {
2845 return err
2846 }
2847
2848 if err := unm.Unmarshal(buf, resp); err != nil {
2849 return err
2850 }
2851
2852 return nil
2853 }, opts...)
2854 if e != nil {
2855 return nil, e
2856 }
2857
2858 override := fmt.Sprintf("/v1/%s", resp.GetName())
2859 return &DeleteSubscriptionOperation{
2860 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2861 pollPath: override,
2862 }, nil
2863 }
2864
2865
2866 func (c *restClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
2867 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2868 jsonReq, err := m.Marshal(req)
2869 if err != nil {
2870 return nil, err
2871 }
2872
2873 baseUrl, err := url.Parse(c.endpoint)
2874 if err != nil {
2875 return nil, err
2876 }
2877 baseUrl.Path += fmt.Sprintf("/v1/%v:getIamPolicy", req.GetResource())
2878
2879
2880 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2881
2882 hds = append(c.xGoogHeaders, hds...)
2883 hds = append(hds, "Content-Type", "application/json")
2884 headers := gax.BuildHeaders(ctx, hds...)
2885 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
2886 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2887 resp := &iampb.Policy{}
2888 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2889 if settings.Path != "" {
2890 baseUrl.Path = settings.Path
2891 }
2892 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2893 if err != nil {
2894 return err
2895 }
2896 httpReq = httpReq.WithContext(ctx)
2897 httpReq.Header = headers
2898
2899 httpRsp, err := c.httpClient.Do(httpReq)
2900 if err != nil {
2901 return err
2902 }
2903 defer httpRsp.Body.Close()
2904
2905 if err = googleapi.CheckResponse(httpRsp); err != nil {
2906 return err
2907 }
2908
2909 buf, err := io.ReadAll(httpRsp.Body)
2910 if err != nil {
2911 return err
2912 }
2913
2914 if err := unm.Unmarshal(buf, resp); err != nil {
2915 return err
2916 }
2917
2918 return nil
2919 }, opts...)
2920 if e != nil {
2921 return nil, e
2922 }
2923 return resp, nil
2924 }
2925
2926
2927 func (c *restClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
2928 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2929 jsonReq, err := m.Marshal(req)
2930 if err != nil {
2931 return nil, err
2932 }
2933
2934 baseUrl, err := url.Parse(c.endpoint)
2935 if err != nil {
2936 return nil, err
2937 }
2938 baseUrl.Path += fmt.Sprintf("/v1/%v:setIamPolicy", req.GetResource())
2939
2940
2941 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2942
2943 hds = append(c.xGoogHeaders, hds...)
2944 hds = append(hds, "Content-Type", "application/json")
2945 headers := gax.BuildHeaders(ctx, hds...)
2946 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
2947 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2948 resp := &iampb.Policy{}
2949 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2950 if settings.Path != "" {
2951 baseUrl.Path = settings.Path
2952 }
2953 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2954 if err != nil {
2955 return err
2956 }
2957 httpReq = httpReq.WithContext(ctx)
2958 httpReq.Header = headers
2959
2960 httpRsp, err := c.httpClient.Do(httpReq)
2961 if err != nil {
2962 return err
2963 }
2964 defer httpRsp.Body.Close()
2965
2966 if err = googleapi.CheckResponse(httpRsp); err != nil {
2967 return err
2968 }
2969
2970 buf, err := io.ReadAll(httpRsp.Body)
2971 if err != nil {
2972 return err
2973 }
2974
2975 if err := unm.Unmarshal(buf, resp); err != nil {
2976 return err
2977 }
2978
2979 return nil
2980 }, opts...)
2981 if e != nil {
2982 return nil, e
2983 }
2984 return resp, nil
2985 }
2986
2987
2988 func (c *restClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
2989 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2990 jsonReq, err := m.Marshal(req)
2991 if err != nil {
2992 return nil, err
2993 }
2994
2995 baseUrl, err := url.Parse(c.endpoint)
2996 if err != nil {
2997 return nil, err
2998 }
2999 baseUrl.Path += fmt.Sprintf("/v1/%v:testIamPermissions", req.GetResource())
3000
3001
3002 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
3003
3004 hds = append(c.xGoogHeaders, hds...)
3005 hds = append(hds, "Content-Type", "application/json")
3006 headers := gax.BuildHeaders(ctx, hds...)
3007 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
3008 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3009 resp := &iampb.TestIamPermissionsResponse{}
3010 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3011 if settings.Path != "" {
3012 baseUrl.Path = settings.Path
3013 }
3014 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3015 if err != nil {
3016 return err
3017 }
3018 httpReq = httpReq.WithContext(ctx)
3019 httpReq.Header = headers
3020
3021 httpRsp, err := c.httpClient.Do(httpReq)
3022 if err != nil {
3023 return err
3024 }
3025 defer httpRsp.Body.Close()
3026
3027 if err = googleapi.CheckResponse(httpRsp); err != nil {
3028 return err
3029 }
3030
3031 buf, err := io.ReadAll(httpRsp.Body)
3032 if err != nil {
3033 return err
3034 }
3035
3036 if err := unm.Unmarshal(buf, resp); err != nil {
3037 return err
3038 }
3039
3040 return nil
3041 }, opts...)
3042 if e != nil {
3043 return nil, e
3044 }
3045 return resp, nil
3046 }
3047
3048
3049
3050 func (c *gRPCClient) DeleteSubscriptionOperation(name string) *DeleteSubscriptionOperation {
3051 return &DeleteSubscriptionOperation{
3052 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3053 }
3054 }
3055
3056
3057
3058 func (c *restClient) DeleteSubscriptionOperation(name string) *DeleteSubscriptionOperation {
3059 override := fmt.Sprintf("/v1/%s", name)
3060 return &DeleteSubscriptionOperation{
3061 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3062 pollPath: override,
3063 }
3064 }
3065
3066
3067
3068 func (c *gRPCClient) RefreshSubscriptionOperation(name string) *RefreshSubscriptionOperation {
3069 return &RefreshSubscriptionOperation{
3070 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3071 }
3072 }
3073
3074
3075
3076 func (c *restClient) RefreshSubscriptionOperation(name string) *RefreshSubscriptionOperation {
3077 override := fmt.Sprintf("/v1/%s", name)
3078 return &RefreshSubscriptionOperation{
3079 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3080 pollPath: override,
3081 }
3082 }
3083
3084
3085
3086 func (c *gRPCClient) SubscribeDataExchangeOperation(name string) *SubscribeDataExchangeOperation {
3087 return &SubscribeDataExchangeOperation{
3088 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3089 }
3090 }
3091
3092
3093
3094 func (c *restClient) SubscribeDataExchangeOperation(name string) *SubscribeDataExchangeOperation {
3095 override := fmt.Sprintf("/v1/%s", name)
3096 return &SubscribeDataExchangeOperation{
3097 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
3098 pollPath: override,
3099 }
3100 }
3101
View as plain text